4 Commits

  1. 41
      bitwarden/actions/upstream-versions
  2. 4
      bitwarden/metadata.yml
  3. 16
      collabora/actions/upstream-version-normalize
  4. 41
      collabora/actions/upstream-versions
  5. 49
      collabora/hooks/upstream-versions
  6. 42
      mongo/actions/upstream-versions
  7. 36
      mongo/hooks/upstream-versions
  8. 24
      nextcloud/actions/get-version
  9. 12
      nextcloud/actions/upgrade
  10. 41
      nextcloud/actions/upstream-versions
  11. 37
      nextcloud/hooks/upstream-versions
  12. 27
      nextcloud/lib/common
  13. 6
      nextcloud/metadata.yml
  14. 40
      rocketchat/actions/upstream-versions

41
bitwarden/actions/upstream-versions

@ -0,0 +1,41 @@
#!/bin/bash
# compose: no-hooks
## List upstream available versions in reverse chronological order
##
## These versions information will be the input for the version
## information usually used by the build process.
##
## A external query of upstream sources will be done.
##
## By default, limit should be 1 (the latest version)
usage="$exname [-h|--help] [-l|--limit <limit>]"
version_limit=5
while [ "$1" ]; do
case "$1" in
"--help"|"-h")
print_usage
exit 0
;;
"--limit"|"-l")
version_limit="$2"
shift
;;
*)
err "Unexpected argument '$1'."
exit 1
;;
esac
shift
done
set -e
DOCKER_IMAGE_NAME=vaultwarden/server
docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "20" -f "^[0-9]+\.[0-9]+\.[0-9]+-alpine" |
sort -rV |
cut -f 1 -d "-" |
head -n "$version_limit"

4
bitwarden/metadata.yml

@ -1,6 +1,6 @@
description: Bitwarden Server
#docker-image: vaultwarden/server:1.27.0
docker-image: docker.0k.io/vaultwarden:1.27.0
#docker-image: vaultwarden/server:1.32.3-alpine
docker-image: docker.0k.io/vaultwarden:1.32.3
data-resources:
- /data
uses:

16
collabora/actions/upstream-version-normalize

@ -0,0 +1,16 @@
#!/bin/bash
# compose: no-hooks
upstream_version="$1"
version="${upstream_version/./}"
read -r year_month major minor patch <<< ${version//./ }
if ! [ "${#patch}" == 1 ]; then
echo "Error: build number is not a single digit: '${patch}' (upstream: '${upstream_version}')" >&2
exit 1
fi
if [ "${#major}" -gt 2 ]; then
echo "Error: major number is more than 2 digits: '${major}' (upstream: '${upstream_version}')" >&2
exit 1
fi
major=$(printf "%02d" ${major})
echo "${year_month}${major}.${minor}.${patch}"

41
collabora/actions/upstream-versions

@ -0,0 +1,41 @@
#!/bin/bash
# compose: no-hooks
## List upstream available versions in reverse chronological order
##
## These versions information will be the input for the version
## information usually used by the build process.
##
## A external query of upstream sources will be done.
##
## By default, limit should be 1 (the latest version)
usage="$exname [-h|--help] [-l|--limit <limit>]"
version_limit=5
while [ "$1" ]; do
case "$1" in
"--help"|"-h")
print_usage
exit 0
;;
"--limit"|"-l")
version_limit="$2"
shift
;;
*)
err "Unexpected argument '$1'."
exit 1
;;
esac
shift
done
set -e
DOCKER_IMAGE_NAME=collabora/code
docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "20" -f "^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" |
sort -rV |
cut -f 1 -d "-" |
head -n "${version_limit}"

49
collabora/hooks/upstream-versions

@ -1,49 +0,0 @@
#!/bin/bash
## List upstream available versions in reverse chronological order
##
## These versions information will be the input for the version information
## usually used by the build process.
## A external query of upstream sources will be done.
##
## This script is launched by ``charm upstream-versions`` and will receive these env variables
##
##
## VERSION_LIMIT ## limit number of version to read
##
##
## The script CWD will be the root of the charm directory
##
DOCKER_IMAGE_NAME=collabora/code
semver:normalize() {
local upstream_version="$1"
local version="${upstream_version/./}"
read -r year_month major minor patch <<< ${version//./ }
if ! [ "${#patch}" == 1 ]; then
echo "Error: build number is not a single digit: '${patch}' (upstream: '${upstream_version}')" >&2
return 1
fi
if [ "${#major}" -gt 2 ]; then
echo "Error: major number is more than 2 digits: '${major}' (upstream: '${upstream_version}')" >&2
return 1
fi
major=$(printf "%02d" ${major})
echo "${year_month}${major}.${minor}.${patch}"
}
upstream:list() {
local limit=${1:-5}
docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "${limit}" -f "^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" |
sort -rV |
cut -f 1 -d "-"
}
while read -r "upstream_version"; do
normalized_version=$(semver:normalize "${upstream_version}") || exit 1
printf "%s %s\n" "$(semver:normalize "${upstream_version}")" "$upstream_version"
done < <(upstream:list "${VERSION_LIMIT}")

42
mongo/actions/upstream-versions

@ -0,0 +1,42 @@
#!/bin/bash
# compose: no-hooks
## List upstream available versions in reverse chronological order
##
## These versions information will be the input for the version
## information usually used by the build process.
##
## A external query of upstream sources will be done.
##
## By default, limit should be 1 (the latest version)
usage="$exname [-h|--help] [-l|--limit <limit>]"
version_limit=5
while [ "$1" ]; do
case "$1" in
"--help"|"-h")
print_usage
exit 0
;;
"--limit"|"-l")
version_limit="$2"
shift
;;
*)
err "Unexpected argument '$1'."
exit 1
;;
esac
shift
done
set -e
set -o pipefail
DOCKER_IMAGE_NAME=mongo
docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "20" -f "^[0-9]+\.[0-9]+\.[0-9]+$" |
sort -rV |
head -n "$version_limit"

36
mongo/hooks/upstream-versions

@ -1,36 +0,0 @@
#!/bin/bash
## List upstream available versions in reverse chronological order
##
## These versions information will be the input for the version information
## usually used by the build process.
## A external query of upstream sources will be done.
##
## This script is launched by ``charm upstream-versions`` and will receive these env variables
##
##
## VERSION_LIMIT ## limit number of version to read
##
##
## The script CWD will be the root of the charm directory
##
DOCKER_IMAGE_NAME=mongo
semver:normalize() {
local upstream_version="$1"
echo "$upstream_version"
}
upstream:list() {
local limit=${1:-5}
docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "${limit}" -f "^[0-9]+\.[0-9]+\.[0-9]+$" |
sort -rV
}
while read -r "upstream_version"; do
printf "%s %s\n" "$(semver:normalize "${upstream_version}")" "$upstream_version"
done < <(upstream:list "${VERSION_LIMIT}")

24
nextcloud/actions/get-version

@ -0,0 +1,24 @@
#!/bin/bash
# compose: no-hooks
. $CHARM_PATH/lib/common
image_version=${DOCKER_BASE_IMAGE##*:} ## retrieve tag
image_version=${image_version%%-*} ## remove suffix
version=$(nextcloud:config:version) || {
err "Failed to retrieve version"
exit 1
}
version=${version:-N/A} ## remove suffix
msg=()
if [ "$version" != "$image_version" ]; then
msg+=("image version mismatch ($image_version)")
fi
printf "%s\n" "$version" "${msg[@]}"

12
nextcloud/actions/upgrade

@ -55,17 +55,7 @@ while [ "$1" ]; do
shift
done
nextcloud:config:version() {
for f in {"$SERVICE_CONFIGSTORE","$SERVICE_DATASTORE"}/var/www/html/config/config.php; do
if [ -e "$f" ]; then
cat "$f"
break
fi
done |
grep "'version' =>" |
cut -f 4 -d \' |
cut -f 1-3 -d .
}
. lib/common
nextcloud:code:version() {
cat "$SERVICE_DATASTORE/var/www/html/version.php" |

41
nextcloud/actions/upstream-versions

@ -0,0 +1,41 @@
#!/bin/bash
# compose: no-hooks
## List upstream available versions in reverse chronological order
##
## These versions information will be the input for the version
## information usually used by the build process.
##
## A external query of upstream sources will be done.
##
## By default, limit should be 1 (the latest version)
usage="$exname [-h|--help] [-l|--limit <limit>]"
version_limit=5
while [ "$1" ]; do
case "$1" in
"--help"|"-h")
print_usage
exit 0
;;
"--limit"|"-l")
version_limit="$2"
shift
;;
*)
err "Unexpected argument '$1'."
exit 1
;;
esac
shift
done
set -e
DOCKER_IMAGE_NAME=nextcloud
docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "20" -f "^[0-9]+\.[0-9]+\.[0-9]+-apache" |
sort -rV |
cut -f 1 -d "-" |
head -n "$version_limit"

37
nextcloud/hooks/upstream-versions

@ -1,37 +0,0 @@
#!/bin/bash
## List upstream available versions in reverse chronological order
##
## These versions information will be the input for the version information
## usually used by the build process.
## A external query of upstream sources will be done.
##
## This script is launched by ``charm upstream-versions`` and will receive these env variables
##
##
## VERSION_LIMIT ## limit number of version to read
##
##
## The script CWD will be the root of the charm directory
##
DOCKER_IMAGE_NAME=nextcloud
semver:normalize() {
local upstream_version="$1"
echo "$upstream_version"
}
upstream:list() {
local limit=${1:-5}
docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "${limit}" -f "^[0-9]+\.[0-9]+\.[0-9]+-apache" |
sort -rV |
cut -f 1 -d "-"
}
while read -r "upstream_version"; do
printf "%s %s\n" "$(semver:normalize "${upstream_version}")" "$upstream_version"
done < <(upstream:list "${VERSION_LIMIT}")

27
nextcloud/lib/common

@ -78,7 +78,14 @@ get_admin_user_password() {
## only called after first install and occ is available
nextcloud:init() {
occ app:disable updatenotification nextcloud_announcements
occ app:disable updatenotification nextcloud_announcements \; \
config:system:set maintenance_window_start --type=integer --value=1 \; \
config:system:set trusted_proxies 0 --value="0.0.0.0/0" \; \
db:add-missing-columns \; \
db:add-missing-indices \; \
db:add-missing-primary-keys \; \
maintenance:repair --include-expensive
}
create_occ_if_not_exists() {
@ -114,7 +121,7 @@ create_occ_if_not_exists() {
err "Expected last command to create /var/www/html/occ"
return 1
fi
nextcloud:init
nextcloud:init || return 1
fi
}
@ -126,6 +133,9 @@ occ() {
## occ.batch will require /var/www/html to be populated ('occ' is
## supposed to exist). For that we need to make sure nextcloud have
## be ran and setup prior to running this next command.
## We need here actually only the relation sql-database. Any other hook
## using `occ` would make the call infinitively recursive.
export COMPOSE_IGNORE_ORPHANS=true
compose --debug -q --no-init --without-relation="$SERVICE_NAME":web-proxy run \
"${occ_docker_run_opts[@]}" \
@ -179,3 +189,16 @@ nextcloud:config:simple:add() {
## Add '$key' => 'value', to the end of the file, before the closing paren.
sed -ri "s/^(\);)$/ '$key' => '${value}',\n\1/g" "$CONFIGFILE"
}
nextcloud:config:version() {
for f in {"$SERVICE_CONFIGSTORE","$SERVICE_DATASTORE"}/var/www/html/config/config.php; do
if [ -e "$f" ]; then
cat "$f"
break
fi
done |
grep "'version' =>" |
cut -f 4 -d \' |
cut -f 1-3 -d .
}

6
nextcloud/metadata.yml

@ -21,6 +21,12 @@ uses:
proxy: "Public access"
default-options:
target: !var-expand ${MASTER_BASE_SERVICE_NAME}:80
apache-custom-rules:
- |
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
</IfModule>
backup:
constraint: recommended
auto: pair

40
rocketchat/actions/upstream-versions

@ -0,0 +1,40 @@
#!/bin/bash
# compose: no-hooks
## List upstream available versions in reverse chronological order
##
## These versions information will be the input for the version
## information usually used by the build process.
##
## A external query of upstream sources will be done.
##
## By default, limit should be 1 (the latest version)
usage="$exname [-h|--help] [-l|--limit <limit>]"
version_limit=5
while [ "$1" ]; do
case "$1" in
"--help"|"-h")
print_usage
exit 0
;;
"--limit"|"-l")
version_limit="$2"
shift
;;
*)
err "Unexpected argument '$1'."
exit 1
;;
esac
shift
done
set -e
DOCKER_IMAGE_NAME=rocketchat/rocket.chat
docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "20" -f "^[0-9]+\.[0-9]+\.[0-9]+$" |
sort -rV |
head -n "${version_limit}"
Loading…
Cancel
Save