Skip to content

Commit

Permalink
build: trap and curl installer fixes
Browse files Browse the repository at this point in the history
Signed-off-by: nachoparker <nacho@ownyourbits.com>
  • Loading branch information
nachoparker committed Jul 25, 2021
1 parent effdd6c commit c94b3b5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
8 changes: 1 addition & 7 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,11 @@ Vagrant.configure("2") do |config|
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git
# indicate that this will be an image build
touch /.ncp-image
# install
git clone -b "$BRANCH" https://github.com/nextcloud/nextcloudpi.git /tmp/nextcloudpi
cd /tmp/nextcloudpi
# uncomment to install devel
#sed -i 's|^BRANCH=master|BRANCH=devel|' install.sh ncp.sh
bash install.sh
source install.sh
# cleanup
source etc/library.sh
Expand Down
4 changes: 2 additions & 2 deletions bin/ncp-update
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[[ "$BRANCH" != "master" ]] && echo "INFO: updating to development branch '$BRANCH'"

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

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

echo -e "Performing updates"
./update.sh || exit 1
./update.sh || exit $?

cd "$TMPDIR"
VER=$( git describe --always --tags | grep -oP "v\d+\.\d+\.\d+" )
Expand Down
21 changes: 10 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#
# more details at https://ownyourbits.com

BRANCH=master
#DBG=x
BRANCH="${BRANCH:-master}"
DBG=x

set -e$DBG

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

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

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

# indicate that this will be an image build
touch /.ncp-image

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

popd
cd -
rm -rf "${TMPDIR}"

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

exit 0

# License
#
# This script is free software; you can redistribute it and/or modify it
Expand Down
2 changes: 1 addition & 1 deletion ncp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ EOF
chmod g+w /var/run/.ncp-latest-version

# Install all ncp-apps
bin/ncp-update $BRANCH || exit 1
bin/ncp-update $BRANCH || exit $?

# LIMIT LOG SIZE
grep -q maxsize /etc/logrotate.d/apache2 || sed -i /weekly/amaxsize2M /etc/logrotate.d/apache2
Expand Down
2 changes: 1 addition & 1 deletion post-inst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ configure()
find /var/log -type f -exec rm {} \;

# clean build flags
rm /.ncp-image
rm -f /.ncp-image
}

# License
Expand Down
5 changes: 4 additions & 1 deletion run_update_history.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ if is_more_recent_than "$latest_checkpoint_version" "$current_version" ; then
for(( i="$starting_checkpoint"; i<="$end_of_list"; i++)); do
update_file=${updates_list[$i]}
tag_update=$( basename "$update_file" .sh )
bash "$updates_dir/$update_file" || exit 1
bash "$updates_dir/$update_file" || {
echo "Error while applying update $(basename "$update_file" .sh). Exiting..."
exit 1
}
echo "v$tag_update" > /usr/local/etc/ncp-version
[[ $i != $end_of_list ]] && echo -e "NextCloudPi updated to version v$tag_update" || true
done
Expand Down

0 comments on commit c94b3b5

Please sign in to comment.