-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
90 lines (72 loc) · 2.28 KB
/
entrypoint.sh
File metadata and controls
90 lines (72 loc) · 2.28 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
app_help()
{
hid="$1"
err_="
Must be one option.
Options permited:
basic - login only using username and password
setd - use specific daemon user and group
dtime - set interval and timeout in daemon mode with custom group and user
otime - same dtime without daemon user and group
all - set all options include log info
"
if [ "$hid" = 'lt' ]; then
echo "$err_"
exit 1
fi
if [ "$hid" = 'notpermited' ]; then
echo "$err_"
exit 1
fi
}
start_duc()
{
option=$1
if [ "$option" = "basic" ]; then
noip-duc --daemonize -g all.ddnskey.com --username "$NOIP_USERNAME" --password "$NOIP_PASSWORD"
return "$!"
fi
if [ "$option" = "setd" ]; then
noip-duc -g all.ddnskey.com --username "$NOIP_USERNAME" --password "$NOIP_PASSWORD" --daemon-group "$NOIP_DAEMON_GROUP" --daemon-user "$NOIP_DAEMON_USER"
return "$!"
fi
if [ "$option" = "dtime" ]; then
noip-duc --daemonize -g all.ddnskey.com --username "$NOIP_USERNAME" --password "$NOIP_PASSWORD" --check-interval "$NOIP_CHECK_INTERVAL" --daemon-group "$NOIP_DAEMON_GROUP" --daemon-user "$NOIP_DAEMON_USER" --http-timeout "$NOIP_HTTP_TIMEOUT"
return "$!"
fi
if [ "$option" = "otime" ]; then
noip-duc --daemonize -g all.ddnskey.com --username "$NOIP_USERNAME" --password "$NOIP_PASSWORD" --check-interval "$NOIP_CHECK_INTERVAL" --http-timeout "$NOIP_HTTP_TIMEOUT"
return "$!"
fi
if [ "$option" = "all" ]; then
noip-duc --daemonize -g all.ddnskey.com --username "$NOIP_USERNAME" --password "$NOIP_PASSWORD" --check-interval "$NOIP_CHECK_INTERVAL" --daemon-group "$NOIP_DAEMON_GROUP" --daemon-user "$NOIP_DAEMON_USER" --http-timeout "$NOIP_HTTP_TIMEOUT" --log-level "$NOIP_LOG_LEVEL"
return "$!"
fi
}
watchdog()
{
pid="$1"
while "$(test -e /proc/"$pid")"; do
sleep 15
done
exit 1
}
main()
{
user_option=$1
if [ "$user_option" -lt 2 ]; then
app_help lt
fi
for permited in "basic" "setd" "dtime" "otime" "all"; do
if [ "$user_option" != "$permited" ]; then
invalid=true
fi
done
if [ "$invalid" ]; then app_help notpermited; fi
nuc_pid=$(start_duc "$user_option")
if [ "$nuc_pid" ]; then
watchdog "$nuc_pid"
fi
}
main "$1"