Browse files

added dependency checks and debain init script (provided by jcharaoui)

  • Loading branch information...
1 parent e7f82e5 commit 310e7a51d032b3a65fdedfb48d3bc2a67759d9a5 @graysky2 committed Feb 2, 2013
Showing with 174 additions and 4 deletions.
  1. +4 −0 CHANGELOG
  2. +37 −1 README.md
  3. +9 −3 profile-sync-daemon
  4. +124 −0 psd.debian.init.example
View
4 CHANGELOG
@@ -1,3 +1,7 @@
+v5.12
+02-Feb-2013
+Added dependency checks and debain init script (provided by jcharaoui).
+
v5.11
26-Jan-2013
Added option to deny access to sync target while initial rsync is active (GNA).
View
38 README.md
@@ -1,11 +1,47 @@
#Profile-sync-daemon
Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage your browser's profile in tmpfs and to periodically sync it back to your physical disc (HDD/SSD). This is accomplished via a symlinking step and an innovative use of rsync to maintain back-up and synchronization between the two. One of the major design goals of psd is a completely transparent user experience.
-##Links
+##Links to Distro-Provided Packages
* Arch Linux via AUR Package: https://aur.archlinux.org/packages/profile-sync-daemon
* Chakra Linux via CCR Package: http://chakra-linux.org/ccr/packages.php?ID=3388
* Gentoo via Ebuild: http://packages.gentoo.org/package/www-misc/profile-sync-daemon
+If you are interested in packaging psd for your favorite distro, please contact me and I will add the link here.
+
##Documentation
Consult the man page or the wiki page: https://wiki.archlinux.org/index.php/Profile-sync-daemon
+##File Descriptions
+
+<table>
+<tr>
+<th>File</th><th>Description</th><th>Importance</th>
+</tr>
+<tr>
+<td>CHANGELOG</td><td>Project changelog.</td><td>Optional</td>
+</tr>
+<tr>
+<td>README-for_other_distros</td><td>Information to run psd distros that are not Arch Linux.</td><td>Optional</td>
+</tr>
+<tr>
+<td>VERSION_4_WARNING</td><td>Manual steps to follow if users are running psd version before version 4 and wish to update.</td><td>Must read</td>
+</tr>
+<tr>
+<td>profile-sync-daemon</td><td>Main script. Place it in /usr/bin</td><td>Required</td>
+</tr>
+<tr>
+<td>psd.conf</td><td>Config file. Place it in /etc</td><td>Required</td>
+</tr>
+<tr>
+<td>psd.cron.hourly</td><td>Default cronjob. Place it in /etc/cron.hourly</td><td>Optional</td>
+</tr>
+<tr>
+<td>psd.debian.init.example</td><td>An example init script for Debian users.</td><td>Optional</td>
+</tr>
+<tr>
+<td>psd.manpage</td><td>Example manpage for psd. Place it in /usr/share/man/man1</td><td>Optional</td>
+</tr>
+<tr>
+<td>psd.service</td><td>Example systemd service file. Place it in /usr/lib/systemd/system</td><td>Optional</td>
+</tr>
+</table>
View
12 profile-sync-daemon
@@ -2,7 +2,7 @@
# By graysky <graysky AT archlinux DOT us>
# Inspired by some code originally written by Colin Verot
export BLD="\e[01m" RED="\e[01;31m" GRN="\e[01;32m" YLW="\e[01;33m" NRM="\e[00m"
-VERS="5.11"
+VERS="5.12"
if [[ ! -f /etc/psd.conf ]]; then
echo "Cannot find /etc/psd.conf so bailing. Reinstall package to use Profile-sync-daemon." # nothing to do if there is no conf file
@@ -22,6 +22,12 @@ BROWSERS=${BROWSERS:-"chromium conkeror.mozdev.org firefox google-chrome heftig-
DAEMON_FILE=${DAEMON_FILE:-"/run/psd"} # make it overrideable from the commandline / config
+dep_check() {
+ # Although the package manager should handle these deps, this function is a sanity check for users.
+ command -v rsync >/dev/null 2>&1 || { echo "I require rsync but it's not installed. Aborting." >&2; exit 1; }
+ command -v gawk >/dev/null 2>&1 || { echo "I require gawk but it's not installed. Aborting." >&2; exit 1; }
+}
+
root_check() {
# we call this to ensure that only the root user is calling the function
# why care? both the sync and unsync functions require root access to /run/psd (the pseudo pid file)
@@ -303,10 +309,10 @@ do_unsync() {
case "$1" in
p|P|Parse|parse|debug)
- dup_check && parse_conf_file
+ dep_check && dup_check && parse_conf_file
;;
sync)
- [[ ! -f $DAEMON_FILE ]] && dup_check && running_check && ungraceful_state_check
+ [[ ! -f $DAEMON_FILE ]] && dep_check && dup_check && running_check && ungraceful_state_check
do_sync
;;
resync)
View
124 psd.debian.init.example
@@ -0,0 +1,124 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: profile-sync-daemon
+# Required-Start: $local_fs
+# Required-Stop: $local_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Keeps browser profiles in RAM.
+# Description: Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage
+# your browser's profile in tmpfs and to periodically sync it back to
+# your physical disc (HDD/SSD).
+### END INIT INFO
+
+# Author: Jerome Charaoui (jerome@riseup.net)
+#
+# The default configuration of profile-sync-daemon is to use /tmp over tmpfs
+# On Debian, this can be enabled with RAMTMP=yes in /etc/default/tmpfs
+
+# 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="Profile-sync-daemon"
+NAME=profile-sync-daemon
+DAEMON=/usr/local/bin/$NAME
+LOCKFILE=/run/psd
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Exit if rsync is not installed
+if [ ! -x "/usr/bin/rsync" ]; then
+ log_failure_msg "Could not locate rsync."
+ exit 1
+fi
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
+# and status_of_proc is working.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ [ -f $LOCKFILE ] && return 1
+ $DAEMON sync
+ RETVAL="$?"
+ [ "$RETVAL" != 0 ] && return 2
+ return 0
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ [ ! -f $LOCKFILE ] && return 1
+ $DAEMON unsync
+ RETVAL="$?"
+ [ "$RETVAL" != 0 ] && return 2
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ if [ -f $LOCKFILE ]; then
+ log_success_msg "$NAME is running"
+ exit 0
+ else
+ log_failure_msg "$NAME is not running"
+ exit 1
+ fi
+ ;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:

0 comments on commit 310e7a5

Please sign in to comment.