#!/bin/bash
#
# packup_wwwofflebook [-a]
#
# Copy the installed wwwofflebook files into the originally shipped 
# tarballs directory structure, to create a new tarball, including your
# modifications, that can be shipped again.
# Options:
# -a ... copy all files. Without the option -a, some files are omitted:
# The real purge.conf, by now.
# Note that if it copies your purge.conf, and you intend to ship it to 
# somebody else, you might want to modify these files afterwards 
# for privacy reasons. 
#
# Soucres wwwofflebook.conf.
# You also MUST CONFIGURE this script in the CONFIG section below !

# =================== CONFIG BEGIN =================================

# If you intend to run this script NOT as maintainer-user, you'll have to
# replace the heading ~ with the full path here:
CONFIG=~/.wwwoffle/wwwofflebook.conf
source $CONFIG
README=$userwwwoffle/README__wwwofflebook

# Where the wwwofflebook scripts reside
# SCRIPT_DIR=/usr/local/bin	# recommendet.
SCRIPT_DIR=/root/Scripts	# my personal design :)

# The directory containing the subdirectories where to copy the files. 
# This will also be the tarballs directory-root after extraction
# (e.g. if you extract in /tmp, it will become /tmp/wwwofflebook)
tardir_name=wwwofflebook
# Top directory 
TOP_DIR=/home/WERKS/BASH/TOOLS/$tardir_name
# Subdirectories must match the original structure.
userwwwoffle=$TOP_DIR/userwwwoffle/.wwwoffle
daemonwwwoffle=$TOP_DIR/daemonwwwoffle/etc_wwwoffle
Scripts=$TOP_DIR/Scripts/usr_local_bin
library=$TOP_DIR/library
# Full pathname of the new tarball
TARBALL=/tmp/wwwofflebook.tar.bz2

# Make proper
clear
unalias cp ls 2>/dev/null
copy_all=false; [ "$1" = "-a" ] && copy_all=true

# =================== CONFIG END ==================================


# ===== MAIN
echo "------------------ $0  ----------------------"
#
echo "top directory:"
cp -avf $README $TOP_DIR
echo "-----------------------------------------------------------------------"
#
# 
echo "userwwwoffle:"
cp -avf $CONFIG $userwwwoffle
echo "-----------------------------------------------------------------------"
#
echo "daemonwwwoffle:"
$copy_all && cp -afv $WWWOFFLE_PURGE_CONF $daemonwwwoffle
echo "-----------------------------------------------------------------------"
#
echo "Scripts:"
for file in `ls -1 $SCRIPT_DIR/wwwofflebook*`; do
    cp -afv $file $Scripts
done
echo "-----------------------------------------------------------------------"
#
#
#
echo "Create tarball $TARBALL":
tar -cvj  --directory=$TOP_DIR/.. --file $TARBALL $tardir_name
echo "-------------------------------- done. ----------------------------------"
#
#
#
exit 0




