-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamicIP.sh
More file actions
executable file
·60 lines (50 loc) · 961 Bytes
/
dynamicIP.sh
File metadata and controls
executable file
·60 lines (50 loc) · 961 Bytes
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#
# Michael Piko
# Description:
# Date created: 18-06-2014
# last modified: dd-mm-20yy
#-# Usage:
#-#
#-#
#-#
#-# Description:
#-#
#-# Example:
# Script Variables:
DNSNAME=michaelpiko.no-ip.biz
NOIP2=/usr/local/bin/noip2
LOGGING=y
#see setEnvironment.sh, functions.sh, and variables.sh for explainations
. setEnvironment.sh
buildpath $LOGDIR
cleandir $LOGDIR 2
#recordscriptrun $(basename $0) $LOGBASE
# if ! enoughArgs +0 $#
# then
# usage
# exit 100
#fi
VERBOSE=n
if [ $# -eq 1 ] && [ $1 = "-v" ]
then
VERBOSE=y
shift
fi
# if the host is up then we can stop.
if isHostUp $DNSNAME
then
# all good.
onScreen $VERBOSE "$DNSNAME is up"
exit 0
fi
# Host must be down. restart noip2 if running
PROCESS=$(ps ax | grep $NOIP2 | grep -v grep)
if [ ! -z "$PROCESS" ]
then
PID=$(echo $PROCESS | cut -f1 -d" ")
onScreen $VERBOSE "killing $PID"
logEvent $LOGGING $LOGFILE "$NOIP2 restarted"
sudo kill $PID
fi
exec sudo $NOIP2