#!/bin/sh PATH="/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" HOME_DIR=/home/cristian LOG_DIR=/var/log BACKUP_DIR=${HOME_DIR}/logs RAMDISK_DEV=/dev/ram0 USBPEN_DEV=/dev/sdd # load default init functions . /lib/lsb/init-functions case "$1" in start) log_action_begin_msg "Configuring my stuff" # ram disk fs for var logs mke2fs ${RAMDISK_DEV} > /dev/null 2>&1 if [ $? -ne 0 ] then log_action_end_msg 1 exit 1 fi # mount ram disk mount ${RAMDISK_DEV} ${LOG_DIR} > /dev/null 2>&1 if [ $? -ne 0 ] then log_action_end_msg 1 exit 1 fi # var logs backup rm -rf ${BACKUP_DIR} mkdir -p ${BACKUP_DIR} # mount usb pen mount ${USBPEN_DEV} ${BACKUP_DIR} > /dev/null 2>&1 if [ $? -ne 0 ] then log_action_end_msg 1 exit 1 fi # start backup rsync -rv ${BACKUP_DIR}/log ${LOG_DIR} # hd spin down parameters hdparm -S24 -B1 -A1 /dev/sda if [ $? -ne 0 ] then log_action_end_msg 1 exit 1 fi # laptop mode echo 5 > /proc/sys/vm/laptop_mode # virtual memory sync tweak echo 8640000 > /proc/sys/vm/dirty_expire_centisecs # all ok log_action_end_msg 0 ;; stop) log_action_begin_msg "Deconfiguring my stuff" # unmount ram disk log file system umount ${LOG_DIR} > /dev/null 2>&1 if [ $? -ne 0 ] then log_action_end_msg 1 exit 1 fi # unmount logs backup file system umount ${BACKUP_DIR} > /dev/null 2>&1 if [ $? -ne 0 ] then log_action_end_msg 1 exit 1 fi # all ok log_action_end_msg 0 ;; *) echo "Usage: /etc/init.d/foobar {start|stop}" exit 1 ;; esac exit 0