From 1c7e1f3efef80b9dc3e77b1231dde78eccae954f Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Thu, 19 Dec 2019 16:17:58 +0100 Subject: removed dependency to NetworkManager. added 'privacy settings' --- PKGBUILD | 8 ++++---- x200-my.confd | 39 ++++++++++++++++++++++++++++++++++++++- x200-my.initd | 39 ++++++++++++++++++++++++++++++--------- 3 files changed, 72 insertions(+), 14 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index bc17e95..c063046 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,13 +1,13 @@ # Maintainer: Robert Alessi pkgname=x200-my -pkgver=0.4 +pkgver=0.5 pkgrel=1 pkgdesc="Service to remove whining noise from Thinkpads X200, power off the wifi on shutdown and optionally backup directories." arch=(any) license=(GPL2) url="http://git.robertalessi.net/x200-my" -depends=('sysvinit' 'networkmanager' 'acpid' 'intel-gpu-tools' 'rsync') +depends=('sysvinit' 'acpid' 'intel-gpu-tools' 'rsync' 'macchanger' 'dhcpcd') optdepends=('rsnapshot: for incremental backups') install=x200-my.install source=('x200-my.initd' @@ -15,8 +15,8 @@ source=('x200-my.initd' 'x200-my-lid.sh' 'x200-my-sleep.sh' 'x200-my.sh') -sha512sums=('40d74cc2bce559cc2a08ebcd707279e148d802a5cdeb675cfb5c3abfed453378028a9f78b1be31269d908ad6aacaaaf53b48b13f97d019cdb73156ff92f507b5' - 'bf6513589b39daad03e4365e61f2026a4cb1801af9d061f38f502c4caa5732d03e529d43f2ec87a4ded952b6a299fdec1c18f302162b0dd28c540299be8987cf' +sha512sums=('22401ceed6c1bf0be9c2afb6ffc1cb3e72c6e0a961f806dab5f7516596e8225fe729e96ee695855f8a8bdd98840939d1413a6eafb80de7075326a10e25a5cbdd' + 'e0bc650377f593484185438d1ea8e7b6a298fb2ab4d1cf9a99191d878d250c82a998d1ead8f1a0bd6518105e068c0b0926409b9497d8283444c6b734debe3599' '0dc141f1a26f2cd570d49a05bcc9496ba4c49fde39afad46f5a0783e83c07ec810ca81454a28c3241bcffc62ac31274e2a8d726bbd3c1e91d8cf5315b783c3f8' '610564aa853c5dbc4e370ec2a4d3b5590e53ed235a1960927c0986a31f6c77d135086b1f5752b56fd511ea4a0294082fc7e98ee2fa7b69b37776a59f45c2ec34' 'cb765075f02b5cd16bcfc31571cf7c31ddcd74ff3aa832df1acd96bd8feb62855c0cf90c31c3e0028180765a51eafc5c74fb1f0406dd9172bdc0f5ec02b39f8c') diff --git a/x200-my.confd b/x200-my.confd index 35d26bd..4de394d 100644 --- a/x200-my.confd +++ b/x200-my.confd @@ -1,9 +1,46 @@ # /etc/conf.d/x200-my: config file for /etc/init.d/x200-my -# Options to pass to the x200-my daemon. +######################################### +# Options to pass to the x200-my daemon # +######################################### + +# Is this machine a Thinkpad X200? If so, x200-my can eliminate the +# whining noise that is noticeable when the brightness of the screen +# is lowered. + +is_thinkpad_x200="yes" # (yes|no) PWMFREQ_RATE="0x8bb7b16dc5b6a" +#################### +# Privacy settings # +#################### + +# To enable privacy settings, set enable_privacy to 'true' and supply +# the right name of the wired internet interface that may or may not +# be connected to the internet so that its MAC address can be spoofed +# at startup. Additionally, x200-my will delete /etc/dhcpcd.duid, +# which will make dhcpcd generate a new DUID-LLT based file with an +# updated timestamp and the link-layer address of the network +# interface that is connected to the DHCP device at the time that the +# DUID is generated. + +# IMPORTANT NOTICE: As dhcpcd uses ANY ONE network interface that is +# connected to the DHCP device to generate the DIUD-LLT file, the +# wireless interface MUST have its MAC address spoofed as well. To +# make wpa_supplicant handle this, add the following two lines in +# /etc/wpa_supplicant/wpa_supplicant.conf: +# mac_addr=1 +# preassoc_mac_addr=1 + +# Finally, it is advisable to set the hostname to "localhost" and have +# "hostname_short" in /etc/dhcpcd.conf so that the actual hostname of +# the machine should not be sent to the DHCP server. + +enable_privacy="false" # either 'true' or 'false' +wired_interface="" # supply the actual interface name! In case of + # doubt, see the output of 'ls /sys/class/net/' + ################## # Backup options # ################## diff --git a/x200-my.initd b/x200-my.initd index de88ff0..e4303e6 100644 --- a/x200-my.initd +++ b/x200-my.initd @@ -1,13 +1,13 @@ -#!/sbin/openrc-run +#!/usr/bin/openrc-run # Copyright 2018-2019 Robert Alessi # Distributed under the terms of the GNU General Public License v2 description="Removes whining noise from Thinkpads X200, powers off the wifi on shutdown and optionally backups directories." -command="/usr/bin/intel_reg" +x200_cmdfreq="/usr/bin/intel_reg" pwmfreq="${PWMFREQ_RATE}" -command_args="write 0x00061254 $pwmfreq" +x200_cmdfreq_args="write 0x00061254 $pwmfreq" extra_started_commands="initbackup" @@ -23,12 +23,17 @@ else backup_args="-aAX --relative --delete --quiet" fi +depend() { + need localmount + before net +} + do_listofpackages() { /usr/bin/pacman -Qqetn > "$backup_path"/pkglist.txt /usr/bin/pacman -Qqem > "$backup_path"/foreignpkglist.txt } -do_backup () { +do_backup() { if [ $autobackup = "true" ] then if [ -e "$backup_path"/"$control_file" ] @@ -50,20 +55,36 @@ do_backup () { fi } +do_privacy() { + if [ $enable_privacy = "true" ] + then + if [ -n ${wired_interface:+1} ] + then + rm -rf /etc/dhcpcd.duid + /sbin/macchanger -r $wired_interface + fi + fi +} + initbackup() { do_backup } start() { - if [ "${RC_CMD}" = "restart" ]; + if [ "${RC_CMD}" = "restart" ] then - /usr/bin/nmcli radio all off + /usr/sbin/rfkill block all + else + do_privacy + fi + /usr/sbin/rfkill block all + if [ $is_thinkpad_x200 = "yes" ] + then + exec $x200_cmdfreq $x200_cmdfreq_args 2>/dev/null fi - - exec $command $command_args 2>/dev/null } stop() { - /usr/bin/nmcli radio all off + /usr/sbin/rfkill block all do_backup } -- cgit v1.2.3