2023-10-14 22:38:03 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-10-14 22:38:04 +02:00
|
|
|
. ./sync.conf || . ../sync.conf
|
|
|
|
|
2023-10-14 22:38:03 +02:00
|
|
|
DRY_RUN=${DRY_RUN:-no}
|
|
|
|
|
|
|
|
bool() {
|
|
|
|
case "$1" in
|
|
|
|
1|true|yes|on|TRUE|YES|ON) return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
run() {
|
2023-10-14 22:38:06 +02:00
|
|
|
# Check if command starts with NO_RUN ($*) and remove it
|
|
|
|
if echo "$*" | grep -q "^NO_RUN"; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2023-10-14 22:38:03 +02:00
|
|
|
if bool "$DRY_RUN"; then
|
|
|
|
echo "DRY: + $*"
|
|
|
|
else
|
|
|
|
echo "+ $*"
|
|
|
|
"$@"
|
|
|
|
fi
|
|
|
|
}
|
2023-10-14 22:38:04 +02:00
|
|
|
|
|
|
|
is_graphical() {
|
2023-10-14 22:38:06 +02:00
|
|
|
command -v $PREF_TERM > /dev/null && return 0 || return 1
|
2023-10-14 22:38:04 +02:00
|
|
|
}
|
|
|
|
|
2023-10-14 22:38:06 +02:00
|
|
|
command -v $SYS_SUDO > /dev/null || SYS_SUDO="NO_RUN"
|