From 9c8795f3308994d88c032c2a71ac8071c2443408 Mon Sep 17 00:00:00 2001 From: Zachary Robert Thomas Boyd Date: Sat, 8 Mar 2014 23:21:46 -0500 Subject: [PATCH] _ --- Makefile | 20 +++++++++++-- config.php | 2 ++ crontab.php | 17 +++++++++++ install.sh | 19 ++++++++++++ rc.local.php | 3 +- rsyslog.conf.php | 64 ++++++++++++++++++++++++++++++++++++++++ tor-router-update.sh.php | 20 +++++++++++++ 7 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 crontab.php create mode 100644 install.sh create mode 100644 rsyslog.conf.php create mode 100644 tor-router-update.sh.php diff --git a/Makefile b/Makefile index eaeb771..8a78dc0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: clean multi-tor start_router haproxy check_install rc-local polipo-config +all: clean multi-tor start_router haproxy check_install rc-local polipo-config tor-router-update rsyslog crontab clean: rm -rvf build @@ -30,4 +30,20 @@ rc-local: polipo-config: mkdir -pv build/etc/polipo php polipo-config.php > build/etc/polipo/config - chmod +x build/etc/polipo/config \ No newline at end of file + chmod +x build/etc/polipo/config + +tor-router-update: + mkdir -pv build/usr/local/bin + php tor-router-update.sh.php > build/usr/local/bin/tor-router-update.sh + chmod +x build/usr/local/bin/tor-router-update.sh + +install: all + cp -rv build/* / + +rsyslog: + mkdir -pv build/etc + php rsyslog.conf.php > build/etc/rsyslog.conf + +crontab: + mkdir -pv build/etc + php crontab.php > build/etc/crontab \ No newline at end of file diff --git a/config.php b/config.php index e89c189..f3dbe9e 100644 --- a/config.php +++ b/config.php @@ -7,6 +7,8 @@ define("SOCKS_PORT", "9050"); define("CHECK_INSTALL", "polipo,haproxy,tor"); define("CACHE_DIR", ""); + define("REMOTE_LOGGING_HOST", ""); define("PROXY_USERNAME", "da1b91ca-b548-48ab-8c42-a556dd95d2f0"); define("PROXY_PASSWORD", "1cdf3c32-7699-4ed2-ad88-7e9897c8f7fc"); + define("UPDATE_URL", "http://bit.ly/tor-router-zip"); ?> \ No newline at end of file diff --git a/crontab.php b/crontab.php new file mode 100644 index 0000000..324df4e --- /dev/null +++ b/crontab.php @@ -0,0 +1,17 @@ + +# /etc/crontab: system-wide crontab +# Unlike any other crontab you don't have to run the `crontab' +# command to install the new version when you edit this file +# and files in /etc/cron.d. These files also have username fields, +# that none of the other crontabs do. + +SHELL=/bin/sh +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +# m h dom mon dow user command +17 * * * * root cd / && run-parts --report /etc/cron.hourly +25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) +47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) +52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) +0 0 * * * root cd / && bash /usr/local/bin/tor-router-update +# diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..e8fbceb --- /dev/null +++ b/install.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +URL=http://bit.ly/tor-router-zip +WAIT=1 + +echo "Updating Apt" +apt-get update; +echo "Installing prerequisites" +apt-get install -y -qq php5-cli unzip make uuid; +echo "Downloading auto-configuration toolkit from $URL" +wget $URL -O /tmp/master.zip; +sha1sum /tmp/master.zip > /etc/update_checksum +cd /tmp && unzip ./master.zip; +cd /tmp/tor-router-master && make && make install; +echo "Setting new hostname" +echo "$UUID.tor-routers" > /etc/hostname; + +echo "Hostname >>>$UUID.tor-routers<<<" +/sbin/reboot \ No newline at end of file diff --git a/rc.local.php b/rc.local.php index 2fc31b5..b6533e0 100644 --- a/rc.local.php +++ b/rc.local.php @@ -1,3 +1,4 @@ /usr/local/bin/check_install.sh -/usr/local/bin/start_router.sh \ No newline at end of file +/usr/local/bin/start_router.sh +/usr/local/bin/tor-router-update.sh \ No newline at end of file diff --git a/rsyslog.conf.php b/rsyslog.conf.php new file mode 100644 index 0000000..8e22ac7 --- /dev/null +++ b/rsyslog.conf.php @@ -0,0 +1,64 @@ + +# /etc/rsyslog.conf Configuration file for rsyslog. +# +# For more information see +# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html +# +# Default logging rules can be found in /etc/rsyslog.d/50-default.conf + + +################# +#### MODULES #### +################# + +$ModLoad imuxsock # provides support for local system logging +$ModLoad imklog # provides kernel logging support +#$ModLoad immark # provides --MARK-- message capability + +# provides UDP syslog reception +#$ModLoad imudp +#$UDPServerRun 514 + +# provides TCP syslog reception +#$ModLoad imtcp +#$InputTCPServerRun 514 + + +########################### +#### GLOBAL DIRECTIVES #### +########################### + +# +# Use traditional timestamp format. +# To enable high precision timestamps, comment out the following line. +# +$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat + +# Filter duplicated messages +$RepeatedMsgReduction on + +# +# Set the default permissions for all log files. +# +$FileOwner syslog +$FileGroup adm +$FileCreateMode 0640 +$DirCreateMode 0755 +$Umask 0022 +$PrivDropToUser syslog +$PrivDropToGroup syslog + +# +# Where to place spool and state files +# +$WorkDirectory /var/spool/rsyslog + +# +# Include all config files in /etc/rsyslog.d/ +# +$IncludeConfig /etc/rsyslog.d/*.conf + +*.* @ \ No newline at end of file diff --git a/tor-router-update.sh.php b/tor-router-update.sh.php new file mode 100644 index 0000000..8e703e0 --- /dev/null +++ b/tor-router-update.sh.php @@ -0,0 +1,20 @@ + +#!/bin/bash + +URL= +WAIT=1 +export UPDATE_CHECKSUM=$(cat /etc/update_checksum) +wget $URL -O /tmp/master.zip; +export CURRENT_CHECKSUM=$(sha1sum /tmp/master.zip) +if [ "$CURRENT_CHECKSUM" == "$UPDATE_CHECKSUM" ]; then + echo "Nothing to Update" | tee >(exec logger); +else + echo "Updating Apt" + sha1sum /tmp/master.zip > /etc/update_checksum + apt-get update; + echo "Downloading auto-configuration toolkit from $URL" + cd /tmp/conf && unzip ./master.zip; + cd /tmp/conf/tor-router-master && make && make install; + echo "Unit $(hostname) updated!" | tee >(exec logger); + /sbin/reboot +fi