Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate

Advertising

Unnamed
Sunday, December 30th, 2012 at 8:23:01pm UTC 

  1. #!/bin/bash
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides:          4store
  5. # Required-Start:    $remote_fs
  6. # Required-Stop:     $remote_fs
  7. # Should-Start:      $network $syslog avahi
  8. # Should-Stop:       $network $syslog avahi
  9. # Default-Start:     2 3 4 5
  10. # Default-Stop:      0 1 6
  11. # Short-Description: Start and stop the 4store database server daemon
  12. # Description:       Controls the 4store database server daemon "4s-httpd"
  13. ### END INIT INFO
  14. #
  15. set -e
  16. set -u
  17. ${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
  18.  
  19. DAEMON1=/usr/bin/4s-backend
  20. DAEMON2=/usr/bin/4s-httpd
  21.  
  22. test -x $DAEMON1 || exit 5
  23. test -x $DAEMON2 || exit 5
  24.  
  25. # Knowledge base
  26. KB="$2"
  27. # Default user
  28. USER=fourstore
  29.  
  30. if [ -r /etc/default/4store ]; then
  31.         . /etc/default/4store
  32. fi
  33.  
  34. . /lib/lsb/init-functions
  35.  
  36. # Safeguard (relative paths, core dumps..)
  37. cd /
  38. umask 077
  39.  
  40. case "$1" in
  41.         start)
  42.                 mkdir -p -m 0755 /var/lib/4store /var/log/4store
  43.                 # Refresh ownership, avoiding "chown -R" hardlink attacks
  44.                 find /var/lib/4store /var/log/4store \( -type d -links 2 \) -or \( -type f -links 1 \) -execdir chown "$USER": {} +
  45.  
  46.                 log_daemon_msg "Starting 4s-backend" "4s-backend" "$KB"
  47.                 start-stop-daemon --start --chuid $USER --quiet --oknodo --name 4s-backend --startas $DAEMON1 -- $KB
  48.                 status=$?
  49.                 log_end_msg $status
  50.                 log_daemon_msg "Starting 4s-httpd" "4s-httpd" "$KB"
  51.                 start-stop-daemon --start --chuid $USER --quiet --oknodo --name 4s-httpd --startas $DAEMON2 -- $KB
  52.                 status=$?
  53.                 log_end_msg $status
  54.                 ;;
  55.         stop)
  56.                 log_daemon_msg "Stopping 4s-httpd" "4s-httpd"
  57.                 start-stop-daemon --stop --quiet --oknodo --name 4s-backend -- $KB
  58.                 log_end_msg $?
  59.                 log_daemon_msg "Stopping 4s-backend" "4s-backend"
  60.                 start-stop-daemon --stop --quiet --oknodo --name 4s-httpd -- $KB
  61.                 log_end_msg $?
  62.                 ;;
  63.         restart|force-reload)
  64.                 $0 stop && sleep 2 && $0 start
  65.                 ;;
  66.         try-restart)
  67.                 if $0 status >/dev/null; then
  68.                         $0 restart
  69.                 else
  70.                         exit 0
  71.                 fi
  72.                 ;;
  73.         reload)
  74.                 exit 3
  75.                 ;;
  76.         status)
  77.                 status_of_proc $DAEMON1 "4s-backend server" "$KB"
  78.                 ;;
  79.         *)
  80.                 echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
  81.                 exit 2
  82.                 ;;
  83. esac
  84.  
  85. exit 0

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus