~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: apeel
  • Date: 2008-03-14 01:33:50 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:688
setup.py now creates the /etc/init.d script for usrmgr-server, and install_proc.txt has instructions on installing it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
635
635
    jailconffile = os.path.join(cwd, "lib/conf/jailconf.py")
636
636
    conf_hfile = os.path.join(cwd, "trampoline/conf.h")
637
637
    phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php")
 
638
    usrmgtserver_initdfile = os.path.join(cwd, "doc/setup/usrmgt-server.init")
638
639
 
639
640
    # Get command-line arguments to avoid asking questions.
640
641
 
655
656
    %s
656
657
    %s
657
658
    %s
 
659
    %s
658
660
prompting you for details about your configuration. The file will be
659
661
overwritten if it already exists. It will *not* install or deploy IVLE.
660
662
 
661
663
Please hit Ctrl+C now if you do not wish to do this.
662
 
""" % (conffile, jailconffile, conf_hfile, phpBBconffile)
 
664
""" % (conffile, jailconffile, conf_hfile, phpBBconffile, usrmgtserver_initdfile)
663
665
 
664
666
        # Get information from the administrator
665
667
        # If EOF is encountered at any time during the questioning, just exit
837
839
 
838
840
    print "Successfully wrote www/php/phpBB3/config.php"
839
841
 
 
842
    # Write lib/conf/usrmgt-server.init
 
843
 
 
844
    try:
 
845
        conf = open(usrmgtserver_initdfile, "w")
 
846
 
 
847
        conf.write( '''#! /bin/sh
 
848
 
 
849
# Works for Ubuntu. Check before using on other distributions
 
850
 
 
851
### BEGIN INIT INFO
 
852
# Provides:          usrmgt-server
 
853
# Required-Start:    $syslog $networking $urandom
 
854
# Required-Stop:     $syslog
 
855
# Default-Start:     2 3 4 5
 
856
# Default-Stop:      1
 
857
# Short-Description: IVLE user management server
 
858
# Description:       Daemon connecting to the IVLE user management database.
 
859
### END INIT INFO
 
860
 
 
861
PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
862
DESC="IVLE user management server"
 
863
NAME=usrmgt-server
 
864
DAEMON=/opt/ivle/scripts/$NAME
 
865
DAEMON_ARGS="''' + str(usrmgt_port) + ''' ''' + usrmgt_magic + '''"
 
866
PIDFILE=/var/run/$NAME.pid
 
867
SCRIPTNAME=/etc/init.d/usrmgt-server
 
868
 
 
869
# Exit if the daemon does not exist 
 
870
test -f $DAEMON || exit 0
 
871
 
 
872
# Load the VERBOSE setting and other rcS variables
 
873
[ -f /etc/default/rcS ] && . /etc/default/rcS
 
874
 
 
875
# Define LSB log_* functions.
 
876
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
 
877
. /lib/lsb/init-functions
 
878
 
 
879
#
 
880
# Function that starts the daemon/service
 
881
#
 
882
do_start()
 
883
{
 
884
        # Return
 
885
        #   0 if daemon has been started
 
886
        #   1 if daemon was already running
 
887
        #   2 if daemon could not be started
 
888
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
 
889
                || return 1
 
890
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
 
891
                $DAEMON_ARGS \
 
892
                || return 2
 
893
        # Add code here, if necessary, that waits for the process to be ready
 
894
        # to handle requests from services started subsequently which depend
 
895
        # on this one.  As a last resort, sleep for some time.
 
896
}
 
897
 
 
898
#
 
899
# Function that stops the daemon/service
 
900
#
 
901
do_stop()
 
902
{
 
903
        # Return
 
904
        #   0 if daemon has been stopped
 
905
        #   1 if daemon was already stopped
 
906
        #   2 if daemon could not be stopped
 
907
        #   other if a failure occurred
 
908
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
 
909
        RETVAL="$?"
 
910
        [ "$RETVAL" = 2 ] && return 2
 
911
        # Wait for children to finish too if this is a daemon that forks
 
912
        # and if the daemon is only ever run from this initscript.
 
913
        # If the above conditions are not satisfied then add some other code
 
914
        # that waits for the process to drop all resources that could be
 
915
        # needed by services started subsequently.  A last resort is to
 
916
        # sleep for some time.
 
917
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
 
918
        [ "$?" = 2 ] && return 2
 
919
        # Many daemons don't delete their pidfiles when they exit.
 
920
        rm -f $PIDFILE
 
921
        return "$RETVAL"
 
922
}
 
923
 
 
924
#
 
925
# Function that sends a SIGHUP to the daemon/service
 
926
#
 
927
do_reload() {
 
928
        #
 
929
        # If the daemon can reload its configuration without
 
930
        # restarting (for example, when it is sent a SIGHUP),
 
931
        # then implement that here.
 
932
        #
 
933
        start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
 
934
        return 0
 
935
}
 
936
 
 
937
case "$1" in
 
938
  start)
 
939
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
 
940
        do_start
 
941
        case "$?" in
 
942
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
 
943
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 
944
        esac
 
945
        ;;
 
946
  stop)
 
947
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
 
948
        do_stop
 
949
        case "$?" in
 
950
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
 
951
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 
952
        esac
 
953
        ;;
 
954
  #reload|force-reload)
 
955
        #
 
956
        # If do_reload() is not implemented then leave this commented out
 
957
        # and leave 'force-reload' as an alias for 'restart'.
 
958
        #
 
959
        #log_daemon_msg "Reloading $DESC" "$NAME"
 
960
        #do_reload
 
961
        #log_end_msg $?
 
962
        #;;
 
963
  restart|force-reload)
 
964
        #
 
965
        # If the "reload" option is implemented then remove the
 
966
        # 'force-reload' alias
 
967
        #
 
968
        log_daemon_msg "Restarting $DESC" "$NAME"
 
969
        do_stop
 
970
        case "$?" in
 
971
          0|1)
 
972
                do_start
 
973
                case "$?" in
 
974
                        0) log_end_msg 0 ;;
 
975
                        1) log_end_msg 1 ;; # Old process is still running
 
976
                        *) log_end_msg 1 ;; # Failed to start
 
977
                esac
 
978
                ;;
 
979
          *)
 
980
                # Failed to stop
 
981
                log_end_msg 1
 
982
                ;;
 
983
        esac
 
984
        ;;
 
985
  *)
 
986
        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
 
987
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
 
988
        exit 3
 
989
        ;;
 
990
esac
 
991
 
 
992
:
 
993
''')
 
994
        
 
995
        conf.close()
 
996
    except IOError, (errno, strerror):
 
997
        print "IO error(%s): %s" % (errno, strerror)
 
998
        sys.exit(1)
 
999
 
 
1000
    # fix permissions as the file contains the database password
 
1001
    try:
 
1002
        os.chmod('doc/setup/usrmgt-server.init', 0600)
 
1003
    except OSError, (errno, strerror):
 
1004
        print "WARNING: Couldn't chmod doc/setup/usrmgt-server.init:"
 
1005
        print "OS error(%s): %s" % (errno, strerror)
 
1006
 
 
1007
    print "Successfully wrote lib/conf/usrmgt-server.init"
 
1008
 
840
1009
    print
841
1010
    print "You may modify the configuration at any time by editing"
842
1011
    print conffile
843
1012
    print jailconffile
844
1013
    print conf_hfile
845
1014
    print phpBBconffile
 
1015
    print usrmgtserver_initdfile
846
1016
    print
847
1017
    return 0
848
1018