Skip to content

Instantly share code, notes, and snippets.

@beer-psi
Last active April 16, 2022 07:55
Show Gist options
  • Save beer-psi/72c9c362c8e4538d93d93fa519ec7f4a to your computer and use it in GitHub Desktop.
Save beer-psi/72c9c362c8e4538d93d93fa519ec7f4a to your computer and use it in GitHub Desktop.
launchctl reboot userspac
#!/bin/sh
LAUNCHCTL_PATH="/bin/launchctl"
if ! command -v $LAUNCHCTL_PATH &> /dev/null
then
LAUNCHCTL_PATH="/usr/bin/launchctl"
fi
if [ -t 0 ] && [ "$1" = "reboot" ]; then
if [ "$2" = "userspace" ]; then
$LAUNCHCTL_PATH reboot userspace
else
echo '/!\ You did not type userspace correctly, or did not type it at all /!\'
echo 'This will cause a full reboot, requiring you to rejailbreak!'
echo "If you want to do a userspace reboot, press Ctrl + C then run \"launchctl reboot userspace\""
echo "If you want to do a full reboot, type \"Yes, do as I say!\" (without quotes)"
read -r input
if [ "$input" = "Yes, do as I say!" ]; then
$LAUNCHCTL_PATH reboot
else
echo "Did not type properly; not rebooting"
fi
fi
else
$LAUNCHCTL_PATH "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment