Last active
August 21, 2019 08:57
-
-
Save abd3lraouf/fce9eca949f5137c18faf7ff8841fdb2 to your computer and use it in GitHub Desktop.
shell script to toggle snapd service on ubuntu 18.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if systemctl list-units | grep -q -E 'snapd.service.*running'; then | |
sudo systemctl stop snapd.service > /dev/null 2>&1 | |
sudo systemctl disable snapd.service > /dev/null 2>&1 | |
sudo systemctl mask snapd.service > /dev/null 2>&1 | |
sudo rm -rf /etc/xdg/autostart/snap-userd-autostart.desktop | |
echo | |
tput setaf 1; echo "snapd stopped successfully" | |
echo | |
else | |
sudo systemctl unmask snapd.service > /dev/null 2>&1 | |
sudo systemctl reenable snapd.service > /dev/null 2>&1 | |
sudo systemctl start snapd.service > /dev/null 2>&1 | |
cat > snap-userd-autostart.desktop <<- "EOF" | |
[Desktop Entry] | |
Name=Snap user application autostart helper | |
Comment=Helper program for launching snap applications that are configured to start automatically. | |
Exec=/usr/bin/snap userd --autostart | |
Type=Application | |
EOF | |
sudo mv snap-userd-autostart.desktop /etc/xdg/autostart | |
echo | |
tput setaf 2; echo "snapd started successfully" | |
echo | |
fi | |
tput setaf 5; echo "created by $(tput setab 7)AbdElraouf Sabri$(tput sgr 0)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
or
if not working try the real link
Tested