#!/bin/sh ### BEGIN INIT INFO # Provides: mount-all.sh # Required-Start: $loop # Required-Stop: # Default-Start: S # Default-Stop: 0 1 6 # Position: S38eisconfig # Short-Description: mount config.d folder from data to root partition ### END INIT INFO # --------------------------------------------------------------------------- ### ------------------------------------------------------------------------- ### start/stop and failure message color output ### ------------------------------------------------------------------------- . /lib/lsb/init-functions ### ------------------------------------------------------------------------- ### mount from data to the root partition exists ### ------------------------------------------------------------------------- mount_eisfair_dir() { local datadir=$1 local rootdir=$2 local txtmsg=$3 if [ -e "$datadir" ] then log_begin_msg "$txtmsg" if [ -z "`mount | grep $datadir `" ] then mkdir -p $rootdir if cp -au ${rootdir}/* ${datadir}/ >/dev/null 2>&1 then echo -n " updated " rm -rf ${rootdir}/* fi mount --rbind $datadir $rootdir log_end_msg $? else log_end_msg 0 fi fi } ### ------------------------------------------------------------------------- ### umount from the root partition if exists ### ------------------------------------------------------------------------- umount_eisfair_dir() { local datadir=$1 local rootdir=$2 local txtmsg=$3 if [ -e $datadir ] then log_begin_msg "$txtmsg" if [ -n "`mount | grep $datadir `" ] then umount $rootdir log_end_msg $? else log_end_msg 0 fi fi } ### ------------------------------------------------------------------------- ### status check ### ------------------------------------------------------------------------- status_mount_dir() { local datadir=$1 local txtmsg=$2 if [ -e $datadir ] then log_begin_msg "$txtmsg" if [ -n "`mount | grep $datadir `" ] then log_end_msg $? else log_end_msg 0 fi fi } ### ------------------------------------------------------------------------- ### status check ### ------------------------------------------------------------------------- read_data_mounts_file() { [ -e /etc/datamount.conf ] || exit 0 local startstop="$1" while read datapath rootpath comment do echo "$datapath" | grep -q '^#' && continue case "$startstop" in start) mount_eisfair_dir "$datapath" "$rootpath" "$comment" ;; stop) umount_eisfair_dir "$datapath" "$rootpath" "$comment" ;; status) status_mount_dir "$datapath" "$comment" ;; esac done < /etc/datamount.conf } ### ------------------------------------------------------------------------- ### create xen console if necessary ### ------------------------------------------------------------------------- create_xen_console() { #---------------------------------------------------------------------------- # activate/deactivate hvc0 #---------------------------------------------------------------------------- [ -e /var/install/include/virtlib ] && . /var/install/include/virtlib is_running_in_xendomu if [ $? = 0 ] then if [ -c /dev/hvc0 ] then # turn on hvc0 sed -i -e 's/^#respawn*/respawn/' /etc/event.d/hvc0 sed -i -e 's/^#exec*/exec/' /etc/event.d/hvc0 # turn off xvc0 sed -i -e 's/^respawn*/#respawn/' /etc/event.d/xvc0 sed -i -e 's/^exec*/#exec/' /etc/event.d/xvc0 fi if [ -c /dev/xvc0 ] then # turn off hvc0 sed -i -e 's/^respawn*/#respawn/' /etc/event.d/hvc0 sed -i -e 's/^exec*/#exec/' /etc/event.d/hvc0 # turn on xvc0 sed -i -e 's/^#respawn*/respawn/' /etc/event.d/xvc0 sed -i -e 's/^#exec*/exec/' /etc/event.d/xvc0 fi else sed -i -e 's/^respawn*/#respawn/' /etc/event.d/hvc0 sed -i -e 's/^exec*/#exec/' /etc/event.d/hvc0 sed -i -e 's/^respawn*/#respawn/' /etc/event.d/xvc0 sed -i -e 's/^exec*/#exec/' /etc/event.d/xvc0 fi } ### ------------------------------------------------------------------------- ### main ### ------------------------------------------------------------------------- case "$1" in start) create_xen_console mount_eisfair_dir /data/etc/config.d /etc/config.d "Mount eisfair config.d on /data..." mount_eisfair_dir /data/home /home "Mount eisfair home on /data..." mount_eisfair_dir /data/var/lib /var/lib "Mount eisfair /var/lib on /data..." read_data_mounts_file start ;; stop) umount_eisfair_dir /data/etc/config.d /etc/config.d "Umount eisfair configuration config.d..." umount_eisfair_dir /data/home /home "Umount eisfair /home..." umount_eisfair_dir /data/var/lib /var/lib "Umount eisfair /var/lib..." read_data_mounts_file stop ;; status) status_mount_dir /data/etc/config.d "Mount eisfair config.d on /data..." status_mount_dir /data/home "Mount eisfair home on /data..." status_mount_dir /data/var/lib "Mount eisfair /var/lib on /data..." read_data_mounts_file status ;; restart|reload|force-reload) $0 stop $0 start ;; *) log_action_msg "Usage: /etc/init.d/cron {start|stop|status|restart|reload|force-reload}" exit 2 ;; esac exit 0