diff --git a/README.md b/README.md index 9bbbe2b..6a93dea 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,31 @@ -macosx-script-boot-shutdown +MacOsx-script-boot-shutdown =========================== -This configuration is useful when you need to execute a shell script at Mac OS X boot or shutdown. +This configuration is useful when you need to execute a shell script or command at Mac OS X boot or shutdown. + +# Automatic Install and or Uninstall with install.sh + +install.sh Is a user ineractif script to be runned as super user. How to use : +- open terminal +- type : cd ~ +- type : git clone https://github.com/christophecvr/macosx-script-boot-shutdown +- type : sudo macosx-script-boot-shutdown/install.sh + +The script will install the files: + +- boot-shut-down-script.plist in path /Library/LaunchDaemons also adapt the target paths into the plist file. +- boot-shutdown.sh in path /library/Scripts this path can be adapted by user during install. +- log path location /Library/Logs this path can be adapted by user during install. + +After the install is completed the script will be loaded + +This installscript will also check on previous installation. +Give the user the oportunity to stop or choose to remove the service from you're system. +Then the user will be asked to reinstall or not. +After the Install,Uninstall or Reinstall is done you will be asked to remove or not the +git repo from you're pc. + +# Manual Install There are two files: @@ -35,6 +59,15 @@ When RunAtLoad is set to false, after the load you must start and stop the scrip sudo launchctl start BOOT.SHUTDOWN.SERVICE sudo launchctl stop BOOT.SHUTDOWN.SERVICE +# After changing file boot-shutdown.sh + +unload and reload the service in order to have changes directly applied +- open terminal +- type : sudo launchctl unload -w /Library/LaunchDaemons/boot-shutdown-script.plist +- type : sudo launchctl load -w /Library/LaunchDaemons/boot-shutdown-script.plist + +Alternatively just restart(reboot) twice and You're changes should be in effect. + ## Useful links - [Daemons and Services Programming Guide][1] diff --git a/boot-shutdown.sh b/boot-shutdown.sh index 716f898..4e33d5f 100755 --- a/boot-shutdown.sh +++ b/boot-shutdown.sh @@ -25,7 +25,6 @@ function startup() } trap shutdown SIGTERM -trap shutdown SIGKILL startup; diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..5287c35 --- /dev/null +++ b/install.sh @@ -0,0 +1,360 @@ +#!/bin/bash + +# Author christophecvr christophevanr@gmail.com +# 2024/01/14 +if [ -z "$SUDO_USER" ];then + echo "########################################################" + echo "###### This instal script must be launched with sudo " + echo "###### Retry with sudo