Skip to content
Snippets Groups Projects
Commit bf08776f authored by Bob Mottram's avatar Bob Mottram
Browse files

Handle rootdir

parent 44ba5c52
No related branches found
No related tags found
No related merge requests found
......@@ -35,13 +35,18 @@ CONFIGURATION_FILE=/root/${PROJECT_NAME}.cfg
ONION_ONLY='no'
site_domain=${PROJECT_NAME}.net
site_onion_port=8149
rootdir=
if [ "$1" ]; then
site_domain="$1"
if [[ "$site_domain" == '/tmp/'* ]]; then
rootdir=/tmp/$(echo -n "$site_domain" | awk -F '/' '{print $3}')
CONFIGURATION_FILE="$rootdir/root/${PROJECT_NAME}.cfg"
fi
fi
if [ ! -d /root/${PROJECT_NAME}/website ]; then
echo "Directory not found /root/${PROJECT_NAME}/website"
if [ ! -d "$rootdir/root/${PROJECT_NAME}/website" ]; then
echo "Directory not found $rootdir/root/${PROJECT_NAME}/website"
exit 1
fi
......@@ -53,7 +58,7 @@ if [[ "$ONION_ONLY" != 'no' ]]; then
site_domain=${PROJECT_NAME}_web
fi
dest_dir="/var/www/${site_domain}/htdocs"
dest_dir="$rootdir/var/www/${site_domain}/htdocs"
if [[ "${site_domain}" == *'/help' ]]; then
dest_dir="${site_domain}"
......@@ -64,14 +69,14 @@ if [ ! -d "$dest_dir" ]; then
mkdir -p "$dest_dir"
fi
if ! grep -q ":$site_onion_port" /etc/torrc.d/${PROJECT_NAME}; then
if ! grep -q ":$site_onion_port" "$rootdir/etc/torrc.d/${PROJECT_NAME}"; then
{ echo "HiddenServiceDir /var/lib/tor/hidden_service_${PROJECT_NAME}/";
echo 'HiddenServiceVersion 3';
echo "HiddenServicePort 80 127.0.0.1:${site_onion_port}"; } >> /etc/torrc.d/${PROJECT_NAME}
echo "HiddenServicePort 80 127.0.0.1:${site_onion_port}"; } >> "$rootdir/etc/torrc.d/${PROJECT_NAME}"
systemctl restart tor
fi
site_onion_domain=$(cat /var/lib/tor/hidden_service_${PROJECT_NAME}/hostname)
site_onion_domain=$(cat "$rootdir/var/lib/tor/hidden_service_${PROJECT_NAME}/hostname")
if [[ "$ONION_ONLY" == 'no' ]]; then
{ echo 'server {';
......@@ -195,9 +200,9 @@ if [[ "$ONION_ONLY" == 'no' ]]; then
echo " proxy_set_header X-Forwarded-For \$remote_addr;";
echo ' }';
echo '}';
echo ''; } > /etc/nginx/sites-available/${site_domain}
echo ''; } > "$rootdir/etc/nginx/sites-available/${site_domain}"
else
echo -n '' > /etc/nginx/sites-available/${site_domain}
echo -n '' > "$rootdir/etc/nginx/sites-available/${site_domain}"
fi
{ echo 'server {';
......@@ -258,12 +263,12 @@ fi
echo " proxy_set_header X-Forwarded-For \$remote_addr;";
echo ' }';
echo '}';
echo '# End of TURN Server'; } >> /etc/nginx/sites-available/${site_domain}
echo '# End of TURN Server'; } >> "$rootdir/etc/nginx/sites-available/${site_domain}"
nginx_ensite ${site_domain}
if [[ "$ONION_ONLY" == 'no' ]]; then
if [ ! -f "/etc/letsencrypt/live/${site_domain}/fullchain.pem" ]; then
if [ ! -f "$rootdir/etc/letsencrypt/live/${site_domain}/fullchain.pem" ]; then
DH_KEYLENGTH=2048
LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory'
${PROJECT_NAME}-addcert -e "${site_domain}" -s "$LETSENCRYPT_SERVER" --dhkey "$DH_KEYLENGTH"
......@@ -274,7 +279,7 @@ if [ ! "$lang" ]; then
lang='EN'
fi
cd /root/${PROJECT_NAME}/website || exit 2
cd "$rootdir/root/${PROJECT_NAME}/website" || exit 2
if [ ! -d "$dest_dir" ]; then
mkdir -p "$dest_dir"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment