diff options
Diffstat (limited to 'x200-my.initd')
-rw-r--r-- | x200-my.initd | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/x200-my.initd b/x200-my.initd index 8edefd6..b026b5b 100644 --- a/x200-my.initd +++ b/x200-my.initd | |||
@@ -1,14 +1,44 @@ | |||
1 | #!/sbin/openrc-run | 1 | #!/sbin/openrc-run |
2 | # Copyright 2018 Robert Alessi | 2 | # Copyright 2018-2019 Robert Alessi |
3 | # Distributed under the terms of the GNU General Public License v2 | 3 | # Distributed under the terms of the GNU General Public License v2 |
4 | 4 | ||
5 | description="Removes whining noise from Thinkpads X200 and powers off the wifi on shutdown." | 5 | description="Removes whining noise from Thinkpads X200, powers off the wifi on shutdown and optionally backups directories." |
6 | 6 | ||
7 | command="/usr/bin/intel_reg" | 7 | command="/usr/bin/intel_reg" |
8 | pwmfreq="${PWMFREQ_RATE}" | 8 | pwmfreq="${PWMFREQ_RATE}" |
9 | 9 | ||
10 | command_args="write 0x00061254 $pwmfreq" | 10 | command_args="write 0x00061254 $pwmfreq" |
11 | 11 | ||
12 | extra_started_commands="initbackup" | ||
13 | |||
14 | autobackup="${conf_autobackup}" | ||
15 | backup_path="${conf_backup_path}" | ||
16 | control_file="${conf_control_file}" | ||
17 | backup_cmd="/usr/bin/rsync" | ||
18 | backup_args="-aAX --relative --delete --quiet" | ||
19 | |||
20 | do_listofpackages() { | ||
21 | /usr/bin/pacman -Qqetn > "$backup_path"/pkglist.txt | ||
22 | /usr/bin/pacman -Qqem > "$backup_path"/foreignpkglist.txt | ||
23 | } | ||
24 | |||
25 | initbackup() { | ||
26 | if [ $autobackup = "true" ] | ||
27 | then | ||
28 | if [ -e "$backup_path"/"$control_file" ] | ||
29 | then | ||
30 | do_listofpackages | ||
31 | for dir in "${conf_backup_dirs[@]}" | ||
32 | do | ||
33 | if [ -d "$dir" ] | ||
34 | then | ||
35 | $backup_cmd $backup_args "$dir" "$backup_path" | ||
36 | fi | ||
37 | done | ||
38 | fi | ||
39 | fi | ||
40 | } | ||
41 | |||
12 | start() { | 42 | start() { |
13 | if [ "${RC_CMD}" = "restart" ]; | 43 | if [ "${RC_CMD}" = "restart" ]; |
14 | then | 44 | then |
@@ -20,4 +50,18 @@ start() { | |||
20 | 50 | ||
21 | stop() { | 51 | stop() { |
22 | /usr/bin/nmcli radio all off | 52 | /usr/bin/nmcli radio all off |
53 | if [ $autobackup = "true" ] | ||
54 | then | ||
55 | if [ -e "$backup_path"/"$control_file" ] | ||
56 | then | ||
57 | do_listofpackages | ||
58 | for dir in "${conf_backup_dirs[@]}" | ||
59 | do | ||
60 | if [ -d "$dir" ] | ||
61 | then | ||
62 | $backup_cmd $backup_args "$dir" "$backup_path" | ||
63 | fi | ||
64 | done | ||
65 | fi | ||
66 | fi | ||
23 | } | 67 | } |