install code just on first run

This commit is contained in:
rootzoll
2021-09-01 01:18:13 +02:00
parent 80de89ede9
commit ba430b4c96

View File

@@ -164,42 +164,39 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
fi fi
# source code (one place for all instances) # source code (one place for all instances)
if [ -f /home/rtl/RTL/rtl ];then if [ -f /home/rtl/RTL/LICENSE ];then
echo "# OK - the RTL code is already present - just update" echo "# OK - the RTL code is already present"
cd /home/rtl/RTL cd /home/rtl/RTL
sudo -u rtl git pull
else else
# download source code and set to tag release # download source code and set to tag release
echo "# Get the RTL Source Code" echo "# Get the RTL Source Code"
sudo -u rtl rm -rf /home/rtl/RTL 2>/dev/null sudo -u rtl rm -rf /home/rtl/RTL 2>/dev/null
sudo -u rtl git clone https://github.com/ShahanaFarooqui/RTL.git /home/rtl/RTL sudo -u rtl git clone https://github.com/ShahanaFarooqui/RTL.git /home/rtl/RTL
cd /home/rtl/RTL cd /home/rtl/RTL
fi
# check https://github.com/Ride-The-Lightning/RTL/releases/ # check https://github.com/Ride-The-Lightning/RTL/releases/
sudo -u rtl git reset --hard $RTLVERSION sudo -u rtl git reset --hard $RTLVERSION
# from https://github.com/Ride-The-Lightning/RTL/commits/master # from https://github.com/Ride-The-Lightning/RTL/commits/master
# git checkout 917feebfa4fb583360c140e817c266649307ef72 # git checkout 917feebfa4fb583360c140e817c266649307ef72
if [ -d "/home/rtl/RTL" ]; then if [ -f /home/rtl/RTL/LICENSE ]; then
echo "# OK - RTL code copy looks good" echo "# OK - RTL code copy looks good"
else else
echo "# FAIL - RTL code not available" echo "# FAIL - RTL code not available"
echo "err='code download falied'" echo "err='code download falied'"
exit 1 exit 1
fi fi
echo
# install # install
echo "# Run: npm install" echo "# Run: npm install"
export NG_CLI_ANALYTICS=false export NG_CLI_ANALYTICS=false
sudo -u rtl npm install --only=prod sudo -u rtl npm install --only=prod
if ! [ $? -eq 0 ]; then if ! [ $? -eq 0 ]; then
echo "# FAIL - npm install did not run correctly, aborting" echo "# FAIL - npm install did not run correctly - deleting code and exit"
sudo rm -r /home/rtl/RTL
exit 1 exit 1
else else
echo "# OK - RTL install looks good" echo "# OK - RTL install looks good"
echo echo
fi fi
fi
echo "# Updating Firewall" echo "# Updating Firewall"
sudo ufw allow ${RTLHTTP} comment "${systemdService} HTTP" sudo ufw allow ${RTLHTTP} comment "${systemdService} HTTP"