Without being on the computer, it's hard to troubleshoot. But, if you're running the script from the JSS, you don't need sudo, as everything runs as root. It may be breaking because it's expecting you to authenticate.
If you're installing Equitrac as a package, from Casper Imaging or Self Service, you could index the package, then check the Allow package to be uninstalled box. That might be a more complete deletion.
At this point, I am just testing the script in the Terminal on a machine that has items listed in the directories targeted in lines 3-5.
Are you suggesting that I remove sudo and attempt running the script from the JSS?
Either that, or get rid of the sudos in the script, and use sudo to run the script itself.
As quoted from askubuntu:
It is rarely a good idea to have sudo inside scripts. Instead, remove the sudo from the script and run the script itself with sudo:
1sudo myscript.sh
That way, all commands within the script will be run with root privileges and you only need to give the password once when launching the script.
Bonus tidbit: If you need a particular command within the script to be run without sudo privileges, you can run it as a regular user:
1sudo -u username command
So, your script should be:
1#!/bin/sh
2killall EquitracLoginController
3killall EQLoginController
4rm -r /Applications/Utilities/EquitracPrinterUtilityX.app
5rm -r /Library/Printers/Equitrac/
6rm -r /Library/Application Support/Equitrac/
7exit 0
Then just run it with:
1sudo sh ./dieEquitracDie.sh
Thanks. I tried your script version and I still get the "No such file or directory" error.
The error is originating here:
1sudo rm -r /Library/Application Support/Equitrac/
Ref: Word Splitting
The interpreter is reading that line as sudo rm -r /Library/Application
.
Assuming you've followed JayDuff's instructions re: sudo
, you'll want to change the above line to either:
1rm -r /Library/Application Support/Equitrac
or
1rm -r "/Library/Application Support/Equitrac"
Duh. Good spot, @grepoli !
Thanks @grepoli!
Using the same suggestion, I am unable to execute this line:
rm -r /Applications/Utilities/EquitracPrinterUtilityX.app
How should I handle that line?
@tomhastings
Assuming you're running this script multiple times on the same computer, that file was already deleted the last time you ran the script during testing. Without the force (-f
) option, the rm
command fails when it encounters a nonexistent file/directory. Add that option, and for peace of mind, add the verbose (-v
) option as well.
Thus:
1#!/usr/bin/env bash
2
3# Kill processes if running
4killall EquitracLoginController EQLoginController
5
6# Remove the app and installed components
7rm -rfv "/Applications/Utilities/EquitracPrinterUtilityX.app"
8rm -rfv "/Library/Printers/Equitrac"
9rm -rfv "/Library/Application Support/Equitrac"
sudo chmod +x /path/to/script
to make it executable, then run with sudo /path/to/script
Thanks for all the help! Everything is working.