Fix formatting and remove unnecessary recursive rm's

This commit is contained in:
EnderIce2 2024-05-29 22:55:02 +03:00
parent 3021f8e4ad
commit bf98b8784c
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# This script is used to create a LaunchAgent on MacOS, to support the service functionnality. # This script is used to create a LaunchAgent on MacOS, to support the service functionality.
# Usage: ./launchd.sh (install|remove) # Usage: ./launchd.sh (install|remove)
SYMLINK=/tmp/rpc-bridge/tmpdir SYMLINK=/tmp/rpc-bridge/tmpdir
@ -16,7 +16,7 @@ function install() {
if [ ! -d "$LOCATION" ]; then if [ ! -d "$LOCATION" ]; then
mkdir -p "$LOCATION" mkdir -p "$LOCATION"
fi fi
# Link script # Link script
if [ -f "$SCRIPT" ]; then if [ -f "$SCRIPT" ]; then
rm -f "$SCRIPT" rm -f "$SCRIPT"
@ -27,9 +27,9 @@ if [ ! -d "\$TARGET_DIR" ]; then
mkdir -p "\$TARGET_DIR" mkdir -p "\$TARGET_DIR"
fi fi
rm -rf "\$TARGET_DIR" rm -rf "\$TARGET_DIR"
ln -s "\$TMPDIR" "\$TARGET_DIR"" > "$SCRIPT" ln -s "\$TMPDIR" "\$TARGET_DIR"" > "$SCRIPT"
chmod +x "$SCRIPT" chmod +x "$SCRIPT"
# LaunchAgent # LaunchAgent
if [ -f "$AGENT" ]; then if [ -f "$AGENT" ]; then
rm -f "$AGENT" rm -f "$AGENT"
@ -50,13 +50,12 @@ rm -rf "\$TARGET_DIR"
</plist>" > "$AGENT" </plist>" > "$AGENT"
launchctl load "$AGENT" launchctl load "$AGENT"
echo "LaunchAgent has been installed." echo "LaunchAgent has been installed."
} }
function remove() { function remove() {
rm -rf "$SYMLINK" rm -f "$SYMLINK"
rm -rf "$LOCATION"
rm -f "$SCRIPT" rm -f "$SCRIPT"
rmdir "$LOCATION"
if [ -f "$AGENT" ]; then if [ -f "$AGENT" ]; then
launchctl unload "$AGENT" launchctl unload "$AGENT"
fi fi
@ -81,4 +80,4 @@ case $1 in
echo "Invalid argument. Please use 'install' or 'remove'." echo "Invalid argument. Please use 'install' or 'remove'."
exit 1 exit 1
;; ;;
esac esac