blob: 545a778c7b5d1b636660da71e1c9cb13e01e5c01 (
plain)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: my-x200
# X-Start-Before: dhcpcd
# Required-Start: $remote_fs $local_fs
# Required-Stop: $remote_fs $local_fs
# X-Stop-After: xdm
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts and stops my-x200
# Description: Removes whining noise from Thinkpads X200, powers off the wifi on shutdown and optionally backups directories.
### END INIT INFO
# Copyright 2018-2021 Robert Alessi
# Distributed under the terms of the GNU General Public License v2
# Set variables
NAME=my-x200
# Source init functions
. /lib/lsb/init-functions
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
x200_cmdfreq="/usr/bin/intel_reg"
pwmfreq="${PWMFREQ_RATE}"
x200_cmdfreq_args="write 0x00061254 $pwmfreq"
autobackup="${conf_autobackup}"
backup_path="${conf_backup_path}"
control_file="${conf_control_file}"
if [ "$use_rsnapshot" = "true" ]
then
backup_cmd="/usr/bin/rsnapshot"
backup_args="${rsnapshot_args}"
else
backup_cmd="/usr/bin/rsync"
backup_args="-aAX --relative --delete --quiet"
fi
set_pwmfreq() {
if [ "$is_thinkpad_x200" = "yes" ]
then
exec $x200_cmdfreq $x200_cmdfreq_args 2>/dev/null
fi
}
do_backup() {
if [ "$autobackup" = "true" ]
then
if [ -e "$backup_path"/"$control_file" ]
then
if [ "$use_rsnapshot" = "true" ]
then
$backup_cmd $backup_args
else
$backup_cmd $backup_args $conf_backup_dirs "$backup_path"
fi
fi
fi
}
do_privacy() {
if [ "$enable_privacy" = "true" ]
then
if [ -n "${wired_interface}" ]
then
printf '0004' > /var/lib/dhcpcd/duid
cat /proc/sys/kernel/random/boot_id >> /var/lib/dhcpcd/duid
/usr/bin/macchanger -r $wired_interface
fi
fi
}
do_refresh() {
set_pwmfreq
}
do_initbackup() {
do_backup
}
do_start() {
do_privacy
/usr/sbin/rfkill block all
set_pwmfreq
}
do_stop() {
/usr/sbin/rfkill block all
do_backup
}
do_restart() {
/usr/sbin/rfkill block all
set_pwmfreq
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart|force-reload)
do_restart
;;
refresh)
do_refresh
;;
initbackup)
do_initbackup
;;
*)
echo "Usage: $NAME {start|stop|refresh|initbackup}" >&2
exit 3
;;
esac
|