-
Notifications
You must be signed in to change notification settings - Fork 3
/
update_server.sh
executable file
·41 lines (33 loc) · 1006 Bytes
/
update_server.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /bin/sh
usage="$(basename "$0") [-h] [-s server_address] -- update apache2 and Lifemap html scripts with specific server asdress.
where:
-h show this help text
-s server to use. (default: ip adress of the machine on the web)"
server=""
while getopts ':hs:' option; do
case "$option" in
h) echo "$usage"
exit
;;
s) server=$OPTARG
;;
:) printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ -z "$server" ]; then
echo "Getting IP adress of machine..."
server=$(curl ifconfig.me)
fi
#Exporting server address to /etc/lifemap_envir
sudo echo "export SERVER_ADDRESS="$server > /etc/lifemap_envir
sudo service apache2 restart
#Export server adress to jsvascript (needed for html pages)
sudo echo "var ServerAddress=\"$server\"" > /var/www/html/server-address.js