scripts/debian/desktop-environment/clean-install-mate.sh

123 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
#### Variables
APT_UPDATE="apt -y update"
APT_INST="apt -y install"
APT_PURGE="apt -y purge"
APT_REMOVE="apt -y autoremove"
PKG_MATE="mate-desktop-environment mozo caja-open-terminal lightdm"
PKG_INDI="package-update-indicator"
PKG_APPS="audacious vlc synaptic gnome-disk-utility gimp hardinfo"
PKG_OFFICE="libreoffice libreoffice-gtk3 aspell-hr hunspell-hr"
PKG_NET="network-manager-gnome thunderbird net-tools remmina"
#### Functions
check_root() {
if [ "$EUID" -ne 0 ]; then
echo "Must be root to run $0"
exit
fi
}
choice() {
echo -ne "[y/n]"
while true
do
read -rN1 input
case $input in
[yY][eE][sS]|[yY])
return 0
break
;;
[nN][oO]|[nN])
return 1
;;
esac
done
}
fix_net() {
# More about bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=758557
nf="/etc/network/interfaces"
ifs=($(ip addr | grep -E ':\s.*?:' | cut -d ":" -f 2 | tr -d " "))
for value in "${ifs[@]}"
do
sed -i 's/^[^#]*'.$value.'*/#&/' $nf
done
systemctl restart networking.service
systemctl restart NetworkManager.service
systemctl restart NetworkManager-wait-online.service
}
fix_console() {
# More about bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=846256#67
VAR_DIR_CONSOLE=/etc/systemd/system/console-setup.service.d
VAR_DIR_KEYBOARD=/etc/systemd/system/keyboard-setup.service.d
if ! [ -d "$VAR_DIR_CONSOLE" ]; then
mkdir -p $VAR_DIR_CONSOLE
echo "[Unit]" > $VAR_DIR_CONSOLE/override.conf
echo "After=systemd-tmpfiles-setup.service" >> $VAR_DIR_CONSOLE/override.conf
echo "Add fix for console-setup.service"
fi
if ! [ -d "$VAR_DIR_KEYBOARD" ]; then
mkdir -p $VAR_DIR_KEYBOARD
echo "[Unit]" > $VAR_DIR_KEYBOARD/override.conf
echo "After=systemd-tmpfiles-setup.service" >> $VAR_DIR_KEYBOARD/override.conf
echo "Add fix for keyboard-setup.service"
fi
systemctl restart console-setup.service
systemctl restart keyboard-setup.service
}
#### Main
check_root
echo -e "\nUpdate apt"
echo "$APT_UPDATE"
$APT_UPDATE
echo -ne "\nInstall of MATE minimal ($PKG_MATE)? "
if choice 2>/dev/null; then
echo -ne "\n$APT_INST $PKG_MATE\n"
$APT_INST $PKG_MATE
fi
echo -ne "\nInstall of update indicator ($PKG_INDI)? "
if choice 2>/dev/null; then
echo -ne "\n$APT_INST --no-install-recommends $PKG_INDI\n"
$APT_INST --no-install-recommends $PKG_INDI
fi
echo -ne "\nYou want to install apps ($PKG_APPS)? "
if choice 2>/dev/null; then
echo -ne "\n$APT_INST $PKG_APPS\n"
$APT_INST $PKG_APPS
fi
echo -ne "\nYou want to install office packages ($PKG_OFFICE)? "
if choice 2>/dev/null; then
echo -ne "\n$APT_INST $PKG_OFFICE\n"
$APT_INST $PKG_OFFICE
fi
echo -ne "\nYou want to install internet programs ($PKG_NET)? "
if choice 2>/dev/null; then
echo -ne "\n$APT_INST $PKG_FIREFOX $PKG_NET\n"
$APT_INST $PKG_FIREFOX $PKG_NET
fi
echo -ne "\nYou want to run fix_net function? "
if choice 2>/dev/null; then
fix_net
fi
echo -ne "\nYou want to run fix_console function? "
if choice 2>/dev/null; then
fix_console
fi
echo -ne "\n\n"