mirror of
https://github.com/BreizhHardware/SpotifyAddBlock.git
synced 2026-01-18 16:27:25 +01:00
61 lines
1.5 KiB
Bash
Executable File
61 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
state="$(head -n 1 .state)"
|
|
|
|
detect_distro() {
|
|
if [ -f /etc/os-release ]; then
|
|
# freedesktop.org and systemd
|
|
. /etc/os-release
|
|
OS=$(echo "$ID" | awk '{print tolower($0)}')
|
|
OS_VER=$VERSION_ID
|
|
elif type lsb_release >/dev/null 2>&1; then
|
|
# linuxbase.org
|
|
OS=$(lsb_release -si | awk '{print tolower($0)}')
|
|
OS_VER=$(lsb_release -sr)
|
|
elif [ -f /etc/lsb-release ]; then
|
|
# For some versions of Debian/Ubuntu without lsb_release command
|
|
. /etc/lsb-release
|
|
OS=$(echo "$DISTRIB_ID" | awk '{print tolower($0)}')
|
|
OS_VER=$DISTRIB_RELEASE
|
|
elif [ -f /etc/debian_version ]; then
|
|
# Older Debian/Ubuntu/etc.
|
|
OS="debian"
|
|
OS_VER=$(cat /etc/debian_version)
|
|
elif [ -f /etc/SuSe-release ]; then
|
|
# Older SuSE/etc.
|
|
OS="SuSE"
|
|
OS_VER="?"
|
|
elif [ -f /etc/redhat-release ]; then
|
|
# Older Red Hat, CentOS, etc.
|
|
OS="Red Hat/CentOS"
|
|
OS_VER="?"
|
|
else
|
|
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
|
|
OS=$(uname -s)
|
|
OS_VER=$(uname -r)
|
|
fi
|
|
|
|
OS=$(echo "$OS" | awk '{print tolower($0)}')
|
|
OS_VER_MAJOR=$(echo "$OS_VER" | cut -d. -f1)
|
|
}
|
|
|
|
detect_distro
|
|
|
|
|
|
if [ "$EUID" -ne 0 ]
|
|
then
|
|
echo "Please run as root"
|
|
exit
|
|
fi
|
|
|
|
if [ "$state" == "$SUDO_USER $HOSTNAME 1" ]
|
|
then
|
|
echo "You are going to unninstall the service SpotifyAddBlock, press any key to continue or ctrl-c to avoid uninstallation"
|
|
read cap
|
|
echo "Service uninstalled!"
|
|
cp .hosts_original_${OS}.txt /etc/hosts
|
|
else
|
|
echo "The service is not installed on this machine"
|
|
fi
|
|
|
|
echo "$SUDO_USER $HOSTNAME 0" > .state
|