Changeset - 5b4fc2d5772f
[Not reviewed]
default
0 1 0
virii - 11 years ago 2013-12-23 17:46:38
virii@enn.lu
config files can now be passed via command line arguments
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
Scripts/update_server.pl
Show inline comments
 
#!/usr/bin/env perl
 
=About
 
This is a perlized "Update Server" script which should run out of the box
 
on most machines. If not you need to install HTTP::Tiny
 
sudo cpan
 
>install HTTP::Tiny
 

	
 
by virii
 
=cut
 
use HTTP::Tiny;
 
use IO::Socket;
 
######## [defaults] ########
 
@configs = qw(torrc torrc2);					 # every config file! like: torrc torrc0 torrc1 
 
@configs = @ARGV if @ARGV;					 # perl updater_server.pl torrc torrc0 torrc1
 
@configs = qw(torrc torrc2) unless @ARGV;			 # OR hardcode every config file! like: torrc torrc0 torrc1 
 
$data_dir = '/var/lib/tor';					 # default data dir
 
$pidfile  = '/var/run/tor/tor.pid';				 # default pid file
 
$API_url = 'http://enn.lu';					 # will be ignored if /etc/ennstatus_updater.conf is present
 
######## [ennstatus URL - config file] ######
 
if (-e '/etc/ennstatus_updater.conf') {
 
	open ennstatus, "<", "/etc/ennstatus_updater.conf" || die "Cannot open 'ennstatus_updater.conf'!\n";
 
    		while (<ennstatus>) {
 
        		$ennstatus_url = $1 if /^ennstatus_url = (.+)/i;
 
    		}
 
	close ennstatus;
 
} else {
 
	$ennstatus_url = $API_url;
 
}
 
######## [loop through configs] ########
 
for (1..scalar @configs) {
 
    open config, "<", "/etc/tor/" . $configs[$_ -1] || die "Cannot open $configs[$_ -1]\n";
 
        while (<config>) {
 
            $server_name = $1       if /^Nickname (\w+)/i;
 
            $server_type = 'Exit'   if /^ExitPolicy accept \*:\*/i;
 
            $server_type = 'Relay'  if /^ExitPolicy reject \*:\*/i;
 
            $server_type = 'Bridge' if /^BridgeRelay 1/i;
 
            $data_dir    = $1       if /^DataDirectory (.*)/i;
 
            $pidfile     = $1       if /^PidFile (.*)/i;
 
            $obfs        = 'True'   if /^ServerTransportPlugin obfs2,obfs3/i;
0 comments (0 inline, 0 general)