Install destination variable

main
Bob Mottram 2020-06-19 13:17:02 +01:00
parent e6a07de862
commit 1cb91fd4d0
2 changed files with 22 additions and 18 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
install_destination=/opt/epicyon
if [[ "$1" == 'remove' ]]; then if [[ "$1" == 'remove' ]]; then
echo 'Removing Epicyon i2p instance' echo 'Removing Epicyon i2p instance'
systemctl stop i2pd systemctl stop i2pd
@ -16,7 +18,7 @@ if [[ "$1" == 'remove' ]]; then
systemctl disable epicyon systemctl disable epicyon
rm /etc/nginx/sites-enabled/epicyon rm /etc/nginx/sites-enabled/epicyon
rm /etc/nginx/sites-availale/epicyon rm /etc/nginx/sites-availale/epicyon
rm -rf /opt/epicyon 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
@ -67,10 +69,10 @@ else
fi fi
echo 'Cloning the epicyon repo' echo 'Cloning the epicyon repo'
if [ ! -d /opt/epicyon ]; then if [ ! -d ${install_destination} ]; then
git clone https://gitlab.com/bashrc2/epicyon /opt/epicyon git clone https://gitlab.com/bashrc2/epicyon ${install_destination}
if [ ! -d /opt/epicyon ]; then if [ ! -d ${install_destination} ]; then
echo 'Epicyon repo failed to clone' echo 'Epicyon repo failed to clone'
exit 3 exit 3
fi fi
@ -79,14 +81,14 @@ fi
echo 'Adding an epicyon system user account' echo 'Adding an epicyon system user account'
if [ -f /usr/bin/pacman ]; then if [ -f /usr/bin/pacman ]; then
groupadd epicyon groupadd epicyon
useradd --system -g epicyon --home-dir=/opt/epicyon $username useradd --system -g epicyon --home-dir=${install_destination} $username
groupadd www-data groupadd www-data
useradd --system -g www-data --home-dir=/srv/http www-data useradd --system -g www-data --home-dir=/srv/http www-data
else else
adduser --system --home=/opt/epicyon --group $username adduser --system --home=${install_destination} --group $username
fi fi
chown -R epicyon:epicyon /opt/epicyon chown -R epicyon:epicyon ${install_destination}
echo 'Creating a command script to obtain i2p domain names from dat files' echo 'Creating a command script to obtain i2p domain names from dat files'
{ echo '#!/bin/bash'; { echo '#!/bin/bash';
@ -201,8 +203,8 @@ echo 'Creating Epicyon daemon'
echo 'Type=simple'; echo 'Type=simple';
echo "User=$username"; echo "User=$username";
echo "Group=$username"; echo "Group=$username";
echo 'WorkingDirectory=/opt/epicyon'; echo "WorkingDirectory=${install_destination}";
echo "ExecStart=/usr/bin/python3 /opt/epicyon/epicyon.py --http --i2p --port 80 --proxy ${EPICYON_PORT} --domain ${I2P_DOMAIN} --registration open"; echo "ExecStart=/usr/bin/python3 ${install_destination}/epicyon.py --http --i2p --port 80 --proxy ${EPICYON_PORT} --domain ${I2P_DOMAIN} --registration open";
echo "Environment=USER=$username"; echo "Environment=USER=$username";
echo 'Environment=PYTHONUNBUFFERED=true'; echo 'Environment=PYTHONUNBUFFERED=true';
echo 'Restart=always'; echo 'Restart=always';

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
install_destination=/opt/epicyon
if [[ "$1" == 'remove' ]]; then if [[ "$1" == 'remove' ]]; then
echo 'Removing Epicyon onion instance' echo 'Removing Epicyon onion instance'
systemctl stop tor systemctl stop tor
@ -11,7 +13,7 @@ if [[ "$1" == 'remove' ]]; then
systemctl disable epicyon systemctl disable epicyon
rm /etc/nginx/sites-enabled/epicyon rm /etc/nginx/sites-enabled/epicyon
rm /etc/nginx/sites-availale/epicyon rm /etc/nginx/sites-availale/epicyon
rm -rf /opt/epicyon 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
@ -48,10 +50,10 @@ else
fi fi
echo 'Cloning the epicyon repo' echo 'Cloning the epicyon repo'
if [ ! -d /opt/epicyon ]; then if [ ! -d ${install_destination} ]; then
git clone https://gitlab.com/bashrc2/epicyon /opt/epicyon git clone https://gitlab.com/bashrc2/epicyon ${install_destination}
if [ ! -d /opt/epicyon ]; then if [ ! -d ${install_destination} ]; then
echo 'Epicyon repo failed to clone' echo 'Epicyon repo failed to clone'
exit 3 exit 3
fi fi
@ -60,14 +62,14 @@ fi
echo 'Adding an epicyon system user account' echo 'Adding an epicyon system user account'
if [ -f /usr/bin/pacman ]; then if [ -f /usr/bin/pacman ]; then
groupadd epicyon groupadd epicyon
useradd --system -g epicyon --home-dir=/opt/epicyon $username useradd --system -g epicyon --home-dir=${install_destination} $username
groupadd www-data groupadd www-data
useradd --system -g www-data --home-dir=/srv/http www-data useradd --system -g www-data --home-dir=/srv/http www-data
else else
adduser --system --home=/opt/epicyon --group $username adduser --system --home=${install_destination} --group $username
fi fi
chown -R epicyon:epicyon /opt/epicyon chown -R epicyon:epicyon ${install_destination}
echo 'Creating onion site configuration' echo 'Creating onion site configuration'
if [ ! -d /etc/torrc.d ]; then if [ ! -d /etc/torrc.d ]; then
@ -114,8 +116,8 @@ echo 'Creating Epicyon daemon'
echo 'Type=simple'; echo 'Type=simple';
echo "User=$username"; echo "User=$username";
echo "Group=$username"; echo "Group=$username";
echo 'WorkingDirectory=/opt/epicyon'; echo "WorkingDirectory=${install_destination}";
echo "ExecStart=/usr/bin/python3 /opt/epicyon/epicyon.py --http --port 80 --proxy ${EPICYON_PORT} --domain ${ONION_DOMAIN} --registration open"; echo "ExecStart=/usr/bin/python3 ${install_destination}/epicyon.py --http --port 80 --proxy ${EPICYON_PORT} --domain ${ONION_DOMAIN} --registration open";
echo "Environment=USER=$username"; echo "Environment=USER=$username";
echo 'Environment=PYTHONUNBUFFERED=true'; echo 'Environment=PYTHONUNBUFFERED=true';
echo 'Restart=always'; echo 'Restart=always';