Website start script

This commit is contained in:
CommanderRedYT
2020-12-12 16:24:23 +01:00
parent 5f0fde16d1
commit 33bd36deaa

29
start.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
#1=localhost, 2=local ip, so you can open on smartphone to test
MODE=$1
USERNAME="ccomm"
if [ -z "$MODE" ]
then
echo "Error: Pass argument"
exit
fi
GETIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
if [[ "$MODE" -eq 1 ]]
then
IP="localhost:80"
TAB="http://localhost/"
fi
if [[ "$MODE" -eq 2 ]]
then
IP="$GETIP:80"
TAB="http://$GETIP"
fi
printf 'Starting webserver for '
printf "${PWD##*/}"
printf ' ...\n'
echo $GETIP
su "$USERNAME" -c "firefox --new-tab $TAB"
sudo php -S $IP
cd ~