Skip to content

Instantly share code, notes, and snippets.

@dcrdev
Last active January 29, 2018 21:48
Show Gist options
  • Save dcrdev/8fbc9280045dad89b333d74a307fb131 to your computer and use it in GitHub Desktop.
Save dcrdev/8fbc9280045dad89b333d74a307fb131 to your computer and use it in GitHub Desktop.
#!/bin/bash
initScriptLocation="/etc/init/emby-server.conf"
function main() {
service emby-server stop
read -p 'Username: ' euser
if [ -d "/var/lib/emby" ]; then
chown -R "$euser":"$euser" "/var/lib/emby";
else
chown -R "$euser":"$euser" "/var/lib/emby-server";
fi
sed -i "s/setuid emby/setuid $euser/g" "$initScriptLocation"
initctl reload-configuration
service emby-server start
}
function elevate {
echo "Attempting to Elevate..." 1>&2
sudo "$0" "$@"
exit $?
}
# Test for root.
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root!"
elevate
fi
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment