Skip to content

Commit c94b3b5

Browse files
committed
build: trap and curl installer fixes
Signed-off-by: nachoparker <[email protected]>
1 parent effdd6c commit c94b3b5

File tree

6 files changed

+19
-23
lines changed

6 files changed

+19
-23
lines changed

Vagrantfile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,11 @@ Vagrant.configure("2") do |config|
2828
apt-get update
2929
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git
3030
31-
# indicate that this will be an image build
32-
touch /.ncp-image
33-
3431
# install
3532
git clone -b "$BRANCH" https://github.com/nextcloud/nextcloudpi.git /tmp/nextcloudpi
3633
cd /tmp/nextcloudpi
3734
38-
# uncomment to install devel
39-
#sed -i 's|^BRANCH=master|BRANCH=devel|' install.sh ncp.sh
40-
41-
bash install.sh
35+
source install.sh
4236
4337
# cleanup
4438
source etc/library.sh

bin/ncp-update

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[[ "$BRANCH" != "master" ]] && echo "INFO: updating to development branch '$BRANCH'"
1010

1111
TMPDIR="$( mktemp -d /tmp/ncp-update.XXXXXX || ( echo "Failed to create temp dir. Exiting" >&2; exit 1 ) )"
12-
trap "cd /; rm -rf \"${TMPDIR}\"; exit 0" 0 1 2 3 15
12+
trap 'ret=$?; cd /; rm -rf "${TMPDIR}"; exit $ret' EXIT
1313

1414
echo -e "Downloading updates"
1515
git clone --depth 20 -b "$BRANCH" -q https://github.com/nextcloud/nextcloudpi.git "$TMPDIR" || {
@@ -20,7 +20,7 @@
2020
[[ -f /.ncp-image ]] || cd "$TMPDIR" # update locally during build
2121

2222
echo -e "Performing updates"
23-
./update.sh || exit 1
23+
./update.sh || exit $?
2424

2525
cd "$TMPDIR"
2626
VER=$( git describe --always --tags | grep -oP "v\d+\.\d+\.\d+" )

install.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#
1010
# more details at https://ownyourbits.com
1111

12-
BRANCH=master
13-
#DBG=x
12+
BRANCH="${BRANCH:-master}"
13+
DBG=x
1414

1515
set -e$DBG
1616

@@ -30,13 +30,10 @@ type mysqld &>/dev/null && echo ">>> WARNING: existing mysqld configuration wil
3030
# get install code
3131
echo "Getting build code..."
3232
apt-get update
33-
apt-get install --no-install-recommends -y wget ca-certificates sudo lsb-release
33+
apt-get install --no-install-recommends -y git ca-certificates sudo lsb-release
3434

35-
pushd "$TMPDIR"
36-
wget -qO- --content-disposition https://github.com/nextcloud/nextcloudpi/archive/"$BRANCH"/latest.tar.gz \
37-
| tar -xz \
38-
|| exit 1
39-
cd - && cd "$TMPDIR"/nextcloudpi-"$BRANCH"
35+
git clone -b "${BRANCH}" https://github.com/nextcloud/nextcloudpi.git "${TMPDIR}"/nextcloudpi
36+
cd "${TMPDIR}"/nextcloudpi
4037

4138
# install NCP
4239
echo -e "\nInstalling NextCloudPi..."
@@ -49,6 +46,8 @@ check_distro etc/ncp.cfg || {
4946
exit 1;
5047
}
5148

49+
# indicate that this will be an image build
50+
touch /.ncp-image
5251

5352
mkdir -p /usr/local/etc/ncp-config.d/
5453
cp etc/ncp-config.d/nc-nextcloud.cfg /usr/local/etc/ncp-config.d/
@@ -62,8 +61,10 @@ systemctl restart mysqld # TODO this shouldn't be necessary, but somehow it's ne
6261
install_app ncp.sh
6362
run_app_unsafe bin/ncp/CONFIG/nc-init.sh
6463
bash /usr/local/bin/ncp-provisioning.sh
64+
rm /.ncp-image
6565

66-
popd
66+
cd -
67+
rm -rf "${TMPDIR}"
6768

6869
IFACE="$( ip r | grep "default via" | awk '{ print $5 }' | head -1 )"
6970
IP="$( ip a show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 )"
@@ -79,8 +80,6 @@ first load the activation and :4443 pages. You can run letsencrypt to get rid of
7980
the warning if you have a (sub)domain available.
8081
"
8182

82-
exit 0
83-
8483
# License
8584
#
8685
# This script is free software; you can redistribute it and/or modify it

ncp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ EOF
217217
chmod g+w /var/run/.ncp-latest-version
218218

219219
# Install all ncp-apps
220-
bin/ncp-update $BRANCH || exit 1
220+
bin/ncp-update $BRANCH || exit $?
221221

222222
# LIMIT LOG SIZE
223223
grep -q maxsize /etc/logrotate.d/apache2 || sed -i /weekly/amaxsize2M /etc/logrotate.d/apache2

post-inst.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ configure()
2828
find /var/log -type f -exec rm {} \;
2929

3030
# clean build flags
31-
rm /.ncp-image
31+
rm -f /.ncp-image
3232
}
3333

3434
# License

run_update_history.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ if is_more_recent_than "$latest_checkpoint_version" "$current_version" ; then
103103
for(( i="$starting_checkpoint"; i<="$end_of_list"; i++)); do
104104
update_file=${updates_list[$i]}
105105
tag_update=$( basename "$update_file" .sh )
106-
bash "$updates_dir/$update_file" || exit 1
106+
bash "$updates_dir/$update_file" || {
107+
echo "Error while applying update $(basename "$update_file" .sh). Exiting..."
108+
exit 1
109+
}
107110
echo "v$tag_update" > /usr/local/etc/ncp-version
108111
[[ $i != $end_of_list ]] && echo -e "NextCloudPi updated to version v$tag_update" || true
109112
done

0 commit comments

Comments
 (0)