forked from mainsail-crew/sonar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsonar
executable file
·70 lines (62 loc) · 1.62 KB
/
sonar
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
#!/bin/env bash
#### Sonar - A WiFi Keepalive daemon
####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2022
#### https://github.com/mainsail-crew/sonar
####
#### This File is distributed under GPLv3
####
# shellcheck enable=require-variable-braces
# Make sure script runs with root priviledges
if [ "$(id -u)" != "0" ]; then
echo -e "\nSonar - A WiFi Keepalive daemon\n"
echo -e "This Script is not intended to run as ${USER}!\n"
echo -e "ERROR: Reporting to log and exiting."
exit 1
fi
# Base Paths
BASE_SNR_PATH="$(dirname "$(readlink -f "${0}")")"
BASE_USER_HOME="$(dirname "${BASE_SNR_PATH}")"
export BASE_USER_HOME
SNR_LOG_PATH="/var/log/sonar.log"
export SNR_LOG_PATH
# General configuration is done by function setup_defaults
# See libs/core.sh L#100
## Import Librarys
# shellcheck source-path=SCRIPTDIR/libs/
source "${BASE_SNR_PATH}/libs/configparser.sh"
source "${BASE_SNR_PATH}/libs/core.sh"
source "${BASE_SNR_PATH}/libs/logging.sh"
source "${BASE_SNR_PATH}/libs/messages.sh"
#### MAIN
## Args given?
if [ "$#" -ne 0 ]; then
## Parse Args
while getopts ":vhc:" arg; do
case "${arg}" in
v )
echo -e "\nSonar Version: $(self_version)\n"
exit 0
;;
h )
help_msg
exit 0
;;
c )
export SONAR_CFG="${OPTARG}"
;;
\?)
wrong_args_msg
exit 1
;;
esac
done
fi
init_log_entry
initial_check
while true; do
keepalive
sleep "${SONAR_CHECK_INTERVAL}"
done
exit 0