AppRun 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. # roxapp to install and run Monkey Web Server
  3. # monkey.conf is configured to run as user nobody
  4. # web files are in /root/monkey/public_html
  5. # config file is /root/monkey/conf/monkey.conf
  6. # GuestToo - Nov 17, 2006
  7. APPDIR=`dirname "$0"`
  8. cd "$APPDIR"
  9. APPDIR="`pwd`"
  10. MSG=`which gxmessage` || MSG=xmessage
  11. # newer versions of Puppy have cp-FULL
  12. [ -d /root/monkey ] || mkdir /root/monkey
  13. [ -d /root/monkey/bin ] || cp -a $APPDIR/bin/ /root/monkey/
  14. [ -d /root/monkey/conf ] || cp -a $APPDIR/conf/ /root/monkey/
  15. [ -d /root/monkey/logs ] || mkdir /root/monkey/logs
  16. [ -d /root/monkey/public_html ] || cp -a $APPDIR/public_html/ /root/monkey/
  17. ln -sfn "$APPDIR/bin/banana" /root/my-applications/bin/banana
  18. chown -R nobody:nobody /root/monkey/
  19. if pidof monkey > /dev/null
  20. then
  21. $MSG -bg "#d0ffd0" -buttons "Stop,Kill,Show,Cancel" -default Cancel -center -title "Monkey" "Monkey Web Server is running"
  22. case $? in
  23. 101)
  24. killall -q -2 monkey
  25. sleep 1
  26. exec "$APPDIR/AppRun"
  27. exit ;;
  28. 102)
  29. killall -q -9 monkey
  30. sleep 1
  31. exec "$APPDIR/AppRun"
  32. exit ;;
  33. 103)
  34. $MSG -timeout 2 -default okay -center -title "Monkey" "starting browser" &
  35. PORT=`grep ^Port /root/monkey/conf/monkey.conf | awk '{print $2}'`
  36. exec defaultbrowser "http://127.0.0.1:$PORT/"
  37. exit ;;
  38. *) exit ;;
  39. esac
  40. else
  41. $MSG -bg "#ffc0c0" -buttons "Start,Kill,Cancel" -default Cancel -center -title "Monkey" "Monkey Web Server is NOT running"
  42. case $? in
  43. 101)
  44. killall -q -9 monkey
  45. sleep 1
  46. /root/monkey/bin/monkey -Dc /root/monkey/conf &
  47. sleep 1
  48. exec "$APPDIR/AppRun"
  49. exit ;;
  50. 102)
  51. killall -q -9 monkey
  52. sleep 1
  53. exec "$APPDIR/AppRun"
  54. exit ;;
  55. *) exit ;;
  56. esac
  57. fi