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