aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PKGBUILD8
-rw-r--r--x200-my.confd17
-rw-r--r--x200-my.initd48
3 files changed, 67 insertions, 6 deletions
diff --git a/PKGBUILD b/PKGBUILD
index f01fe9c..ff3b102 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,9 +1,9 @@
1# Maintainer: Robert Alessi <alessi@robertalessi.net> 1# Maintainer: Robert Alessi <alessi@robertalessi.net>
2 2
3pkgname=x200-my 3pkgname=x200-my
4pkgver=0.2 4pkgver=0.3
5pkgrel=1 5pkgrel=1
6pkgdesc="Service which removes whining noise from Thinkpads X200. Also powers off the wifi on shutdown." 6pkgdesc="Service to remove whining noise from Thinkpads X200, power off the wifi on shutdown and optionally backup directories."
7arch=(any) 7arch=(any)
8license=(GPL2) 8license=(GPL2)
9url="http://git.robertalessi.net/x200-my" 9url="http://git.robertalessi.net/x200-my"
@@ -14,8 +14,8 @@ source=('x200-my.initd'
14 'x200-my-lid.sh' 14 'x200-my-lid.sh'
15 'x200-my-sleep.sh' 15 'x200-my-sleep.sh'
16 'x200-my.sh') 16 'x200-my.sh')
17sha512sums=('b8cab7790ecb542fa8aa930f26ac3f293bce772585643a0de189285415a0d7c12f5e9fb98602dd15ff9bb52afdc93acbcd658b153f1b9c1cb640646e55c3b73c' 17sha512sums=('96579d18e8639da441b2f0104e453f2ffd34a1c14c77ad08709fc090b168d0030f5074d8c54f116739a4f421286c5d2b64181c66fabd2eee91c371d8aa856395'
18 '172d5def88c12118c9d736404bb7a028ee39578dd6f2dd632224e7c03ee30a34a19412725fb09c17f31aedc14846e0f2f0682f1d9077c4ff202bd7b7cf48c467' 18 '9129a88db1c0a8385a053060ae3f737e75be1c50d7ae17a8804121ae20365b9938ed47c06b55250e72df2c20036c5043e70c84fb63e57d4548afb20ee9b29c94'
19 '0dc141f1a26f2cd570d49a05bcc9496ba4c49fde39afad46f5a0783e83c07ec810ca81454a28c3241bcffc62ac31274e2a8d726bbd3c1e91d8cf5315b783c3f8' 19 '0dc141f1a26f2cd570d49a05bcc9496ba4c49fde39afad46f5a0783e83c07ec810ca81454a28c3241bcffc62ac31274e2a8d726bbd3c1e91d8cf5315b783c3f8'
20 '610564aa853c5dbc4e370ec2a4d3b5590e53ed235a1960927c0986a31f6c77d135086b1f5752b56fd511ea4a0294082fc7e98ee2fa7b69b37776a59f45c2ec34' 20 '610564aa853c5dbc4e370ec2a4d3b5590e53ed235a1960927c0986a31f6c77d135086b1f5752b56fd511ea4a0294082fc7e98ee2fa7b69b37776a59f45c2ec34'
21 'cb765075f02b5cd16bcfc31571cf7c31ddcd74ff3aa832df1acd96bd8feb62855c0cf90c31c3e0028180765a51eafc5c74fb1f0406dd9172bdc0f5ec02b39f8c') 21 'cb765075f02b5cd16bcfc31571cf7c31ddcd74ff3aa832df1acd96bd8feb62855c0cf90c31c3e0028180765a51eafc5c74fb1f0406dd9172bdc0f5ec02b39f8c')
diff --git a/x200-my.confd b/x200-my.confd
index 44312bc..a65dd69 100644
--- a/x200-my.confd
+++ b/x200-my.confd
@@ -3,3 +3,20 @@
3# Options to pass to the x200-my daemon. 3# Options to pass to the x200-my daemon.
4 4
5PWMFREQ_RATE="0x8bb7b16dc5b6a" 5PWMFREQ_RATE="0x8bb7b16dc5b6a"
6
7#
8# Backup options
9#
10# Activate autobackup on shutdown (true/false)
11conf_autobackup="false"
12# Path to backup directory:
13conf_backup_path="/mnt/disk"
14# Control file. This (empty) file must exist in the backup directory:
15conf_backup_control_file="dobackup"
16# Directories to backup:
17conf_backup_dirs=(
18 "/etc"
19 "/root"
20 "/usr/local"
21 "/home"
22)
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
5description="Removes whining noise from Thinkpads X200 and powers off the wifi on shutdown." 5description="Removes whining noise from Thinkpads X200, powers off the wifi on shutdown and optionally backups directories."
6 6
7command="/usr/bin/intel_reg" 7command="/usr/bin/intel_reg"
8pwmfreq="${PWMFREQ_RATE}" 8pwmfreq="${PWMFREQ_RATE}"
9 9
10command_args="write 0x00061254 $pwmfreq" 10command_args="write 0x00061254 $pwmfreq"
11 11
12extra_started_commands="initbackup"
13
14autobackup="${conf_autobackup}"
15backup_path="${conf_backup_path}"
16control_file="${conf_control_file}"
17backup_cmd="/usr/bin/rsync"
18backup_args="-aAX --relative --delete --quiet"
19
20do_listofpackages() {
21 /usr/bin/pacman -Qqetn > "$backup_path"/pkglist.txt
22 /usr/bin/pacman -Qqem > "$backup_path"/foreignpkglist.txt
23}
24
25initbackup() {
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
12start() { 42start() {
13 if [ "${RC_CMD}" = "restart" ]; 43 if [ "${RC_CMD}" = "restart" ];
14 then 44 then
@@ -20,4 +50,18 @@ start() {
20 50
21stop() { 51stop() {
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}