File: lxqt-admin-time-helper.freebsd

package info (click to toggle)
lxqt-admin 0.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,104 kB
  • sloc: cpp: 1,654; sh: 92; makefile: 11
file content (71 lines) | stat: -rwxr-xr-x 1,275 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
usage() {
echo "usage: ${0} -l islocaltime -n usentp -t timezone -d newdate [timewhenset]"
exit 0;
}
usentp=""
islocaltime=""
timezone=""
newdate=""
[ $# -eq 0 ] && usage
while getopts "n:l:t:d:" arg; do
  case $arg in
    n)
	usentp=${OPTARG}
	;;
    l)
	islocaltime=${OPTARG}
      ;;
    t)
	timezone=${OPTARG}
      ;;
    d)
	newdate=${OPTARG}
      ;;
    h | *) # Display help.
      usage
      exit 0;
      ;;
  esac
done
shift $(( OPTIND - 1 ))

if [ "${newdate}" != "" ]; then
	if [ "$1" != "" ]; then
		timewhenset=$1;
		timenow=`date +%s`;
		timediff=$((${timenow} - ${timewhenset}));
		settime=$((${newdate} + ${timediff}))
		echo $timediff
	else
                settime=${newdate};
	fi;
	echo $settime
	date -f %s ${settime}
fi;
if [ "${usentp}" != "" ];  then
	if [ "$usentp" = "true" ]; then
	sysrc ntpd_enable=YES
	service ntpd stop
	ntpd -g -q
	service ntpd start
	fi;
	if [ "$usentp" = "false" ]; then
		sysrc ntpd_enable=false
		service ntpd onestop
        fi;
fi;
if [ "${islocaltime}" != "" ]; then
	if  [ $islocaltime = "false" ]; then
	rm -f /etc/wall_cmos_clock;
	fi;
	if [ $islocaltime = "true" ]; then
	touch /etc/wall_cmos_clock
	fi
fi;
if [  "${timezone}" != ""  ]; then
	/usr/sbin/tzsetup $timezone
	/sbin/adjkerntz -a
fi;

exit $?