Files
argon40-battery-display/archive/kickstarter/argon-uninstall.sh
Jeff Curless 2b178485ae Modify build and archive Argon40 scripts.
Move all of the argon40 scripts to archive... these scripts should not
be used as is, they are simply copies of the originals so I can track
changes to see if there is anything important that needs to be
transfered to the battery driver.
2026-02-02 13:02:10 -05:00

181 lines
4.0 KiB
Bash

#!/bin/bash
echo "----------------------"
echo " Argon Uninstall Tool"
echo "----------------------"
echo -n "Press Y to continue:"
read -n 1 confirm
echo
if [ "$confirm" = "y" ]
then
confirm="Y"
fi
if [ "$confirm" != "Y" ]
then
echo "Cancelled"
exit
fi
destfoldername=$USERNAME
if [ -z "$destfoldername" ]
then
destfoldername=$USER
fi
if [ "$destfoldername" = "root" ]
then
destfoldername=""
fi
if [ -z "$destfoldername" ]
then
destfoldername="pi"
fi
shortcutfile="/home/$destfoldername/Desktop/argonone-config.desktop"
if [ -f "$shortcutfile" ]; then
sudo rm $shortcutfile
if [ -f "/usr/share/pixmaps/ar1config.png" ]; then
sudo rm /usr/share/pixmaps/ar1config.png
fi
if [ -f "/usr/share/pixmaps/argoneon.png" ]; then
sudo rm /usr/share/pixmaps/argoneon.png
fi
fi
shortcutfile="/home/$destfoldername/Desktop/argononeup.desktop"
if [ -f "$shortcutfile" ]; then
sudo rm $shortcutfile
fi
INSTALLATIONFOLDER=/etc/argon
argononefanscript=$INSTALLATIONFOLDER/argononed.py
if [ -f $argononefanscript ]; then
sudo systemctl stop argononed.service
sudo systemctl disable argononed.service
# Turn off the fan
/usr/bin/python3 $argononefanscript FANOFF
# Remove files
sudo rm /lib/systemd/system/argononed.service
fi
argononeupscript=$INSTALLATIONFOLDER/argononeupd.py
if [ -f $argononeupscript ]; then
sudo systemctl stop argononeupd.service
sudo systemctl disable argononeupd.service
# Remove files
sudo rm /lib/systemd/system/argononeupd.service
fi
# Remove RTC if any
argoneonrtcscript=$INSTALLATIONFOLDER/argoneond.py
if [ -f "$argoneonrtcscript" ]
then
# Disable Services
sudo systemctl stop argoneond.service
sudo systemctl disable argoneond.service
# No need for sudo
/usr/bin/python3 $argoneonrtcscript CLEAN
/usr/bin/python3 $argoneonrtcscript SHUTDOWN
# Remove files
sudo rm /lib/systemd/system/argoneond.service
fi
# Remove UPS daemon if any
argononeupsscript=$INSTALLATIONFOLDER/argononeupsd.py
if [ -f "$argononeupsscript" ]
then
#sudo rmmod argonbatteryicon
# Disable Services
sudo systemctl stop argononeupsd.service
sudo systemctl disable argononeupsd.service
sudo systemctl stop argonupsrtcd.service
sudo systemctl disable argonupsrtcd.service
# Remove files
sudo rm /lib/systemd/system/argononeupsd.service
sudo rm /lib/systemd/system/argonupsrtcd.service
find "/home" -maxdepth 1 -type d | while read line; do
shortcutfile="$line/Desktop/argonone-ups.desktop"
if [ -f "$shortcutfile" ]; then
sudo rm $shortcutfile
fi
done
fi
# Remove UPS daemon if any
argononeupsscript=$INSTALLATIONFOLDER/argononeupd.py
if [ -f "$argononeupsscript" ]
then
#sudo rmmod argonbatteryicon
# Disable Services
sudo systemctl stop argononeupd.service
sudo systemctl disable argononeupd.service
for tmpuser in `awk -F: '{ if ($3 >= 1000) print $1 }' /etc/passwd`
do
if [ "$tmpuser" != "nobody" ]
then
sudo -u "$tmpuser" systemctl --user stop argononeupduser.service
sudo -u "$tmpuser" systemctl --user disable argononeupduser.service
fi
done
systemctl --user stop argononeupduser.service
systemctl --user disable argononeupduser.service
# Remove files
sudo rm /lib/systemd/system/argononeupd.service
sudo rm /etc/systemd/user/argononeupduser.service
find "/home" -maxdepth 1 -type d | while read line; do
shortcutfile="$line/Desktop/argononeup.desktop"
if [ -f "$shortcutfile" ]; then
sudo rm $shortcutfile
fi
done
fi
if [ -f "/usr/bin/argon-config" ]
then
sudo rm /usr/bin/argon-config
fi
if [ -f "/usr/bin/argonone-config" ]
then
sudo rm /usr/bin/argonone-config
sudo rm /usr/bin/argonone-uninstall
fi
if [ -f "/usr/bin/argonone-ir" ]
then
sudo rm /usr/bin/argonone-ir
fi
# Delete config files
for configfile in argonunits argononed argononed-hdd argoneonrtc argoneonoled argonupsrtc argononeupd
do
if [ -f "/etc/${configfile}.conf" ]
then
sudo rm "/etc/${configfile}.conf"
fi
done
sudo rm /lib/systemd/system-shutdown/argon-shutdown.sh
sudo rm -R -f $INSTALLATIONFOLDER
echo "Removed Argon Services."
echo "Cleanup will complete after restarting the device."