I wrote:

Killing three birds with one stone ... I have an init script
(attached) that:

OFFFS ... first post and I screw up by failing to attach the script
<blush>

R
--
R A Lichtensteiger

   “Don’t make something unless it is both necessary and useful; but if it is
    both necessary and useful, don’t hesitate to make it beautiful.”
              —Shaker philosophy

--
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/20190729164129.GC10844%40mta.tifosi.com.
#!/bin/sh 

# Startup script to sync to/from a ramdisk for WeeWX for Debian derivatives
#
### BEGIN INIT INFO
# Provides:          weewx-ramdisk
# Required-Start:    $local_fs $remote_fs $syslog $time
# Required-Stop:     $local_fs $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: weewx weather system ramdisk
# Description:       Manages a ramdisk for the web output of weewx
### END INIT INFO

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="weewx weather system ramdisk"
NAME=weewx-ramdisk

TARGET="/var/www/weather"
BACKUP="/var/backups/weewx-webdir"
LOGFILE="/var/log/weewx/webdir-sync.log"

RSYNC_BIN="/usr/bin/rsync"

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Exit if the rsync package is not installed
[ -x "$RSYNC_BIN" ] || exit 0

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

if [ "$START_WEEWX" = no ]
then
  log_action_msg "Not starting $DESC, see /etc/default/$NAME"
  exit 0
fi

case "$1" in
  start)
    echo "Copying files to ramdisk"
    $RSYNC_BIN -av ${BACKUP}/ ${TARGET}/
    echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk restored from HD >> ${LOGFILE}
    ;;
  stop|sync|reload)
    echo "Synching files from ramdisk to Harddisk"
    echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk backed up to HD >> ${LOGFILE}
    $RSYNC_BIN -av --delete --recursive --force ${TARGET}/ ${BACKUP}/
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|sync|reload}"
    exit 1
    ;;
esac

exit 0

Reply via email to