git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
BranchCommit messageAuthorAge
masterCreate build directory, offer to clean outH. P. 5 months
 
TagDownloadAuthorAge
1.0.0lirion-initfunctions-1.0.0.tar.bz2  H. P. 9 months
 
AgeCommit messageAuthorFilesLines
2024-07-27+archlinux in packager1.0.0H. P. 2-3/+6
2024-06-16Rename package to ln-initfunctions, remove generated nfpm.yaml from gitH. P. 3-33/+2
2024-06-16include changelog init in make, remove prerelease and git stings from versionH. P. 4-6/+8
2024-06-16Fix: now in skeletonH. P. 2-2/+2
2024-06-16Fix: file ending for changelog fileH. P. 1-1/+1
2024-06-16InComm .chglog.ymlH. P. 1-0/+2
2024-06-16InCommH. P. 6-0/+645
} /* Error */ .highlight .k { color: #0000aa } /* Keyword */ .highlight .ch { color: #aaaaaa; font-style: italic } /* Comment.Hashbang */ .highlight .cm { color: #aaaaaa; font-style: italic } /* Comment.Multiline */ .highlight .cp { color: #4c8317 } /* Comment.Preproc */ .highlight .cpf { color: #aaaaaa; font-style: italic } /* Comment.PreprocFile */ .highlight .c1 { color: #aaaaaa; font-style: italic } /* Comment.Single */ .highlight .cs { color: #0000aa; font-style: italic } /* Comment.Special */ .highlight .gd { color: #aa0000 } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ .highlight .gi { color: #00aa00 } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #0000aa } /* Keyword.Constant */ .highlight .kd { color: #0000aa } /* Keyword.Declaration */ .highlight .kn { color: #0000aa } /* Keyword.Namespace */ .highlight .kp { color: #0000aa } /* Keyword.Pseudo */ .highlight .kr { color: #0000aa } /* Keyword.Reserved */ .highlight .kt { color: #00aaaa } /* Keyword.Type */ .highlight .m { color: #009999 } /* Literal.Number */ .highlight .s { color: #aa5500 } /* Literal.String */ .highlight .na { color: #1e90ff } /* Name.Attribute */ .highlight .nb { color: #00aaaa } /* Name.Builtin */ .highlight .nc { color: #00aa00; text-decoration: underline } /* Name.Class */ .highlight .no { color: #aa0000 } /* Name.Constant */ .highlight .nd { color: #888888 } /* Name.Decorator */ .highlight .ni { color: #880000; font-weight: bold } /* Name.Entity */ .highlight .nf { color: #00aa00 } /* Name.Function */ .highlight .nn { color: #00aaaa; text-decoration: underline } /* Name.Namespace */ .highlight .nt { color: #1e90ff; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #aa0000 } /* Name.Variable */ .highlight .ow { color: #0000aa } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #009999 } /* Literal.Number.Bin */ .highlight .mf { color: #009999 } /* Literal.Number.Float */ .highlight .mh { color: #009999 } /* Literal.Number.Hex */ .highlight .mi { color: #009999 } /* Literal.Number.Integer */ .highlight .mo { color: #009999 } /* Literal.Number.Oct */ .highlight .sa { color: #aa5500 } /* Literal.String.Affix */ .highlight .sb { color: #aa5500 } /* Literal.String.Backtick */ .highlight .sc { color: #aa5500 } /* Literal.String.Char */ .highlight .dl { color: #aa5500 } /* Literal.String.Delimiter */ .highlight .sd { color: #aa5500 } /* Literal.String.Doc */ .highlight .s2 { color: #aa5500 } /* Literal.String.Double */ .highlight .se { color: #aa5500 } /* Literal.String.Escape */ .highlight .sh { color: #aa5500 } /* Literal.String.Heredoc */ .highlight .si { color: #aa5500 } /* Literal.String.Interpol */ .highlight .sx { color: #aa5500 } /* Literal.String.Other */ .highlight .sr { color: #009999 } /* Literal.String.Regex */ .highlight .s1 { color: #aa5500 } /* Literal.String.Single */ .highlight .ss { color: #0000aa } /* Literal.String.Symbol */ .highlight .bp { color: #00aaaa } /* Name.Builtin.Pseudo */ .highlight .fm { color: #00aa00 } /* Name.Function.Magic */ .highlight .vc { color: #aa0000 } /* Name.Variable.Class */ .highlight .vg { color: #aa0000 } /* Name.Variable.Global */ .highlight .vi { color: #aa0000 } /* Name.Variable.Instance */ .highlight .vm { color: #aa0000 } /* Name.Variable.Magic */ .highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
#!/usr/bin/env bash
#
# This script is mostly included "as is", I did this quite a while ago and (also see todo remarks)
# I'm not happy yet, but it works fine and the core mechanisms are swell.
#
# AUTHOR: mail_redacted_for_web
# LICENCE: LGPL-3.0-only
#
# shellcheck disable=SC1091
source /etc/lirion/nextcloud.conf || exit 1
# shellcheck disable=SC1091
source /usr/lib/lirion/ln-initfunctions || exit 2

# TODO: Parametrise file directory and pw acquisition - better design and more secure
BDBDIR="${NCDBBKPDIR}/files"
PWFL="${NCDBBKPDIR}/pw"
TIME="$(date +"%Y-%m-%dT%H:%M:%S%z")"

#########
# MYSQL #
#########
DUMPOPTS=( "--add-drop-table" "--add-locks" )
DUMPOPTS+=( "--complete-insert" "--create-options" "--lock-tables" )

printf "File timestamp: %s\n" "$TIME"
DBARR=( "$NCDBNAME" )
for i in "${DBARR[@]}";do
	lnbegin "DB backup: $i"
	sleep 0.1337
	lnprog "dump"
	if ! mysqldump "${DUMPOPTS[@]}" -u root --password="$(cat "$PWFL")" --databases \
			"$i" > "$BDBDIR/$i-$TIME.sql" 2>/dev/null; then
		lnfail
		exit 120
	fi
	sleep 0.1337
	lnprog "compression"
	if ! xz -T4 "$BDBDIR/$i-$TIME.sql" > /dev/null 2>&1 && chmod 0600 \
			"$BDBDIR/$i-$TIME.sql.xz" 2>/dev/null; then
		lnfail
		exit 121
	fi
	sleep 0.1337
	lnok
done

NCVER="$(/usr/bin/sudo -u "$NCUSER" "$NCPHPBIN" "${NCAPPLDIR}/occ" 'status')" || exit 122
NCVER="$(/usr/bin/printf '%b' "$NCVER" | /usr/bin/grep 'version:' | /usr/bin/awk '{print $NF}')" || exit 123
/usr/bin/printf 'Current version: %b\n' "$NCVER"
if [ "$(printf '%b' "$NCVER" | wc -l)" -gt 0 ]; then
	printf 'Not a single line: %b\n' "$NCVER" >&2
	exit 124
elif [ "$(printf '%b' "$NCVER" | wc -w)" -ne 1 ]; then
	printf 'Not a single word: %b\n' "$NCVER" >&2
	exit 125
fi
lnbegin "File backup: Nextcloud"
sudo rm -f "${NCAPPLDIR}/../nextcloud-$(date -I)-${NCVER}.tar" \
	"${NCAPPLDIR}/../nextcloud-$(date -I)-${NCVER}.tar.xz" || exit 126
sleep 0.1337
lnprog 'dump'
if ! tar -C "${NCAPPLDIR}/.." --checkpoint=32768 --checkpoint-action='.' -cf \
		"${NCAPPLDIR}/../nextcloud-$(date -I)-${NCVER}.tar" "$NCAPPLDIR" 2>/dev/null
then
	lnfail
	exit 127
fi
lnprog 'compression'
if ! xz -T4 "${NCAPPLDIR}/../nextcloud-$(date -I)-${NCVER}.tar" > /dev/null 2>&1 && \
		chmod 0600 "${NCAPPLDIR}/../nextcloud-$(date -I)-${NCVER}.tar.xz" 2>/dev/null
then
	lnfail
	exit 128
fi
lnok