From a7e8487df3985125739af3577ef0cf8afb7488db Mon Sep 17 00:00:00 2001 From: deajan Date: Fri, 25 Mar 2016 22:51:26 +0100 Subject: [PATCH] Added optional statistics for installer --- CHANGELOG.md | 1 + dev/merge.sh | 6 +++++- install.sh | 29 +++++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b67f0a..af18570 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG README: FreeBSD execution needs mailer (not found), sudo missing, bash needed, sed missing (see if StripQuotes mandatory) ! XX Mar 2016: obackup v2.0 released +- Added optional statistics for installer - Added an option to ignore knownhosts for ssh connections (use with caution, this can lead to a security issue) - Improved mail fallback - More logging enhancements diff --git a/dev/merge.sh b/dev/merge.sh index 74bfd59..d198f2c 100755 --- a/dev/merge.sh +++ b/dev/merge.sh @@ -3,6 +3,8 @@ ## Merges ofunctions.sh and n_osync.sh into osync.sh PROGRAM=obackup +VERSION=$(grep "PROGRAM_VERSION=" n_$PROGRAM.sh) +VERSION=${VERSION#*=} FUNC_PATH=/home/git/common PARANOIA_DEBUG_LINE="__WITH_PARANOIA_DEBUG" @@ -36,7 +38,8 @@ function CleanDebug { } 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 chmod +x ../install.sh chmod +x ../obackup-batch.sh @@ -46,4 +49,5 @@ Unexpand Merge CleanDebug rm -f tmp_$PROGRAM.sh +rm -f ../tmp_install.sh CopyCommons diff --git a/install.sh b/install.sh index fbc48fa..0568a42 100755 --- a/install.sh +++ b/install.sh @@ -1,9 +1,10 @@ #!/usr/bin/env bash PROGRAM=obackup +PROGRAM_VERSION=2.0-pre PROGRAM_BINARY=$PROGRAM".sh" PROGRAM_BATCH=$PROGRAM"-batch.sh" -SCRIPT_BUILD=2016032202 +SCRIPT_BUILD=2016032501 ## osync / obackup daemon install script ## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8 & 10 @@ -32,7 +33,6 @@ case $local_os_var in ;; esac - if [ "$(whoami)" != "$USER" ]; then echo "Must be run as $USER." exit 1 @@ -104,3 +104,28 @@ if [ -f "./osync-srv" ]; then echo "Created osync-srv service in [$SERVICE_DIR]." fi fi + +function Statistics { + + local link="http://instcount.netpower.fr?program=$PROGRAM&version=$PROGRAM_VERSION" + if type wget > /dev/null; then + wget $link > /dev/null 2>&1 + elif type curl > /dev/null; then + curl $link > /dev/null 2>&1 + else + echo "Neiter wget nor curl installed. Cannot run statistics. Use link below please." + fi +} + +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