X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Finit.d%2Fsfa;h=08975dc7adbaaa5039981b415adbd60de2c62dc4;hb=3961165f3cbf33b0b154db3140398e0ed383acbd;hp=da583a8a8be3c137fadd49849406b59703758f62;hpb=f13173726f8382eef380f1e754f24dd2b126a77b;p=sfa.git diff --git a/sfa/init.d/sfa b/sfa/init.d/sfa index da583a8a..08975dc7 100755 --- a/sfa/init.d/sfa +++ b/sfa/init.d/sfa @@ -1,81 +1,117 @@ #!/bin/bash # -# geniwrapper Wraps PLCAPI into the GENI compliant API +# sfa Wraps PLCAPI into the SFA compliant API # -# chkconfig: 2345 5 99 +# hopefully right after plc +# chkconfig: 2345 61 39 # -# description: Wraps PLCAPI into the GENI compliant API -# -# $Id$ -# $URL$ +# description: Wraps PLCAPI into the SFA compliant API # # Source config -. /etc/sfa/sfa_config +[ -f /etc/sfa/sfa_config ] && . /etc/sfa/sfa_config # source function library . /etc/init.d/functions +# Regenerate configuration files - almost verbatim from plc.init +reload () +{ + force=$1 + + # Regenerate the main configuration file from default values + # overlaid with site-specific and current values. + # Thierry -- 2007-07-05 : values in plc_config.xml are *not* taken into account here + files=( + /etc/sfa/default_config.xml + /etc/sfa/configs/site.xml + ) + for file in "${files[@]}" ; do + if [ -n "$force" -o $file -nt /etc/sfa/sfa_config.xml ] ; then + tmp=$(mktemp /tmp/sfa_config.xml.XXXXXX) + plc-config --xml "${files[@]}" >$tmp + if [ $? -eq 0 ] ; then + mv $tmp /etc/sfa/sfa_config.xml + chmod 444 /etc/sfa/sfa_config.xml + else + echo "SFA: Warning: Invalid configuration file(s) detected" + rm -f $tmp + fi + break + fi + done + + # Convert configuration to various formats + if [ -n "$force" -o /etc/sfa/sfa_config.xml -nt /etc/sfa/sfa_config ] ; then + plc-config --shell /etc/sfa/sfa_config.xml >/etc/sfa/sfa_config + fi + if [ -n "$force" -o /etc/sfa/sfa_config.xml -nt /etc/sfa/sfa_config.py ] ; then + plc-config --python /etc/sfa/sfa_config.xml >/etc/sfa/sfa_config.py + fi +# if [ -n "$force" -o /etc/sfa/sfa_config.xml -nt /etc/sfa/php/sfa_config.php ] ; then +# mkdir -p /etc/sfa/php +# plc-config --php /etc/sfa/sfa_config.xml >/etc/sfa/php/sfa_config.php +# fi + + # [re]generate the sfa_component_config + gen-sfa-cm-config.py +} start() { - echo -n $"Starting GENIWrapper: " + + reload - if [ "$GENI_REGISTRY_ENABLED" ]; then - echo "Registry" - daemon /usr/bin/sfa-server.py -r -d $OPTIONS - fi + # install peer certs + action $"SFA installing peer certs" daemon /usr/bin/sfa-start.py -t -d $OPTIONS + + if [ "$SFA_REGISTRY_ENABLED" -eq 1 ]; then + action $"SFA Registry" daemon /usr/bin/sfa-start.py -r -d $OPTIONS + fi - if [ "$GENI_AGGREGATE_ENABLED" ]; then - echo "Aggregate" - daemon /usr/bin/sfa-server.py -a -d $OPTIONS - fi + if [ "$SFA_AGGREGATE_ENABLED" -eq 1 ]; then + action $"SFA Aggregate" daemon /usr/bin/sfa-start.py -a -d $OPTIONS + fi - if [ "$GENI_SM_ENABLED" ]; then - echo "SliceMgr" - daemon /usr/bin/sfa-server.py -s -d $OPTIONS - fi + if [ "$SFA_SM_ENABLED" -eq 1 ]; then + action "SFA SliceMgr" daemon /usr/bin/sfa-start.py -s -d $OPTIONS + fi + + if [ "$SFA_FLASHPOLICY_ENABLED" -eq 1 ]; then + action "Flash Policy Server" daemon /usr/bin/sfa_flashpolicy.py --file="$SFA_FLASHPOLICY_CONFIG_FILE" --port=$SFA_FLASHPOLICY_PORT -d + fi - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/geniwrapper + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sfa-start.py } stop() { - echo -n $"Shutting down GENIWrapper: " - killproc sfa-server.py + action $"Shutting down SFA" killproc sfa-start.py RETVAL=$? - echo - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/geniwrapper + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sfa-start.py } - case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) - stop - start - ;; - condrestart) - if [ -f /var/lock/subsys/geniwrapper ]; then - stop - start - fi - ;; - status) - status geniwrapper - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|condrestart|status}" - exit 1 + start) start ;; + stop) stop ;; + reload) reload force ;; + restart) stop; start ;; + condrestart) + if [ -f /var/lock/subsys/sfa-start.py ]; then + stop + start + fi + ;; + status) + status sfa-start.py + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}" + exit 1 + ;; esac exit $RETVAL