Skip to content

Instantly share code, notes, and snippets.

@ryanmaclean
Forked from billerby/alfresco
Last active August 29, 2015 14:08
Show Gist options
  • Save ryanmaclean/2a99b8db349c38179866 to your computer and use it in GitHub Desktop.
Save ryanmaclean/2a99b8db349c38179866 to your computer and use it in GitHub Desktop.
Run Alfresco Start Up Script as a User Other Than Root
#!/bin/sh
#
# chkconfig: 2345 80 30
# description: Alfresco Enterprise
#
# Username YOURUSER used in this case. Replace with one defined locally
# e.g.: with Chef or Puppet.
$YOURUSER = YOURUSER
RETVAL=0
start () {
su -m $YOURUSER -c "cd /opt/alfresco && /opt/alfresco/alfresco.sh start" "$2"
RETVAL=$?
if [ -d "/var/lock/subsys" ] && [ `id -u` = 0 ] && [ $RETVAL -eq 0 ] ; then
touch /var/lock/subsys/alfresco
fi
}
stop () {
su -m $YOURUSER /opt/alfresco/alfresco.sh stop "$2"
RETVAL=$?
}
case "$1" in
start)
start "$@"
;;
stop)
stop "$@"
;;
restart)
stop "$@"
start "$@"
;;
*)
su -m $YOURUSER /opt/alfresco/alfresco.sh "$@"
RETVAL=$?
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment