Replace the tor daemon on debian

merge-requests/30/head
Bob Mottram 2021-01-31 22:01:02 +00:00
parent 00b7cf430f
commit 6d2ecf32ff
1 changed files with 49 additions and 32 deletions

View File

@ -16,10 +16,10 @@ if [[ "$1" == 'remove' ]]; then
rm "/etc/nginx/sites-availale/${username}" rm "/etc/nginx/sites-availale/${username}"
rm -rf ${install_destination} rm -rf ${install_destination}
if [ -d /var/www/cache ]; then if [ -d /var/www/cache ]; then
rm -rf /var/www/cache rm -rf /var/www/cache
fi fi
if [ -d /srv/http/cache ]; then if [ -d /srv/http/cache ]; then
rm -rf /srv/http/cache rm -rf /srv/http/cache
fi fi
userdel -r ${username} userdel -r ${username}
echo 'Epicyon onion instance removed' echo 'Epicyon onion instance removed'
@ -37,18 +37,35 @@ if [ -f /usr/bin/pacman ]; then
pacman -Syy pacman -Syy
pacman -S --noconfirm tor python-pip python-pysocks python-pycryptodome \ pacman -S --noconfirm tor python-pip python-pysocks python-pycryptodome \
imagemagick python-pillow python-requests \ imagemagick python-pillow python-requests \
perl-image-exiftool python-numpy python-dateutil \ perl-image-exiftool python-numpy python-dateutil \
certbot flake8 git qrencode bandit certbot flake8 git qrencode bandit
pip3 install pyLD pyqrcode pypng pip3 install pyLD pyqrcode pypng
else else
apt-get update apt-get update
apt-get -y install imagemagick python3-crypto python3-pycryptodome \ apt-get -y install imagemagick python3-crypto python3-pycryptodome \
python3-dateutil python3-idna python3-requests \ python3-dateutil python3-idna python3-requests \
python3-numpy python3-pil.imagetk python3-pip \ python3-numpy python3-pil.imagetk python3-pip \
python3-setuptools python3-socks python3-idna \ python3-setuptools python3-socks python3-idna \
libimage-exiftool-perl python3-flake8 python3-pyld \ libimage-exiftool-perl python3-flake8 python3-pyld \
python3-django-timezone-field tor nginx git qrencode \ python3-django-timezone-field tor nginx git qrencode \
python3-pyqrcode python3-png python3-bandit python3-pyqrcode python3-png python3-bandit
fi
if [[ "$(uname -a)" == *'Debian'* ]]; then
echo 'Fixing the tor daemon'
{ echo '[Unit]';
echo 'Description=Anonymizing overlay network for TCP (multi-instance-master)';
echo '';
echo '[Service]';
echo 'Type=simple';
echo 'User=root';
echo 'Group=debian-tor';
echo 'ExecStart=/usr/bin/tor --defaults-torrc /usr/share/tor/tor-service-defaults-torrc -f /etc/tor/torrc --RunAsDaemon 0';
echo '';
echo '[Install]';
echo 'WantedBy=multi-user.target'; } > /lib/systemd/system/tor.service
systemctl daemon-reload
systemctl restart tor
fi fi
echo 'Cloning the epicyon repo' echo 'Cloning the epicyon repo'
@ -56,8 +73,8 @@ if [ ! -d ${install_destination} ]; then
git clone https://gitlab.com/bashrc2/epicyon ${install_destination} git clone https://gitlab.com/bashrc2/epicyon ${install_destination}
if [ ! -d ${install_destination} ]; then if [ ! -d ${install_destination} ]; then
echo 'Epicyon repo failed to clone' echo 'Epicyon repo failed to clone'
exit 3 exit 3
fi fi
fi fi
@ -186,7 +203,7 @@ if [ ! -f /etc/nginx/nginx.conf ]; then
echo '}'; } > /etc/nginx/nginx.conf echo '}'; } > /etc/nginx/nginx.conf
else else
if ! grep -q 'include /etc/nginx/sites-enabled' /etc/nginx/nginx.conf; then if ! grep -q 'include /etc/nginx/sites-enabled' /etc/nginx/nginx.conf; then
echo 'include /etc/nginx/sites-enabled/*.conf;' >> /etc/nginx/nginx.conf echo 'include /etc/nginx/sites-enabled/*.conf;' >> /etc/nginx/nginx.conf
fi fi
fi fi
if [ ! -d /etc/nginx/conf.d ]; then if [ ! -d /etc/nginx/conf.d ]; then
@ -201,25 +218,25 @@ fi
if [ -f /usr/bin/pacman ]; then if [ -f /usr/bin/pacman ]; then
if [ ! -f /lib/systemd/system/nginx.service ]; then if [ ! -f /lib/systemd/system/nginx.service ]; then
echo 'Creating nginx daemon' echo 'Creating nginx daemon'
{ echo '[Unit]'; { echo '[Unit]';
echo 'Description=A high performance web server and a reverse proxy server'; echo 'Description=A high performance web server and a reverse proxy server';
echo 'Documentation=man:nginx(8)'; echo 'Documentation=man:nginx(8)';
echo 'After=network.target nss-lookup.target'; echo 'After=network.target nss-lookup.target';
echo '' echo ''
echo '[Service]'; echo '[Service]';
echo 'Type=forking'; echo 'Type=forking';
echo 'PIDFile=/run/nginx.pid'; echo 'PIDFile=/run/nginx.pid';
echo "ExecStartPre=$(which nginx) -t -q -g 'daemon on; master_process on;'"; echo "ExecStartPre=$(which nginx) -t -q -g 'daemon on; master_process on;'";
echo "ExecStart=$(which nginx) -g 'daemon on; master_process on;'"; echo "ExecStart=$(which nginx) -g 'daemon on; master_process on;'";
echo "ExecReload=$(which nginx) -g 'daemon on; master_process on;' -s reload"; echo "ExecReload=$(which nginx) -g 'daemon on; master_process on;' -s reload";
echo 'ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid'; echo 'ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid';
echo 'TimeoutStopSec=5'; echo 'TimeoutStopSec=5';
echo 'KillMode=mixed'; echo 'KillMode=mixed';
echo ''; echo '';
echo '[Install]'; echo '[Install]';
echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/nginx.service echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/nginx.service
systemctl enable nginx systemctl enable nginx
fi fi
fi fi