mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-10 01:17:19 +00:00
Fix upgrade job failure
This commit is contained in:
parent
b0090edd52
commit
6a93af9670
10
.travis.yml
10
.travis.yml
@ -11,7 +11,9 @@ jobs:
|
|||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
# JOB: MiaB-LDAP connected to a remote Nextcloud
|
# JOB: MiaB-LDAP connected to a remote Nextcloud
|
||||||
- env: PRIMARY_HOSTNAME=box1.abc.com
|
- env:
|
||||||
|
- PRIMARY_HOSTNAME=box1.abc.com
|
||||||
|
- FEATURE_MUNIN=false
|
||||||
name: remote-nextcloud-docker
|
name: remote-nextcloud-docker
|
||||||
before_install:
|
before_install:
|
||||||
- echo "==== ENVIRONMENT ===="
|
- echo "==== ENVIRONMENT ===="
|
||||||
@ -35,7 +37,11 @@ jobs:
|
|||||||
- sudo tests/runner.sh -dumpoutput -no-smtp-remote default remote-nextcloud
|
- sudo tests/runner.sh -dumpoutput -no-smtp-remote default remote-nextcloud
|
||||||
|
|
||||||
# JOB: Upgrade from upstream install
|
# JOB: Upgrade from upstream install
|
||||||
- env: PRIMARY_HOSTNAME=box2.abc.com
|
- env:
|
||||||
|
- PRIMARY_HOSTNAME=box2.abc.com
|
||||||
|
- UPSTREAM_TAG=master
|
||||||
|
- FEATURE_NEXTCLOUD=false
|
||||||
|
- FEATURE_MUNIN=false
|
||||||
name: upgrade-from-upstream
|
name: upgrade-from-upstream
|
||||||
install:
|
install:
|
||||||
- sudo tests/system-setup/upgrade-from-upstream.sh
|
- sudo tests/system-setup/upgrade-from-upstream.sh
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Munin: resource monitoring tool
|
# Munin: resource monitoring tool
|
||||||
#################################################
|
#################################################
|
||||||
|
[ "${FEATURE_MUNIN:-true}" == "false" ] && return 0
|
||||||
|
|
||||||
source setup/functions.sh # load our functions
|
source setup/functions.sh # load our functions
|
||||||
source /etc/mailinabox.conf # load global vars
|
source /etc/mailinabox.conf # load global vars
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Nextcloud
|
# Nextcloud
|
||||||
##########################
|
##########################
|
||||||
|
[ "${FEATURE_NEXTCLOUD:-true}" == "false" ] && return 0
|
||||||
|
|
||||||
source setup/functions.sh # load our functions
|
source setup/functions.sh # load our functions
|
||||||
source /etc/mailinabox.conf # load global vars
|
source /etc/mailinabox.conf # load global vars
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# requirements:
|
# requirements:
|
||||||
# system packages: [ curl ]
|
# system packages: [ curl ]
|
||||||
# lib scripts: [ color-output.sh ]
|
# lib scripts: [ system.sh, color-output.sh ]
|
||||||
#
|
#
|
||||||
|
|
||||||
rest_urlencoded() {
|
rest_urlencoded() {
|
||||||
@ -26,8 +26,7 @@ rest_urlencoded() {
|
|||||||
# 1 curl returned with non-zero code that indicates and error
|
# 1 curl returned with non-zero code that indicates and error
|
||||||
# 2 the response status was <200 or >= 300
|
# 2 the response status was <200 or >= 300
|
||||||
#
|
#
|
||||||
# Messages, errors, and output are all sent to stderr, there is no
|
# Messages and errors are sent to stderr
|
||||||
# stdout output
|
|
||||||
#
|
#
|
||||||
local verb="$1" # eg "POST"
|
local verb="$1" # eg "POST"
|
||||||
local uri="$2" # eg "/mail/users/add"
|
local uri="$2" # eg "/mail/users/add"
|
||||||
@ -36,12 +35,14 @@ rest_urlencoded() {
|
|||||||
shift; shift; shift; shift # remaining arguments are data or curl args
|
shift; shift; shift; shift # remaining arguments are data or curl args
|
||||||
|
|
||||||
local url
|
local url
|
||||||
|
local is_local="false"
|
||||||
case "$uri" in
|
case "$uri" in
|
||||||
http:* | https:* )
|
http:* | https:* )
|
||||||
url="$uri"
|
url="$uri"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
url="https://$PRIMARY_HOSTNAME${uri}"
|
url="https://$PRIMARY_HOSTNAME${uri}"
|
||||||
|
is_local="true"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -98,6 +99,9 @@ rest_urlencoded() {
|
|||||||
if [ $REST_HTTP_CODE -lt 200 -o $REST_HTTP_CODE -ge 300 ]; then
|
if [ $REST_HTTP_CODE -lt 200 -o $REST_HTTP_CODE -ge 300 ]; then
|
||||||
REST_ERROR="REST status $REST_HTTP_CODE: $REST_OUTPUT"
|
REST_ERROR="REST status $REST_HTTP_CODE: $REST_OUTPUT"
|
||||||
echo "${F_DANGER}$REST_ERROR${F_RESET}" 1>&2
|
echo "${F_DANGER}$REST_ERROR${F_RESET}" 1>&2
|
||||||
|
if $is_local && [ $REST_HTTP_CODE -ge 500 ]; then
|
||||||
|
tail -100 /var/log/syslog
|
||||||
|
fi
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
echo "CURL succeded, HTTP status $REST_HTTP_CODE" 1>&2
|
echo "CURL succeded, HTTP status $REST_HTTP_CODE" 1>&2
|
||||||
|
@ -45,7 +45,7 @@ mgmt_rest() {
|
|||||||
shift; shift; # remaining arguments are data
|
shift; shift; # remaining arguments are data
|
||||||
|
|
||||||
# call function from lib/rest.sh
|
# call function from lib/rest.sh
|
||||||
rest_urlencoded "$verb" "$uri" "${MGMT_ADMIN_EMAIL}" "${MGMT_ADMIN_PW}" "$@" 2>>$TEST_OF
|
rest_urlencoded "$verb" "$uri" "${MGMT_ADMIN_EMAIL}" "${MGMT_ADMIN_PW}" "$@" >>$TEST_OF 2>&1
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,13 +142,17 @@ after_miab_install() {
|
|||||||
|
|
||||||
# install and enable Nextcloud apps
|
# install and enable Nextcloud apps
|
||||||
H2 "docker: install Nextcloud calendar app"
|
H2 "docker: install Nextcloud calendar app"
|
||||||
docker exec -u www-data NC ./occ app:install calendar \
|
if ! docker exec -u www-data NC ./occ app:install calendar
|
||||||
|| $container_started \
|
then
|
||||||
&& die "docker: installing calendar app failed ($?)"
|
$container_started || die "docker: installing calendar app failed"
|
||||||
|
fi
|
||||||
|
|
||||||
H2 "docker: install Nextcloud contacts app"
|
H2 "docker: install Nextcloud contacts app"
|
||||||
docker exec -u www-data NC ./occ app:install contacts \
|
if ! docker exec -u www-data NC ./occ app:install contacts
|
||||||
|| $container_started \
|
then
|
||||||
&& die "docker: installing contacts app failed ($?)"
|
$container_started || die "docker: installing contacts app failed"
|
||||||
|
fi
|
||||||
|
|
||||||
H2 "docker: enable user_ldap"
|
H2 "docker: enable user_ldap"
|
||||||
docker exec -u www-data NC ./occ app:enable user_ldap \
|
docker exec -u www-data NC ./occ app:enable user_ldap \
|
||||||
|| die "docker: enabling user_ldap failed ($?)"
|
|| die "docker: enabling user_ldap failed ($?)"
|
||||||
|
@ -51,7 +51,7 @@ upstream_install() {
|
|||||||
rm -rf "$upstream_dir"
|
rm -rf "$upstream_dir"
|
||||||
die "git clone upstream failed!"
|
die "git clone upstream failed!"
|
||||||
fi
|
fi
|
||||||
if [ -z "$TAG" ]; then
|
if [ -z "$UPSTREAM_TAG" ]; then
|
||||||
tag_from_readme "$upstream_dir/README.md"
|
tag_from_readme "$upstream_dir/README.md"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
rm -rf "$upstream_dir"
|
rm -rf "$upstream_dir"
|
||||||
@ -61,9 +61,9 @@ upstream_install() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
pushd "$upstream_dir" >/dev/null
|
pushd "$upstream_dir" >/dev/null
|
||||||
if [ ! -z "$TAG" ]; then
|
if [ ! -z "$UPSTREAM_TAG" ]; then
|
||||||
H2 "Checkout $TAG"
|
H2 "Checkout $UPSTREAM_TAG"
|
||||||
git checkout "$TAG" || die "git checkout $TAG failed"
|
git checkout "$UPSTREAM_TAG" || die "git checkout $UPSTREAM_TAG failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
H2 "Run upstream setup"
|
H2 "Run upstream setup"
|
||||||
@ -93,7 +93,7 @@ add_data() {
|
|||||||
#
|
#
|
||||||
local current_users=() current_aliases=()
|
local current_users=() current_aliases=()
|
||||||
local user alias
|
local user alias
|
||||||
if ! rest_urlencoded GET /admin/mail/users "$EMAIL_ADDR" "$EMAIL_PW" --insecure 2>/dev/null; then
|
if ! rest_urlencoded GET /admin/mail/users "$EMAIL_ADDR" "$EMAIL_PW" --insecure >/dev/null 2>&1; then
|
||||||
die "Unable to enumerate users: rc=$? err=$REST_ERROR"
|
die "Unable to enumerate users: rc=$? err=$REST_ERROR"
|
||||||
fi
|
fi
|
||||||
for user in $REST_OUTPUT; do
|
for user in $REST_OUTPUT; do
|
||||||
@ -132,7 +132,7 @@ add_data() {
|
|||||||
echo "Not adding alias $alias: already exists"
|
echo "Not adding alias $alias: already exists"
|
||||||
|
|
||||||
elif ! rest_urlencoded POST /admin/mail/aliases/add "$EMAIL_ADDR" "$EMAIL_PW" --insecure -- "address=$alias" "forwards_to=$forwards_to" 2>/dev/null
|
elif ! rest_urlencoded POST /admin/mail/aliases/add "$EMAIL_ADDR" "$EMAIL_PW" --insecure -- "address=$alias" "forwards_to=$forwards_to" 2>/dev/null
|
||||||
then
|
then
|
||||||
die "Unable to add alias $alias: rc=$? err=$REST_ERROR"
|
die "Unable to add alias $alias: rc=$? err=$REST_ERROR"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -144,7 +144,7 @@ capture_state() {
|
|||||||
# tls certificates: expected CN's
|
# tls certificates: expected CN's
|
||||||
|
|
||||||
local state_dir="$1"
|
local state_dir="$1"
|
||||||
local infojson="$state_dir/info.json"
|
local info="$state_dir/info.txt"
|
||||||
|
|
||||||
H1 "Capture server state to $state_dir"
|
H1 "Capture server state to $state_dir"
|
||||||
|
|
||||||
@ -153,9 +153,9 @@ capture_state() {
|
|||||||
mkdir -p "$state_dir"
|
mkdir -p "$state_dir"
|
||||||
|
|
||||||
# create info.json
|
# create info.json
|
||||||
H2 "create info.json"
|
H2 "create info.txt"
|
||||||
echo "VERSION='$(git describe --abbrev=0)'" >"$infojson"
|
echo "VERSION='$(git describe --abbrev=0)'" >"$info"
|
||||||
echo "MIGRATION_VERSION=$(cat "$STORAGE_ROOT/mailinabox.version")" >>"$infojson"
|
echo "MIGRATION_VERSION=$(cat "$STORAGE_ROOT/mailinabox.version")" >>"$info"
|
||||||
|
|
||||||
# record users
|
# record users
|
||||||
H2 "record users"
|
H2 "record users"
|
||||||
@ -173,10 +173,9 @@ capture_state() {
|
|||||||
H2 "record dns details"
|
H2 "record dns details"
|
||||||
local file
|
local file
|
||||||
mkdir -p "$state_dir/zones"
|
mkdir -p "$state_dir/zones"
|
||||||
for file in ls /etc/nsd/zones/*.signed; do
|
for file in /etc/nsd/zones/*.signed; do
|
||||||
cp "$file" "$state_dir/zones"
|
cp "$file" "$state_dir/zones"
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
miab_ldap_install() {
|
miab_ldap_install() {
|
||||||
@ -217,33 +216,46 @@ compare_state() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
H2 "DNS - zones missing"
|
H2 "DNS - zones missing"
|
||||||
local zone
|
local zone count=0
|
||||||
for zone in $(cd "$s1/zones"; ls *.signed); do
|
for zone in $(cd "$s1/zones"; ls *.signed); do
|
||||||
if [ ! -e "$s2/zones/$zone" ]; then
|
if [ ! -e "$s2/zones/$zone" ]; then
|
||||||
echo "MISSING zone: $zone"
|
echo "MISSING zone: $zone"
|
||||||
changed="true"
|
changed="true"
|
||||||
|
let count+=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
echo "$count missing"
|
||||||
|
|
||||||
H2 "DNS - zones added"
|
H2 "DNS - zones added"
|
||||||
|
count=0
|
||||||
for zone in $(cd "$s2/zones"; ls *.signed); do
|
for zone in $(cd "$s2/zones"; ls *.signed); do
|
||||||
if [ ! -e "$s2/zones/$zone" ]; then
|
if [ ! -e "$s2/zones/$zone" ]; then
|
||||||
echo "ADDED zone: $zone"
|
echo "ADDED zone: $zone"
|
||||||
changed="true"
|
changed="true"
|
||||||
|
let count+=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
echo "$count added"
|
||||||
|
|
||||||
H2 "DNS - zones changed"
|
H2 "DNS - zones changed"
|
||||||
|
count=0
|
||||||
for zone in $(cd "$s1/zones"; ls *.signed); do
|
for zone in $(cd "$s1/zones"; ls *.signed); do
|
||||||
if [ -e "$s2/zones/$zone" ]; then
|
if [ -e "$s2/zones/$zone" ]; then
|
||||||
output="$(diff "$s1/zones/$zone" "$s2/zones/$zone" 2>&1)"
|
# all the signatures change if we're using self-signed certs
|
||||||
|
local t1="/tmp/s1.$$.txt"
|
||||||
|
local t2="/tmp/s2.$$.txt"
|
||||||
|
awk '$4 == "RRSIG" || $4 == "NSEC3" { next; } $4 == "SOA" { print $1" "$2" "$3" "$4" "$5" "$6" "$8" "$9" "$10" "$11" "$12; next } { print $0 }' "$s1/zones/$zone" > "$t1"
|
||||||
|
awk '$4 == "RRSIG" || $4 == "NSEC3" { next; } $4 == "SOA" { print $1" "$2" "$3" "$4" "$5" "$6" "$8" "$9" "$10" "$11" "$12; next } { print $0 }' "$s2/zones/$zone" > "$t2"
|
||||||
|
output="$(diff "$t1" "$t2" 2>&1)"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "CHANGED zone: $zone"
|
echo "CHANGED zone: $zone"
|
||||||
echo "$output"
|
echo "$output"
|
||||||
changed="true"
|
changed="true"
|
||||||
|
let count+=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
echo "$count zone files had differences"
|
||||||
|
|
||||||
if $changed; then
|
if $changed; then
|
||||||
return 1
|
return 1
|
||||||
@ -253,12 +265,17 @@ compare_state() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if [ "$1" == "c" ]; then
|
|
||||||
|
if [ "$1" == "cap" ]; then
|
||||||
capture_state "tests/system-setup/state/miab-ldap"
|
capture_state "tests/system-setup/state/miab-ldap"
|
||||||
exit $?
|
exit $?
|
||||||
|
elif [ "$1" == "compare" ]; then
|
||||||
|
compare_state "tests/system-setup/state/upstream" "tests/system-setup/state/miab-ldap"
|
||||||
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# install basic stuff, set the hostname, time, etc
|
# install basic stuff, set the hostname, time, etc
|
||||||
before_install
|
before_install
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user