Commit 3f0ecce9 authored by Rafael Monnerat's avatar Rafael Monnerat

[package] Remove daemon scripts and remove missing calls to it

parent e6c87b62
...@@ -44,7 +44,7 @@ Directory Organisation ...@@ -44,7 +44,7 @@ Directory Organisation
- slapos.spec.in : configuration file for rpm packaging - slapos.spec.in : configuration file for rpm packaging
- slapos-node/ : Template to build package - slapos-node/ : Template to build package
- Makefile : Makefile to build slapos and add files for package - Makefile : Makefile to build slapos and add files for package
- slapos-start : shell script that will be run on startup (called by slapos-node daemon) - slapos-re6st-setup : shell script that can setup re6st for you.
- slapos-test : python script to check user configuration and cron file - slapos-test : python script to check user configuration and cron file
- template/ : template files for package (cron.d, service) - template/ : template files for package (cron.d, service)
- slapos/ : to build slapos. Contain buildout.cfg.in - slapos/ : to build slapos. Contain buildout.cfg.in
...@@ -76,4 +76,4 @@ About cron file ...@@ -76,4 +76,4 @@ About cron file
Main cron file is situated in slapos-node/template/slapos-node.cron.d Main cron file is situated in slapos-node/template/slapos-node.cron.d
Prepare script will copy this one in the debian directory. Prepare script will copy this one in the debian directory.
WARNING: if you update cron, do not forget to update slapos-test which check cron file WARNING: if you update cron, do not forget to update slapos-test which check cron file
\ No newline at end of file
#!/bin/bash
IPV6CHECK=ipv6.google.com
IPV4CHECK=google.com
IPV6WAITTIME=5
SLAPOS_CONFIGURATION=/etc/opt/slapos/
${ONLY_SLAPFORMAT:=false}
if [ $ONLY_SLAPFORMAT = false ]; then
if [ ! -f $SLAPOS_CONFIGURATION/slapos.cfg ]; then
echo "No slapos.cfg found"
exit 1
fi
echo "Starting slap script"
# Check ipv4
echo "Checking IPv4 connectivity..."
ping -c 2 $IPV4CHECK >/dev/null 2>&1
while [ $? != 0 ]; do
echo "IPv4 is not ready yet."
sleep 2
ping -c 2 $IPV4CHECK >/dev/null 2>&1
done
# Wait for ipv6 connection to be ready
echo "Checking IPv6 connectivity. This may take a few seconds..."
PING6_COMMAND="ping6 -c 2 $IPV6CHECK"
$PING6_COMMAND
while [ $? != 0 ];
do
echo "IPv6 is not ready yet."
sleep 2
$PING6_COMMAND >/dev/null 2>&1
done
else
sleep 15
fi
# Run slapformat
i=1
echo -n "Running slapos node format..."
SLAPOS_FORMAT_COMMAND="/opt/slapos/bin/slapos node format --cfg $SLAPOS_CONFIGURATION/slapos.cfg --now --log-file=/opt/slapos/log/slapos-node-format.log"
$SLAPOS_FORMAT_COMMAND
while [ $? != 0 ]; do
sleep $(($i*60))
if [ $i -le 20 ]; then
let i++
fi
echo "Retrying slapos node format"
$SLAPOS_FORMAT_COMMAND
done
if [ $ONLY_SLAPFORMAT = false ]; then
# Run bang
i=1
echo -n "Banging..."
/opt/slapos/bin/bang -m "Rebooted" $SLAPOS_CONFIGURATION/slapos.cfg
while [ $? != 0 ]; do
sleep $(($i*60))
if [ $i -le 20 ]; then
let i++
fi
echo "Retrying Bang"
/opt/slapos/bin/bang -m "Rebooted" $SLAPOS_CONFIGURATION/slapos.cfg
done
echo "done."
# Delete timestamp of all partitions so that it will force slapgrid to process them.
rm /srv/slapgrid/slappart*/.timestamp 2>/dev/null
fi
exit 0
[Unit]
Description=SlapOS node script
Requires=basic.target
Wants=network.target remote-fs.target
After=basic.target network.target remote-fs.target
[Service]
Type=simple
ExecStart=/usr/sbin/slapos-start
StandardOutput=tty
TTYPath=/dev/console
[Install]
WantedBy=multi-user.target
#! /bin/sh
### BEGIN INIT INFO
# Provides: slapos-node
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Initiate SlapOs
# Description: Check connectivity and run slapformat
### END INIT INFO
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Launching slapformat on start"
NAME=slapos-start
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --background --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --background --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:
...@@ -112,11 +112,5 @@ if [ -f /etc/openvpn/vifib.conf ]; then ...@@ -112,11 +112,5 @@ if [ -f /etc/openvpn/vifib.conf ]; then
cp -rf /etc/openvpn/vifib-keys/ /etc/openvpn/vifib-backup-keys cp -rf /etc/openvpn/vifib-keys/ /etc/openvpn/vifib-backup-keys
sed -i "s/\/etc\/openvpn\/vifib-keys/\/etc\/openvpn\/vifib-backup-keys/g" /etc/openvpn/vifib.backup.conf sed -i "s/\/etc\/openvpn\/vifib-keys/\/etc\/openvpn\/vifib-backup-keys/g" /etc/openvpn/vifib.backup.conf
fi fi
if [ -f /bin/systemctl ]; then
systemctl stop slapos-node.service
fi
%postun %postun
if [ -f /bin/systemctl ]; then
systemctl restart slapos-node.service
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment