Added optional installer statistics
This commit is contained in:
parent
b4f4a122c8
commit
8e74fd2bff
|
@ -3,6 +3,8 @@
|
||||||
## Merges ofunctions.sh and $PROGRAM
|
## Merges ofunctions.sh and $PROGRAM
|
||||||
|
|
||||||
PROGRAM=osync
|
PROGRAM=osync
|
||||||
|
VERSION=$(grep "PROGRAM_VERSION=" n_$PROGRAM.sh)
|
||||||
|
VERSION=${VERSION#*=}
|
||||||
FUNC_PATH=/home/git/common
|
FUNC_PATH=/home/git/common
|
||||||
|
|
||||||
PARANOIA_DEBUG_LINE="#__WITH_PARANOIA_DEBUG"
|
PARANOIA_DEBUG_LINE="#__WITH_PARANOIA_DEBUG"
|
||||||
|
@ -36,7 +38,8 @@ function CleanDebug {
|
||||||
}
|
}
|
||||||
|
|
||||||
function CopyCommons {
|
function CopyCommons {
|
||||||
sed "s/\[prgname\]/$PROGRAM/g" /home/git/common/common_install.sh > ../install.sh
|
sed "s/\[prgname\]/$PROGRAM/g" /home/git/common/common_install.sh > ../tmp_install.sh
|
||||||
|
sed "s/\[version\]/$VERSION/g" ../tmp_install.sh > ../install.sh
|
||||||
sed "s/\[prgname\]/$PROGRAM/g" /home/git/common/common_batch.sh > ../$PROGRAM-batch.sh
|
sed "s/\[prgname\]/$PROGRAM/g" /home/git/common/common_batch.sh > ../$PROGRAM-batch.sh
|
||||||
chmod +x ../install.sh
|
chmod +x ../install.sh
|
||||||
chmod +x ../$PROGRAM-batch.sh
|
chmod +x ../$PROGRAM-batch.sh
|
||||||
|
@ -46,4 +49,5 @@ Unexpand
|
||||||
Merge
|
Merge
|
||||||
CleanDebug
|
CleanDebug
|
||||||
rm -f tmp_$PROGRAM.sh
|
rm -f tmp_$PROGRAM.sh
|
||||||
|
rm -f tmp_install.sh
|
||||||
CopyCommons
|
CopyCommons
|
||||||
|
|
99
install.sh
99
install.sh
|
@ -1,9 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
PROGRAM=osync
|
PROGRAM=osync
|
||||||
|
PROGRAM_VERSION=1.1-dev
|
||||||
PROGRAM_BINARY=$PROGRAM".sh"
|
PROGRAM_BINARY=$PROGRAM".sh"
|
||||||
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
||||||
SCRIPT_BUILD=2016031401
|
SCRIPT_BUILD=2016032502
|
||||||
|
|
||||||
## osync / obackup daemon install script
|
## osync / obackup daemon install script
|
||||||
## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8 & 10
|
## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8 & 10
|
||||||
|
@ -13,8 +14,27 @@ CONF_DIR=/etc/$PROGRAM
|
||||||
BIN_DIR=/usr/local/bin
|
BIN_DIR=/usr/local/bin
|
||||||
SERVICE_DIR=/etc/init.d
|
SERVICE_DIR=/etc/init.d
|
||||||
|
|
||||||
if [ "$(whoami)" != "root" ]; then
|
USER=root
|
||||||
echo "Must be run as 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
|
||||||
|
|
||||||
|
if [ "$(whoami)" != "$USER" ]; then
|
||||||
|
echo "Must be run as $USER."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -42,23 +62,37 @@ if [ -f "./exlude.list.example" ]; then
|
||||||
cp "./exclude.list.example" "/etc/$PROGRAM"
|
cp "./exclude.list.example" "/etc/$PROGRAM"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f "./snapshot.conf" ]; then
|
||||||
|
cp "./snapshot.conf" "/etc/$PROGRAM/snapshot.conf.example"
|
||||||
|
fi
|
||||||
|
|
||||||
cp "./$PROGRAM_BINARY" "$BIN_DIR"
|
cp "./$PROGRAM_BINARY" "$BIN_DIR"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Cannot copy $PROGRAM_BINARY to [$BIN_DIR]."
|
echo "Cannot copy $PROGRAM_BINARY to [$BIN_DIR]."
|
||||||
else
|
else
|
||||||
|
chmod 755 "$BIN_DIR/$PROGRAM_BINARY"
|
||||||
echo "Copied $PROGRAM_BINARY to [$BIN_DIR]."
|
echo "Copied $PROGRAM_BINARY to [$BIN_DIR]."
|
||||||
fi
|
fi
|
||||||
cp "./$PROGRAM_BATCH" "/usr/local/bin"
|
|
||||||
if [ $? != 0 ]; then
|
if [ -f "./$PROGRAM_BATCH" ]; then
|
||||||
echo "Cannot copy $PROGRAM_BATCH to [$BIN_DIR]."
|
cp "./$PROGRAM_BATCH" "$BIN_DIR"
|
||||||
else
|
if [ $? != 0 ]; then
|
||||||
echo "Copied $PROGRAM_BATCH to [$BIN_DIR]."
|
echo "Cannot copy $PROGRAM_BATCH to [$BIN_DIR]."
|
||||||
|
else
|
||||||
|
chmod 755 "$BIN_DIR/$PROGRAM_BATCH"
|
||||||
|
echo "Copied $PROGRAM_BATCH to [$BIN_DIR]."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
cp "./ssh_filter.sh" "/usr/local/bin"
|
|
||||||
if [ $? != 0 ]; then
|
if [ -f "./ssh_filter.sh" ]; then
|
||||||
echo "Cannot copy ssh_filter.sh to [$BIN_DIR]."
|
cp "./ssh_filter.sh" "$BIN_DIR"
|
||||||
else
|
if [ $? != 0 ]; then
|
||||||
echo "Copied ssh_filter.sh to [$BIN_DIR]."
|
echo "Cannot copy ssh_filter.sh to [$BIN_DIR]."
|
||||||
|
else
|
||||||
|
chmod 755 "$BIN_DIR/ssh_filter.sh"
|
||||||
|
chown $USER:$GROUP "$BIN_DIR/ssh_filter.sh"
|
||||||
|
echo "Copied ssh_filter.sh to [$BIN_DIR]."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "./osync-srv" ]; then
|
if [ -f "./osync-srv" ]; then
|
||||||
|
@ -66,12 +100,41 @@ if [ -f "./osync-srv" ]; then
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Cannot copy osync-srv to [$SERVICE_DIR]."
|
echo "Cannot copy osync-srv to [$SERVICE_DIR]."
|
||||||
else
|
else
|
||||||
|
chmod 755 "$SERVICE_DIR/osync-srv"
|
||||||
echo "Created osync-srv service in [$SERVICE_DIR]."
|
echo "Created osync-srv service in [$SERVICE_DIR]."
|
||||||
chmod 755 "/etc/init.d/osync-srv"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 755 "/usr/local/bin/$PROGRAM_BINARY"
|
function Statistics {
|
||||||
chmod 755 "/usr/local/bin/$PROGRAM_BATCH"
|
|
||||||
chmod 755 "/usr/local/bin/ssh_filter.sh"
|
local link="http://instcount.netpower.fr?program=$PROGRAM&version=$PROGRAM_VERSION"
|
||||||
chown root:root "/usr/local/bin/ssh_filter.sh"
|
if type wget > /dev/null; then
|
||||||
|
wget $link > /dev/null 2>&1
|
||||||
|
if [ $? == 0 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if type curl > /dev/null; then
|
||||||
|
curl $link > /dev/null 2>&1
|
||||||
|
if [ $? == 0 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Neiter wget nor curl could be used for. Cannot run statistics. Use the provided link please."
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM"
|
||||||
|
echo ""
|
||||||
|
echo "In order to make install statistics, the script would like to connect to http://instcount.netpower.fr?program=$PROGRAM&version=$PROGRAM_VERSION"
|
||||||
|
read -r -p "No data except those in the url will be send. Allow [Y/n]" response
|
||||||
|
case $response in
|
||||||
|
[nN])
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
Statistics
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
Loading…
Reference in New Issue