Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2017-04-03 20:59:44 +0300
committernachoparker <nacho@ownyourbits.com>2017-04-03 21:28:26 +0300
commit9b5cd8126f05a8151e78410df994c00a20c49f75 (patch)
treed74190d05cc1103969bb482d183037d627a50c9e
parent138fecc9f67eb2aaba6c50bf39cf22a16891f7c8 (diff)
check for updates (and update) upon launching nextcloudpi-configv0.5.3
-rwxr-xr-xbin/ncp-check-updates9
-rwxr-xr-xbin/ncp-test-updates24
-rwxr-xr-xbin/nextcloudpi-config22
-rwxr-xr-xnextcloud.sh36
4 files changed, 53 insertions, 38 deletions
diff --git a/bin/ncp-check-updates b/bin/ncp-check-updates
new file mode 100755
index 00000000..0a483b76
--- /dev/null
+++ b/bin/ncp-check-updates
@@ -0,0 +1,9 @@
+#!/bin/bash
+ cat > /usr/local/bin/ncp-check-updates <<'EOF'
+VERFILE=/var/run/.ncp-latest-version
+if ncp-test-updates; then
+ echo -e "\nNextCloudPi \e[1m$( cat $VERFILE )\e[0m available!!"
+ echo -e "update through 'nextcloudpi-config' or type 'sudo ncp-update'"
+else
+ echo -e "\nNextCloudPi \e[1m$( cat /usr/local/etc/ncp-version )\e[0m is up to date"
+fi
diff --git a/bin/ncp-test-updates b/bin/ncp-test-updates
new file mode 100755
index 00000000..bc7867eb
--- /dev/null
+++ b/bin/ncp-test-updates
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+NEED_UPDATE=false
+VERFILE=/var/run/.ncp-latest-version
+
+if test -f $VERFILE && grep -qP "v\d+\.\d+\.\d+" $VERFILE; then
+
+ MAJOR=$( grep -oP "\d+\.\d+\.\d+" $VERFILE | cut -d. -f1 )
+ MINOR=$( grep -oP "\d+\.\d+\.\d+" $VERFILE | cut -d. -f2 )
+ PATCH=$( grep -oP "\d+\.\d+\.\d+" $VERFILE | cut -d. -f3 )
+
+ MAJ=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f1 )
+ MIN=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f2 )
+ PAT=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f3 )
+
+ if [[ $MAJOR > $MAJ ]]; then
+ NEED_UPDATE=true
+ elif [[ $MAJOR == $MAJ ]] && [[ $MINOR > $MIN ]]; then
+ NEED_UPDATE=true
+ elif [[ $MAJOR == $MAJ ]] && [[ $MINOR == $MIN ]] && [[ $PATCH > $PAT ]]; then
+ NEED_UPDATE=true
+ fi
+fi
+[[ "$NEED_UPDATE" == "true" ]] && exit 0
diff --git a/bin/nextcloudpi-config b/bin/nextcloudpi-config
index f4cb7a70..464b26ae 100755
--- a/bin/nextcloudpi-config
+++ b/bin/nextcloudpi-config
@@ -12,20 +12,35 @@
# More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/
#
-CONFDIR=/usr/local/etc/nextcloudpi-config.d/
-
source /usr/local/etc/library.sh
function nextcloud-config()
{
local DIALOG_OK=0
local LIST=()
+ local VERSION=$( cat /usr/local/etc/ncp-version )
+ local VERFILE=/var/run/.ncp-latest-version
+ local BACKTITLE="NextCloudPi configuration ver. $VERSION"
+ local CONFDIR=/usr/local/etc/nextcloudpi-config.d/
+
+ # save latest version if it has never done before
+ test -f $VERFILE || ncp-check-version
+
+ # ask for update if outdated
+ ncp-test-updates && \
+ whiptail --backtitle "$BACKTITLE" \
+ --title "NextCloudPi update available" \
+ --clear --yesno "Update to $( cat $VERFILE )?" \
+ 10 40
+ [[ $? -eq $DIALOG_OK ]] && ncp-update
+
+ # launch the selection menu
for item in $CONFDIR/*.sh; do
local DESC=$( grep "DESCRIPTION=" $item | sed 's|^DESCRIPTION="||;s|"$||' )
LIST+=( $( basename $item .sh ) "$DESC" )
done
local script
- script=$( whiptail --backtitle "NextCloudPi configuration" \
+ script=$( whiptail --backtitle "$BACKTITLE" \
--title "NextCloudPi Software Configuration Tool (nextcloudpi-config)" \
--cancel-button Finish --ok-button Select \
--menu "Select program to configure and activate:" 20 100 10 \
@@ -34,6 +49,7 @@ function nextcloud-config()
[[ $? -ne $DIALOG_OK ]] || [[ "$script" == "" ]] && return 0
+ # launch selected script
configure_script $script.sh
}
diff --git a/nextcloud.sh b/nextcloud.sh
index 117d06e0..a8d651b4 100755
--- a/nextcloud.sh
+++ b/nextcloud.sh
@@ -257,41 +257,6 @@ EOF
##########################################
$APTINSTALL git
- cat > /usr/local/bin/ncp-check-updates <<'EOF'
-#!/bin/bash
-
-NEED_UPDATE=false
-VERFILE=/var/run/.ncp-latest-version
-
-if test -f $VERFILE && grep -qP "v\d+\.\d+\.\d+" $VERFILE; then
-
- MAJOR=$( grep -oP "\d+\.\d+\.\d+" $VERFILE | cut -d. -f1 )
- MINOR=$( grep -oP "\d+\.\d+\.\d+" $VERFILE | cut -d. -f2 )
- PATCH=$( grep -oP "\d+\.\d+\.\d+" $VERFILE | cut -d. -f3 )
-
- MAJ=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f1 )
- MIN=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f2 )
- PAT=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f3 )
-
- if [[ $MAJOR > $MAJ ]]; then
- NEED_UPDATE=true
- elif [[ $MAJOR == $MAJ ]] && [[ $MINOR > $MIN ]]; then
- NEED_UPDATE=true
- elif [[ $MAJOR == $MAJ ]] && [[ $MINOR == $MIN ]] && [[ $PATCH > $PAT ]]; then
- NEED_UPDATE=true
- fi
-fi
-
-if $NEED_UPDATE; then
- echo -e "\nNextCloudPi \e[1m$( cat $VERFILE )\e[0m available!!"
- echo -e "update through 'nextcloudpi-config' or type 'sudo ncp-update'"
-else
- echo -e "\nNextCloudPi \e[1m$( cat /usr/local/etc/ncp-version )\e[0m is up to date"
-fi
-EOF
- chmod a+x /usr/local/bin/ncp-check-updates
-
-
cat > /etc/cron.daily/ncp-check-version <<EOF
#!/bin/sh
/usr/local/bin/ncp-check-version
@@ -332,6 +297,7 @@ echo -e "NextCloudPi updated to version \e[1m$VER\e[0m"
EOF
chmod a+x /usr/local/bin/ncp-update
+ # update to latest version from github as part of the build process
/usr/local/bin/ncp-update
fi
}