Skip to content

Commit

Permalink
install.sh: Fix ncp-provisioning not being executed on baremetal install
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Knöppler <[email protected]>
  • Loading branch information
theCalcaholic committed Oct 30, 2023
1 parent 61ba6a6 commit fa793b3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/vm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ jobs:
setup-ssh-port-forwarding "$SERVER_ADDRESS"
echo "Run integration tests"
set -x
ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" "root@${SERVER_ADDRESS}" cat /usr/local/etc/instance.cfg
set +x
test-ncp-instance -a -f "$SNAPSHOT_ID" -b "${VERSION}" "root@${SERVER_ADDRESS}" "localhost" "8443" "9443" || {
echo "Integration tests failed"
Expand Down
3 changes: 2 additions & 1 deletion bin/ncp-provisioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# this script runs at startup to provide an unique random passwords for each instance

source /usr/local/etc/library.sh

set -x
## redis provisioning

CFG=/var/www/nextcloud/config/config.php
Expand Down Expand Up @@ -79,6 +79,7 @@ fi
"cohorteId": ${cohorte_id}
}
EOF
cat /usr/local/etc/instance.cfg
}


Expand Down
8 changes: 5 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ apt-get install --no-install-recommends -y git ca-certificates sudo lsb-release
# get install code
if [[ "${CODE_DIR}" == "" ]]; then
echo "Getting build code..."
CODE_DIR="${TEMPDIR}"/nextcloudpi
git clone -b "${BRANCH}" https://github.com/nextcloud/nextcloudpi.git "${CODE_DIR}"
CODE_DIR_TMP="${TEMPDIR}"/nextcloudpi
git clone -b "${BRANCH}" https://github.com/nextcloud/nextcloudpi.git "${CODE_DIR_TMP}"
cd "$CODE_DIR_TMP"
else
cd "${CODE_DIR}"
fi
cd "${CODE_DIR}"

# install NCP
echo -e "\nInstalling NextCloudPi..."
Expand Down
17 changes: 12 additions & 5 deletions tests/system_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
More at https://ownyourbits.com
"""
import json
import subprocess

pre_cmd = []

Expand Down Expand Up @@ -192,11 +193,17 @@ def handle_error(r: CompletedProcess) -> CompletedProcess:
r.stderr.decode('utf-8') if r.stderr else '')

def set_cohorte_id(cohorte_id: int) -> CompletedProcess:
r = handle_error(run(pre_cmd + ['cat', '/usr/local/etc/instance.cfg'], stdout=PIPE, stderr=PIPE))
proc = subprocess.Popen(pre_cmd + ['cat', '/usr/local/etc/instance.cfg'], stdout=subprocess.PIPE, shell=False)
#handle_error(run(pre_cmd + ['cat', '/usr/local/etc/instance.cfg'], stdout=subprocess.STDOUT, stderr=subprocess.STDOUT))
#r = handle_error(run(pre_cmd + ['cat', '/usr/local/etc/instance.cfg'], stdout=PIPE, stderr=PIPE))
(out, err) = proc.communicate()
if proc.returncode != 0:
raise ProcessExecutionException()
try:
instance_cfg = json.loads(r.stdout)
instance_cfg = json.loads(out)
except json.decoder.JSONDecodeError as e:
print(f"{tc.red}error{tc.normal} instance.cfg could not be parsed, was: {r.stdout}")
print(f"{tc.red}error{tc.normal} /usr/local/etc/instance.cfg could not be parsed, was: {out}\n{err}")
print(f"Command: '{' '.join(pre_cmd + ['cat', '/usr/local/etc/instance.cfg'])}'")
raise e

instance_cfg['cohorteId'] = cohorte_id
Expand All @@ -209,7 +216,7 @@ def set_cohorte_id(cohorte_id: int) -> CompletedProcess:
print(f"{tc.yellow}skipped{tc.normal} (already updated to v99.99.99)")
return True
handle_error(run(pre_cmd + ['rm', '-f', '/var/run/.ncp-latest-version']))
result = handle_error(run(pre_cmd + ['sed', '-i', 's|BRANCH="master"|BRANCH="testing/staged-rollouts-1"|', '/usr/local/bin/ncp-check-version'], stdout=PIPE, stderr=PIPE))
handle_error(run(pre_cmd + ['sed', '-i', 's|BRANCH="master"|BRANCH="testing/staged-rollouts-1"|', '/usr/local/bin/ncp-check-version'], stdout=PIPE, stderr=PIPE))
set_cohorte_id(1)
result = run(pre_cmd + ['test', '-f', '/var/run/.ncp-latest-version'], stdout=PIPE, stderr=PIPE)
if result.returncode == 0:
Expand Down Expand Up @@ -323,7 +330,7 @@ def set_cohorte_id(cohorte_id: int) -> CompletedProcess:
tc.yellow + ssh_cmd + tc.normal + "...")
binaries_must_be_installed = binaries_must_be_installed + binaries_no_docker
pre_cmd = ['ssh', '-o UserKnownHostsFile=/dev/null' , '-o PasswordAuthentication=no',
'-o StrictHostKeyChecking=no', '-o ConnectTimeout=1', ssh_cmd[4:]]
'-o StrictHostKeyChecking=no', '-o ConnectTimeout=10', ssh_cmd[4:]]

if not skip_ping:
at_char = ssh_cmd.index('@')
Expand Down

0 comments on commit fa793b3

Please sign in to comment.