Advertisement
Guest User

Sakis3G init script

a guest
Dec 19th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.89 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:            Sakis3G
  4. # Required-Start:      $all
  5. # Required-Stop:       $all
  6. # Default-Start:       2 3 4 5
  7. # Default-Stop:        0 1 6
  8. # Short-Description:   Start/stop the Sakis3G service
  9. # Description:         Sakis3G initscript that allows for Sakis3G to run at boot time as well as being stopped and started
  10. ### END INIT INFO
  11. set -e
  12. NAME="Sakis3G"
  13. PIDFILE="/var/run/sakis3g"
  14. DAEMON="/usr/bin/sakis3g"
  15. user=root
  16.  
  17. ARGS="APN=\"CUSTOM_APN\" CUSTOM_APN=\"epc.tmobile.com\" FORCE_APN=\"epc.tmobile.com\" APN_USER=\"tmobile\" APN_PASS=\"password\"  USBINTERFACE=\"0\""
  18.  
  19. start() {
  20.     if [ -e "$PIDFILE.pid" ]; then
  21.         ## Program is running, exit with error.
  22.         echo "Error! $NAME is currently running!" 1>&2
  23.         exit 1
  24.     else
  25.         ## Change from /dev/null to something like /var/log/$PROG if you want to save output.
  26.         /usr/bin/sakis3g connect $ARGS 2>&1 >/dev/null &
  27.         echo "$NAME started"
  28.         touch "$PIDFILE.pid"
  29.     fi
  30. }
  31.  
  32. stop() {
  33.     if [ -e "$PIDFILE.pid" ]; then
  34.         ## Program is running, so stop it
  35.         /usr/bin/sakis3g disconnect 2>&1 >/dev/null &
  36.         rm "$PIDFILE.pid"
  37.         echo "$NAME stopped"
  38.     else
  39.         ## Program is not running, exit with error.
  40.         echo "Error! $NAME not started!" 1>&2
  41.         exit 1
  42.     fi
  43. }
  44.  
  45. ## Check to see if we are running as root first.
  46. ## Found at http://www.cyberciti.biz/tips/shell-root-user-check-script.html
  47. if [ "$(id -u)" != "0" ]; then
  48.     echo "This script must be run as root" 1>&2
  49.     exit 1
  50. fi
  51.  
  52. case "$1" in
  53.  start)
  54.    start
  55.    exit 0
  56.    ;;
  57.  stop)
  58.    stop
  59.    exit 0
  60.    ;;
  61. status)
  62.    echo -n "Getting status for "$NAME
  63.    /usr/bin/sakis3g connect info &>/dev/null
  64.    echo "\n"
  65.    ;;
  66.  restart)
  67.    stop
  68.    start
  69.    sleep 1
  70.    exit 0
  71.    ;;
  72.  *)
  73.    echo "usage: $0 {start|stop|status|restart}"
  74.    exit 1
  75. esac
  76.  
  77. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement