2015-04-24 21:23:04 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2015-11-12 01:26:38 +01:00
|
|
|
PROGRAM=obackup
|
|
|
|
PROGRAM_BINARY=$PROGRAM".sh"
|
|
|
|
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
2016-03-22 10:57:41 +01:00
|
|
|
SCRIPT_BUILD=2016032202
|
2015-04-24 21:23:04 +02:00
|
|
|
|
2015-11-12 01:26:38 +01:00
|
|
|
## osync / obackup daemon install script
|
2016-03-14 21:50:40 +01:00
|
|
|
## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8 & 10
|
2015-04-24 21:23:04 +02:00
|
|
|
## Please adapt this to fit your distro needs
|
|
|
|
|
2015-11-12 01:26:38 +01:00
|
|
|
CONF_DIR=/etc/$PROGRAM
|
|
|
|
BIN_DIR=/usr/local/bin
|
|
|
|
SERVICE_DIR=/etc/init.d
|
|
|
|
|
2016-03-22 10:56:14 +01:00
|
|
|
USER=root
|
|
|
|
|
|
|
|
local_os_var="$(uname -spio 2>&1)"
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
local_os_var="$(uname -v 2>&1)"
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
local_os_var="$(uname)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $local_os_var in
|
|
|
|
*"BSD"*)
|
|
|
|
GROUP=wheel
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
GROUP=root
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
2016-03-22 10:57:41 +01:00
|
|
|
if [ "$(whoami)" != "$USER" ]; then
|
|
|
|
echo "Must be run as $USER."
|
2015-08-25 15:26:36 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-11-12 01:26:38 +01:00
|
|
|
if [ ! -d "$CONF_DIR" ]; then
|
|
|
|
mkdir "$CONF_DIR"
|
|
|
|
if [ $? == 0 ]; then
|
|
|
|
echo "Created directory [$CONF_DIR]."
|
|
|
|
else
|
|
|
|
echo "Cannot create directory [$CONF_DIR]."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Config directory [$CONF_DIR] exists."
|
|
|
|
fi
|
|
|
|
|
2016-03-14 21:50:40 +01:00
|
|
|
if [ -f "./sync.conf" ]; then
|
|
|
|
cp "./sync.conf" "/etc/$PROGRAM/sync.conf.example"
|
2015-11-12 01:26:38 +01:00
|
|
|
fi
|
|
|
|
|
2016-03-14 21:50:40 +01:00
|
|
|
if [ -f "./host_backup.conf" ]; then
|
|
|
|
cp "./host_backup.conf" "/etc/$PROGRAM/host_backup.conf.example"
|
2015-11-12 01:26:38 +01:00
|
|
|
fi
|
|
|
|
|
2016-03-14 21:50:40 +01:00
|
|
|
if [ -f "./exlude.list.example" ]; then
|
|
|
|
cp "./exclude.list.example" "/etc/$PROGRAM"
|
2015-11-12 01:26:38 +01:00
|
|
|
fi
|
|
|
|
|
2016-03-20 16:49:29 +01:00
|
|
|
if [ -f "./snapshot.conf" ]; then
|
|
|
|
cp "./snapshot.conf" "/etc/$PROGRAM/snapshot.conf.example"
|
|
|
|
fi
|
|
|
|
|
2016-03-14 21:50:40 +01:00
|
|
|
cp "./$PROGRAM_BINARY" "$BIN_DIR"
|
2015-11-12 01:26:38 +01:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Cannot copy $PROGRAM_BINARY to [$BIN_DIR]."
|
|
|
|
else
|
2016-03-20 16:49:29 +01:00
|
|
|
chmod 755 "$BIN_DIR/$PROGRAM_BINARY"
|
2015-11-12 01:26:38 +01:00
|
|
|
echo "Copied $PROGRAM_BINARY to [$BIN_DIR]."
|
|
|
|
fi
|
2016-03-20 16:49:29 +01:00
|
|
|
|
|
|
|
if [ -f "./$PROGRAM_BATCH" ]; then
|
|
|
|
cp "./$PROGRAM_BATCH" "$BIN_DIR"
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Cannot copy $PROGRAM_BATCH to [$BIN_DIR]."
|
|
|
|
else
|
|
|
|
chmod 755 "$BIN_DIR/$PROGRAM_BATCH"
|
|
|
|
echo "Copied $PROGRAM_BATCH to [$BIN_DIR]."
|
|
|
|
fi
|
2015-11-12 01:26:38 +01:00
|
|
|
fi
|
2016-03-20 16:49:29 +01:00
|
|
|
|
|
|
|
if [ -f "./ssh_filter.sh" ]; then
|
|
|
|
cp "./ssh_filter.sh" "$BIN_DIR"
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Cannot copy ssh_filter.sh to [$BIN_DIR]."
|
|
|
|
else
|
|
|
|
chmod 755 "$BIN_DIR/ssh_filter.sh"
|
2016-03-22 10:57:41 +01:00
|
|
|
chown $USER:$GROUP "$BIN_DIR/ssh_filter.sh"
|
2016-03-20 16:49:29 +01:00
|
|
|
echo "Copied ssh_filter.sh to [$BIN_DIR]."
|
|
|
|
fi
|
2015-11-12 01:26:38 +01:00
|
|
|
fi
|
|
|
|
|
2016-03-14 21:50:40 +01:00
|
|
|
if [ -f "./osync-srv" ]; then
|
|
|
|
cp "./osync-srv" "$SERVICE_DIR"
|
2015-11-12 01:26:38 +01:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Cannot copy osync-srv to [$SERVICE_DIR]."
|
|
|
|
else
|
2016-03-20 16:49:29 +01:00
|
|
|
chmod 755 "$SERVICE_DIR/osync-srv"
|
2015-11-12 01:26:38 +01:00
|
|
|
echo "Created osync-srv service in [$SERVICE_DIR]."
|
|
|
|
fi
|
|
|
|
fi
|