[PATCH] implement platform-deterministic statements
Export this patch
works as expected on arch linux arm. i didn't know what to put for the
commit message so i just wrote the fanciest sounding thing i could think
of :P
---
scripts/f_phone | 39 ++++++++++++++++++++++++++++++---------
1 file changed, 30 insertions(+), 9 deletions(-)
diff --git a/scripts/f_phone b/scripts/f_phone
index 47ae9d9..4c83bb2 100755
--- a/scripts/f_phone
+++ b/scripts/f_phone
@@ -73,7 +73,12 @@ installpolkitudevrules() {
});
' | sudo tee "$TARGETPOLKITFILE"
sudo chmod a+rx "$TARGETPOLKITFILE"
- sudo addgroup "$USER" plugdev
+ if ps --no-headers -o comm 1 | grep openrc; then
+ sudo addgroup "$USER" plugdev
+ elif ps --no-headers -o comm 1 | grep systemd; then
+ sudo groupadd plugdev
+ sudo gpasswd -a "$USER" plugdev
+ fi
clear
echo "polkit rule installed! you may need to reboot"
promptok
@@ -95,10 +100,17 @@ installpolkitudevrules() {
}
ensuremmrunning() {
- rc-service modemmanager status | grep started || {
- sudo /etc/init.d/modemmanager start
- sudo rc-update add modemmanager boot
- }
+ if ps --no-headers -o comm 1 | grep openrc; then
+ rc-service modemmanager status | grep started || {
+ sudo /etc/init.d/modemmanager start
+ sudo rc-update add modemmanager boot
+ }
+ elif ps --no-headers -o comm 1 | grep systemd; then
+ systemctl status ModemManager | grep running || {
+ sudo systemctl start ModemManager
+ sudo systemctl enable ModemManager
+ }
+ fi
}
maketext() {
@@ -195,9 +207,14 @@ makecall() {
}
modemrst() {
- mmcli -L | grep /org/freedesktop/ModemManager1 ||
- sudo /etc/init.d/modemmanager restart
-
+ if ps --no-headers -o comm 1 | grep openrc; then
+ mmcli -L | grep /org/freedesktop/ModemManager1 ||
+ sudo /etc/init.d/modemmanager restart
+ elif ps --no-headers -o comm 1 | grep systemd; then
+ mmcli -L | grep /org/freedesktop/ModemManager1 ||
+ sudo systemctl restart ModemManager
+ fi
+
while ! mmcli -L | grep /org/freedesktop/ModemManager1; do
echo "Waiting for modem to come online"
sleep 1
@@ -424,7 +441,11 @@ main() {
ensuremmrunning
modemrst
env | grep -q "^$(basename "$0" | tr '[a-z]' '[A-Z]')=" || eval "$VAR"
- eval "$(grep deviceinfo_codename /etc/deviceinfo | cut -d= -f2 | tr -d \"- | xargs -ID echo deviceD)" ||
+eval "$(
+ grep -E 'deviceinfo_codename|PRETTY_HOSTNAME' /etc/deviceinfo /etc/machine-info |
+ cut -d= -f2 | tr '[:upper:]' '[:lower:]' | tr -d ' \"-' |
+ xargs -ID echo deviceD
+)"||
errdie "Device unsupported - only pinephone supported currently"
monitorboot $$ >&2 2>/dev/null &
--
2.37.3