#!/bin/sh
#
# (C) Daniel Sundberg 2000
# This is free software and you may do whatever 
# you want to with this according to the GPL.

echo "Backing up your plugins..."
for i in `ls $HOME/.jags/plugins/*.plugin | grep .plugin | cut -d ':' -f 1` 
do
    echo "Backing up $i to $i.bak"
    cp -R "$i" "$i.bak"
done

echo
echo "Installing the new samba-2.0.7-plugin..."
cp -R "plugins/samba-2.0.7.plugin" "$HOME/.jags/plugins"

echo
echo "Installing the new FreeBSD samba-2.0.7-plugin..."
cp -R "plugins/freebsd-samba-2.0.7.plugin" "$HOME/.jags/plugins"


# Check if you have the new cfg-options in your config-file
echo
echo "Backing up your config-file to $HOME/.jags/jags.conf.bak"
cp "$HOME/.jags/jags.conf" "$HOME/.jags/jags.conf.bak"
echo

# CFG: ShowDebugInfo
echo "Checking $HOME/.jags/jags.conf"
STUFF=$(more "$HOME/.jags/jags.conf" | grep ShowDebugInfo)
if [ -n "$STUFF" ]; then
    echo "$HOME/.jags/jags.conf is up to date!"
else
    echo "Adding ShowDebugInfo=1 to $HOME/.jags/jags.conf"
    echo "ShowDebugInfo=1" >> "$HOME/.jags/jags.conf"
fi

# CFG: ShowTooltips
STUFF=$(more "$HOME/.jags/jags.conf" | grep ShowTooltips)
if [ -n "$STUFF" ]; then
    echo "$HOME/.jags/jags.conf is up to date!"
else
    echo "Adding ShowTooltips=1 to $HOME/.jags/jags.conf"
    echo "ShowTooltips=1" >> "$HOME/.jags/jags.conf"
fi

# CFG: UserName
STUFF=$(more "$HOME/.jags/jags.conf" | grep UserName)
if [ -n "$STUFF" ]; then
    echo "$HOME/.jags/jags.conf is up to date!"
else
    echo "Adding UserName=username to $HOME/.jags/jags.conf"
    echo "UserName=username" >> "$HOME/.jags/jags.conf"
fi

# CFG: Password
STUFF=$(more "$HOME/.jags/jags.conf" | grep Password)
if [ -n "$STUFF" ]; then
    echo "$HOME/.jags/jags.conf is up to date!"
else
    echo "Adding Password=xxxx to $HOME/.jags/jags.conf"
    echo "Password=xxxx" >> "$HOME/.jags/jags.conf"
    echo "Please note that the password you type into "
    echo "Jags is stored in plain text. Don't do this "
    echo "if the password is important... But the default"
    echo "password if safe to keep..."
fi

# CFG: NumberOfMounts
STUFF=$(more "$HOME/.jags/jags.conf" | grep NumberOfMounts)
if [ -n "$STUFF" ]; then
    echo "$HOME/.jags/jags.conf is up to date!"
else
    echo "Adding NumberOfMounts=0 to $HOME/.jags/jags.conf"
    echo "NumberOfMounts=0" >> "$HOME/.jags/jags.conf"
fi