git.lirion.de

Of git, get, and gud

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LICENSE.md163
-rwxr-xr-xbin/nextcloud-update162
-rwxr-xr-xbin/nextcloud-upgrade2
3 files changed, 305 insertions, 22 deletions
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..cb564da
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,163 @@
+GNU Lesser General Public License
+=================================
+
+_Version 3, 29 June 2007_
+_Copyright © 2007 Free Software Foundation, Inc. &lt;<http://fsf.org/>&gt;_
+
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+
+This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+### 0. Additional Definitions
+
+As used herein, “this License” refers to version 3 of the GNU Lesser
+General Public License, and the “GNU GPL” refers to version 3 of the GNU
+General Public License.
+
+“The Library” refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+An “Application” is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+A “Combined Work” is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the “Linked
+Version”.
+
+The “Minimal Corresponding Source” for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+The “Corresponding Application Code” for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+### 1. Exception to Section 3 of the GNU GPL
+
+You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+### 2. Conveying Modified Versions
+
+If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+* **a)** under this License, provided that you make a good faith effort to
+ensure that, in the event an Application does not supply the
+function or data, the facility still operates, and performs
+whatever part of its purpose remains meaningful, or
+
+* **b)** under the GNU GPL, with none of the additional permissions of
+this License applicable to that copy.
+
+### 3. Object Code Incorporating Material from Library Header Files
+
+The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+* **a)** Give prominent notice with each copy of the object code that the
+Library is used in it and that the Library and its use are
+covered by this License.
+* **b)** Accompany the object code with a copy of the GNU GPL and this license
+document.
+
+### 4. Combined Works
+
+You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+* **a)** Give prominent notice with each copy of the Combined Work that
+the Library is used in it and that the Library and its use are
+covered by this License.
+
+* **b)** Accompany the Combined Work with a copy of the GNU GPL and this license
+document.
+
+* **c)** For a Combined Work that displays copyright notices during
+execution, include the copyright notice for the Library among
+these notices, as well as a reference directing the user to the
+copies of the GNU GPL and this license document.
+
+* **d)** Do one of the following:
+ - **0)** Convey the Minimal Corresponding Source under the terms of this
+License, and the Corresponding Application Code in a form
+suitable for, and under terms that permit, the user to
+recombine or relink the Application with a modified version of
+the Linked Version to produce a modified Combined Work, in the
+manner specified by section 6 of the GNU GPL for conveying
+Corresponding Source.
+ - **1)** Use a suitable shared library mechanism for linking with the
+Library. A suitable mechanism is one that **(a)** uses at run time
+a copy of the Library already present on the user's computer
+system, and **(b)** will operate properly with a modified version
+of the Library that is interface-compatible with the Linked
+Version.
+
+* **e)** Provide Installation Information, but only if you would otherwise
+be required to provide such information under section 6 of the
+GNU GPL, and only to the extent that such information is
+necessary to install and execute a modified version of the
+Combined Work produced by recombining or relinking the
+Application with a modified version of the Linked Version. (If
+you use option **4d0**, the Installation Information must accompany
+the Minimal Corresponding Source and Corresponding Application
+Code. If you use option **4d1**, you must provide the Installation
+Information in the manner specified by section 6 of the GNU GPL
+for conveying Corresponding Source.)
+
+### 5. Combined Libraries
+
+You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+* **a)** Accompany the combined library with a copy of the same work based
+on the Library, uncombined with any other library facilities,
+conveyed under the terms of this License.
+* **b)** Give prominent notice with the combined library that part of it
+is a work based on the Library, and explaining where to find the
+accompanying uncombined form of the same work.
+
+### 6. Revised Versions of the GNU Lesser General Public License
+
+The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License “or any later version”
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/bin/nextcloud-update b/bin/nextcloud-update
index 47c0b7e..c01f75e 100755
--- a/bin/nextcloud-update
+++ b/bin/nextcloud-update
@@ -40,29 +40,149 @@ source /usr/lib/lirion/ln-initfunctions || exit 2
# called /usr/local/bin/nextcloud-*).
# TODO: make update check decide on whether to update
+
+# Define help function
+function hayulp {
+ printf 'USAGE: %b [-a|--app-update] [-c|--core-update] [-s|--status] [-u|--update-check]\n\n' "$(basename "$0")"
+ (
+ printf -- '-a,\n'
+ printf -- '--app-update;Update all apps\n'
+ printf -- '-c,\n'
+ printf -- '--core-update;Update the Nextcloud core (including apps update)\n'
+ printf -- '-s,\n'
+ printf -- '--status;Status including version\n'
+ printf -- '-u,\n'
+ printf -- '--update-check;Status including update check\n'
+ printf -- '-h,\n'
+ printf -- '--help;This help text\n'
+ )|column -ts \;
+ printf '\n'
+}
+
+# User variables: imperatives whether to do app/core updates, print status, print update check.
+# See "PARSE: COMMAND LINE PARAMETERS" below.
+NC_APPSUPD=0; NC_COREUPD=0; NC_STATDSP=0; NC_UPCHECK=0
+# Script-only variables: update available for apps/core?
+NC_UA_APPS=0; NC_UA_CORE=0
+# doc/decl only: we have a variable called UPDVER for the available core update version
+declare UPDVER
+
+##### PARSE: COMMAND LINE PARAMETERS #####
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ "-h"|"--help")
+ hayulp
+ exit 0
+ # shift meaningless here: we exit
+ ;;
+ "-a"|"--app-update")
+ NC_APPSUPD=1
+ shift
+ ;;
+ "-c"|"--core-update")
+ NC_COREUPD=1
+ shift # past argument
+ # VALUE="$2"
+ # shift # past value
+ ;;
+ "-s"|"--status")
+ NC_STATDSP=1
+ shift
+ ;;
+ "-u"|"--update-check")
+ NC_UPCHECK=1
+ shift
+ ;;
+ "-"*)
+ hayulp
+ printf '\033[93mUnknown option: %b\033[0m\n' "$1" >&2
+ exit 101
+ ;;
+ esac
+done
+
+if [[ "$NC_STATDSP" -eq 0 && "$NC_APPSUPD" -eq 0 && "$NC_COREUPD" -eq 0 && "$NC_UPCHECK" -eq 0 ]]; then
+ hayulp
+ printf '\033[93mNo action chosen, please read the help text above.\033[0m\n' >&2
+ exit 255
+fi
+
sudo whoami > /dev/null || exit 2
-lnbegin "Checking for update"
-# THis script always returns 0 - php yokerel, tee hee - so we need to parse. RC!=0 = script failed
-# unexpectedly.
-if ! UPDSTR="$(/usr/bin/sudo -u "$NCUSER" "$NCPHPBIN" "${NCAPPLDIR}/occ" update:check 2>&1)"; then
- lnfail 'update check failed'
- exit 10
+
+##### EXEC: STATUS #####
+if [ "$NC_STATDSP" -eq 1 ]; then
+ printf '\033[1mStatus + version:\033[0m\n'
+ if [ -x "/usr/bin/jq" ]; then
+ /usr/bin/jq < <(/usr/bin/sudo -u "$NCUSER" "$NCPHPBIN" "${NCAPPLDIR}/occ" status --output='json')
+ else
+ /usr/bin/sudo -u "$NCUSER" "$NCPHPBIN" "${NCAPPLDIR}/occ" status --output='json_pretty'
+ fi
fi
-if ! /usr/bin/printf '%b' "$UPDSTR" | grep -P '^Nextcloud [0-9]+\..*is available' > /dev/null; then
- lnok 'none available'
+if [[ "$NC_APPSUPD" -eq 0 && "$NC_COREUPD" -eq 0 && "$NC_UPCHECK" -eq 0 ]]; then
exit 0
-else
- UPDVER="$(/usr/bin/printf '%b' "$UPDSTR" | grep -P '^Nextcloud [0-9]+\..*is available')"
- UPDVER="$(printf '%b' "$UPDVER" | sed 's/.*extcloud[\ \t-]\([^\ \t]\+\).*/\1/')"
- lnok "available: $UPDVER"
fi
-if [ "$(printf '%b' "$UPDVER" | wc -l)" -gt 0 ]; then
- printf 'Not a single line: %b\n' "$NCVER" >&2
- exit 14
-elif [ "$(printf '%b' "$UPDVER" | wc -w)" -ne 1 ]; then
- printf 'Not a single word: %b\n' "$NCVER" >&2
- exit 15
+
+##### EXEC: UPDATE CHECK #####
+lnbegin "Performing update check"
+if ! UPDSTR="$(/usr/bin/sudo -u "$NCUSER" "$NCPHPBIN" "${NCAPPLDIR}/occ" update:check --no-interaction 2>&1)"; then
+ # This script always returns 0 - php yokerel, tee hee - so we need to parse. RC!=0 = script failed
+ # unexpectedly.
+ # Yes, there is --format=json - and no, it does not work for update:check nor does it exist for something
+ # like update:check :-(
+ lnfail
+ exit 10
+fi
+lnok
+if [ "$NC_UPCHECK" -eq 1 ]; then
+ printf '%b\n' "$UPDSTR"
+fi
+
+##### PARSE: CORE UPDATE AVAILABLE? #####
+# See "Performing update check" above...
+if [ "$NC_COREUPD" -eq 1 ]; then
+ lnbegin "Parse: core update"
+ if ! /usr/bin/printf '%b' "$UPDSTR" | grep -P '^Nextcloud [0-9]+\..*is available' > /dev/null; then
+ lnok 'none available'
+ else
+ UPDVER="$(/usr/bin/printf '%b' "$UPDSTR" | grep -P '^Nextcloud [0-9]+\..*is available')"
+ UPDVER="$(printf '%b' "$UPDVER" | sed 's/.*extcloud[\ \t-]\([^\ \t]\+\).*/\1/')"
+ if [ "$(printf '%b' "$UPDVER" | wc -l)" -gt 0 ]; then
+ printf 'Not a single line: %b\n' "$NCVER" >&2
+ exit 14
+ elif [ "$(printf '%b' "$UPDVER" | wc -w)" -ne 1 ]; then
+ printf 'Not a single word: %b\n' "$NCVER" >&2
+ exit 15
+ fi
+ lnok "available: $UPDVER"
+ NC_UA_CORE=1
+ fi
+fi
+
+##### PARSE: APP UPDATE(S) AVAILABLE? #####
+# See "Performing update check" above...
+if [ "$NC_APPSUPD" -eq 1 ]; then
+ lnbegin "Parse: apps updates"
+ # TODO: look at update:check again and see what to grep(!) for (again, the script doesn't deliver
+ # return codes, nor does the crappy output at least have a json flag
+ lnwarn "not yet implemented"
+fi
+
+
+##### NEXTCLOUD CORE DOWNLOAD #####
+if [[ "$NC_COREUPD" -eq 1 && "$NC_UA_CORE" -eq 1 ]]; then
+ /usr/local/bin/nextcloud-download "$UPDVER" || exit "$?"
+fi
+##### NEXTCLOUD INSTANCE BACKUP #####
+# This is the separate backup of DB and files mentioned at the top of the file.
+if [[ "$NC_COREUPD" -eq 1 && "$NC_UA_CORE" -eq 1 ]]; then
+ /usr/bin/sudo /usr/local/bin/nextcloud-backup || exit "$?"
+fi
+
+##### NEXTCLOUD UPDATES #####
+if [[ "$NC_COREUPD" -eq 1 || "$NC_APPSUPD" -eq 1 ]]; then
+ UPDCALL=( '/usr/local/bin/nextcloud-upgrade' )
+ if [[ "$NC_COREUPD" -eq 1 && "$NC_UA_CORE" -eq 1 ]]; then
+ UPDCALL=( '-c' "$UPDVER"
+ fi
fi
-/usr/local/bin/nextcloud-download "$UPDVER" || exit "$?"
-/usr/bin/sudo /usr/local/bin/nextcloud-backup || exit "$?"
-/usr/local/bin/nextcloud-upgrade "$UPDVER" || exit "$?"
+# /usr/local/bin/nextcloud-upgrade "$UPDVER" || exit "$?"
diff --git a/bin/nextcloud-upgrade b/bin/nextcloud-upgrade
index b805afd..c77182b 100755
--- a/bin/nextcloud-upgrade
+++ b/bin/nextcloud-upgrade
@@ -141,7 +141,7 @@ if ! /usr/bin/sudo -u "$NCUSER" "$NCPHPBIN" "${NCAPPLDIR}/occ" upgrade -q >/dev/
lnfail
exit 146
fi
-lnprog "occ app:update"
+lnprog "occ app:update --all"
if ! /usr/bin/sudo -u "$NCUSER" "$NCPHPBIN" "${NCAPPLDIR}/occ" app:update -q --all >/dev/null 2>&1; then
lnfail "occ app:update"
exit 147