WIP generalization of waybar-pkg for all OSes/boxes
This commit is contained in:
parent
59f84d2092
commit
77bf357f50
|
@ -1,10 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Get OS "ID" (lowercase name) and "VARIANT_ID"
|
# Identify OS and Variant
|
||||||
ID="`grep '^ID=' /etc/os-release | cut -d= -f2`-`grep 'VARIANT_ID=' /etc/os-release | cut -d= -f2`"
|
OS="$(grep '^ID=' /etc/os-release | cut -d= -f2)"
|
||||||
|
VARIANT="$(grep '^VARIANT_ID=' /etc/os-release | cut -d= -f2)"
|
||||||
|
if [ -n "$VARIANT" ]; then
|
||||||
|
OS="${OS}-${VARIANT}"
|
||||||
|
fi
|
||||||
|
|
||||||
# Trim if no VARIANT exists (eg. 'debian')
|
# Build log file for upgradeable package counts/errors
|
||||||
ID=`echo $ID | sed -e 's/\-$//'`
|
COUNT_FILE="$HOME/.spool/upgradeable"
|
||||||
|
if [ -f "/run/.containerenv" ] || [ -f "/.dockerenv" ]; then
|
||||||
|
COUNT_FILE="$COUNT_FILE.$(echo "$HOSTNAME" | cut -d'.' -f1)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build command
|
||||||
|
CMD=${0//pkg/pkg-$OS}
|
||||||
|
|
||||||
|
# Log error if command does not exist and exit
|
||||||
|
if [ ! -f "$CMD" ]; then
|
||||||
|
echo "ERROR: unsupported OS/variant '$OS' due to missing script: $CMD" > "$COUNT_FILE"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
# Run appropriate script from same path as this one
|
# Run appropriate script from same path as this one
|
||||||
eval `echo $0 $1| sed -e "s/pkg/${ID}/"`
|
$CMD "$@"
|
||||||
|
|
Loading…
Reference in New Issue