Enable NTP
This commit is contained in:
parent
1f01b4e69a
commit
e538bdeb32
68
debian/settings/enable-ntp.sh
vendored
Executable file
68
debian/settings/enable-ntp.sh
vendored
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
#### Variables
|
||||
APT_INST="apt -y install"
|
||||
PKG_DEPS=(systemd-timesyncd)
|
||||
TIME_ZONE="Europe/Zagreb"
|
||||
|
||||
#### Functions
|
||||
check_root() {
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Must be root to run $0"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
choice() {
|
||||
echo -ne "[y/n]"
|
||||
while true
|
||||
do
|
||||
read -rN1 input
|
||||
case $input in
|
||||
[yY][eE][sS]|[yY])
|
||||
return 0
|
||||
|
||||
break
|
||||
;;
|
||||
[nN][oO]|[nN])
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
check_deps_pkg() {
|
||||
for NAME in "${PKG_DEPS[@]}"
|
||||
do
|
||||
dpkg -l $NAME > /dev/null
|
||||
CODE=$?
|
||||
if ! [ "$CODE" -ne 1 ]; then
|
||||
echo -ne "\nInstall $NAME ? "
|
||||
if choice 2>/dev/null; then
|
||||
echo -ne "\n$APT_INST $NAME\n"
|
||||
$APT_INST $NAME
|
||||
else
|
||||
echo -ne "\n\nAbort install script, package $NAME is required for work $PKG_NAME.\n"
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#### Main
|
||||
|
||||
check_root
|
||||
check_deps_pkg
|
||||
|
||||
echo -ne "\nEnable NTP and set Timezone for Croatia ? "
|
||||
if choice 2>/dev/null; then
|
||||
echo -ne "\nSetting NTP ...\n"
|
||||
timedatectl set-timezone "$TIME_ZONE"
|
||||
timedatectl set-local-rtc 0
|
||||
timedatectl set-ntp true
|
||||
systemctl restart systemd-timesyncd
|
||||
|
||||
echo -ne "\nStatus of NTP\n"
|
||||
timedatectl status
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user