Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/sh
- ### BEGIN INIT INFO
- # Provides: tempfs
- # Required-Start: $remote_fs
- # Required-Stop: $remote_fs
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Example initscript
- # Description: This file move the /var/log on tempfs, and copy them to
- # harddrive on shutdown
- # Create the link with :
- # #update-rc.d tempfs start 05 2 3 4 5 . stop 95 0 1 6 .
- ### END INIT INFO
- # Author: Sébastien Dailly <sebastien@chimrod.com>
- #
- # Do NOT "set -e"
- # PATH should only include /usr/* if it runs after the mountnfs.sh script
- PATH=/sbin:/usr/sbin:/bin:/usr/bin
- DESC="Description of the service"
- NAME=tempfs
- SCRIPTNAME=/etc/init.d/$NAME
- # 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
- #
- # 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
- #C'est ici qu'on va définir le système à mettre en place ( creation des répertoires etc )
- #Creer les répertoires /devrait/ être inutile, puisque tout est sauvegardé sur
- #la partition en dur
- mkdir /tmp/log/fsck
- mkdir /tmp/log/ksymoops
- mkdir /tmp/log/news
- mkdir /tmp/log/apt
- mkdir /tmp/log/dbconfig-common
- mkdir -p /tmp/log/debian-installer/cdebconf
- mkdir /tmp/log/ntpstats; chown ntp /tmp/log/ntpstats/
- mkdir /tmp/log/exim4; chown Debian-exim /tmp/log/exim4
- mkdir /tmp/log/mysql; chown mysql /tmp/log/mysql/
- mkdir -p /tmp/log/apache2/evasive; chown -R www-data:www-data /tmp/log/apache2/
- mkdir /tmp/log/pure-ftpd
- mkdir /tmp/log/mldonkey; chown mldonkey /tmp/log/mldonkey/
- mkdir /tmp/log/mpd; chown mpd /tmp/log/mpd/
- mkdir /tmp/log/lastfm; chown lastfm /tmp/log/lastfm/
- chgrp -R adm /tmp/log/
- mkdir /tmp/log/tor; chown debian-tor /tmp/log/tor/
- mkdir /tmp/uptimed;
- mkdir -p /tmp/mysql/wp_blog_chimrod/
- chown debian-tor /var/lib/tor/
- chown daemon:daemon /var/spool/uptimed/
- chown ntp /var/lib/ntp
- chmod 775 /var/run/screen
- #Lie les répertoires
- cp -af /var/log/ /tmp/
- cp -af /var/spool/uptimed/ /tmp/
- cp -af /var/lib/mysql/wp_blog_chimrod /tmp/mysql/
- mount --bind /tmp/log/ /var/log/
- mount --bind /tmp/mysql/wp_blog_chimrod/ /var/lib/mysql/wp_blog_chimrod/
- mount --bind /tmp/uptimed/ /var/spool/uptimed
- test -d /tmp/php_session/ || mkdir /tmp/php_session/
- chmod 777 /tmp/php_session/
- #Pour les partitions sur la clef USB on n'a pas besoin de copier lors de l'initialisation
- #mount /dev/disk/by-id/usb-EMTEC_U3_Smart_Drive_0700077B0C440397-0:0-part1 /mnt/data/
- #mount --bind /mnt/data/site/wordpress/wp-content/ /usr/share/wordpress/wp-content/
- #mount --bind /mnt/data/site/main/ /var/www/main/
- }
- #
- # Function that stops the daemon/service
- #
- do_stop()
- {
- #Sauvegarde les logs points de sauvegarde avant d'eteindre
- #monter avec bind permet d'outrepasser le point de montage
- #On utilise rsync pour se synchroniser
- # ( ne pas oublier le / final
- # sur le nom de fichier )
- mkdir /tmp/$$
- mount --bind /var/ /tmp/$$
- rsync -a --del /tmp/uptimed/ /tmp/$$/spool/uptimed/
- rsync -a --del /tmp/log/ /tmp/$$/log/
- rsync -a --del /tmp/mysql/wp_blog_chimrod/ /tmp/$$/lib/mysql/wp_blog_chimrod/
- #rsync -a --del /mnt/data/site/main/ /tmp/$$/www/main/
- #rsync -a --del /mnt/data/site/wordpress/wp-content/ /usr/share/wordpress/wp-content/
- umount /tmp/$$ && rm -r /tmp/$$
- }
- case "$1" in
- start)
- do_start
- ;;
- stop)
- do_stop
- ;;
- *)
- echo "Usage: $SCRIPTNAME {start|stop}" >&2
- exit 3
- ;;
- esac
- :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement