-
Notifications
You must be signed in to change notification settings - Fork 40
Moved last two needed scripts from mender-qa to buildscripts #2353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
craigcomstock
merged 4 commits into
cfengine:master
from
craigcomstock:ent-11241/master
Jul 22, 2026
+114
−4
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
577ead1
Moved create_swap_file.sh and initialize-user-data.sh from mender-qa/…
craigcomstock 7c859f0
Remove SSH port forwarding from initialization script
craigcomstock c64cd58
Tidied up initialize-user-data.sh and initialize-build-host.sh script…
craigcomstock f190b38
Fixed ci/cfengine-build-host-setup.cf for older bootstrap hosts which…
craigcomstock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/usr/bin/env bash | ||
| # bash is needed in order to use the "time" built-in and avoid needing | ||
| # an external utility. | ||
|
|
||
| set -e # exit on error | ||
|
|
||
| # Argument $1 is the size in megabytes | ||
| if [ x"$1" = x ] || echo "$1" | grep -q '[^0-9]' | ||
| then | ||
| exit 2 | ||
| fi | ||
| SIZE="$1" | ||
|
|
||
| if swapon | grep /swapfile >/dev/null; then | ||
| echo "/swapfile already configured and setup. Exiting." | ||
| exit 0 | ||
| fi | ||
|
|
||
| time dd if=/dev/zero of=/swapfile bs=1M count=$SIZE | ||
| chmod 0600 /swapfile | ||
|
|
||
| PATH=$PATH:/sbin:/usr/sbin | ||
| mkswap /swapfile | ||
| swapon /swapfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #!/bin/false | ||
|
|
||
| # This file should be sourced, not run. | ||
|
|
||
| # This script will do build slave setup, including creating credentials for the | ||
| # jenkins user, based on root's credentials (will copy its keys). The script is | ||
| # expected to be sourced early in the user-data phase after provisioning. | ||
|
|
||
| # Make sure error detection and verbose output is on, if they aren't already. | ||
| set -x -e | ||
|
|
||
| # Add jenkins user and copy credentials. | ||
| useradd -m -u 1010 jenkins || true | ||
| mkdir -p /home/jenkins/.ssh | ||
| # copy /root/.ssh/authorized_keys to /home/jenkins/.ssh, removing everything | ||
| # before 'ssh-rsa'. Some platforms have forcecommand='echo "root access disabled"' | ||
| # there. | ||
| sed 's/.*ssh-rsa/ssh-rsa/' /root/.ssh/authorized_keys >/home/jenkins/.ssh/authorized_keys || true | ||
|
|
||
| # Enable sudo access for jenkins. | ||
| echo "jenkins ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
|
||
| # Disable TTY requirement. | ||
| sed -i -e 's/^\( *Defaults *requiretty *\)$/# \1/' /etc/sudoers | ||
|
|
||
| # Copy the buildscripts repository to jenkins user. | ||
| cp -r /root/buildscripts /home/jenkins | ||
| # was copying build-artifacts-cache known host entry | ||
| #cp /root/mender-qa/data/known_hosts /home/jenkins/.ssh/known_hosts | ||
|
craigcomstock marked this conversation as resolved.
|
||
|
|
||
|
|
||
| # add authorized_keys file before chowning, so that initialize-build-host.sh can manage | ||
| touch /home/jenkins/.ssh/authorized_keys | ||
|
|
||
| # Make sure everything in jenkins' folder has right owner. | ||
| chown -R jenkins:jenkins /home/jenkins | ||
|
|
||
| groupadd -r kvm || true # In case it already exists. | ||
| usermod -a -G kvm jenkins | ||
|
|
||
| # change hostname to localhost | ||
| # it will fix sudo complaining "unable to resolve host digitalocean", | ||
| # and some tests | ||
| hostname localhost | ||
| # Ensure reverse hostname resolution is correct and 127.0.0.1 is always 'localhost'. | ||
| # There's no nice shell command to test it but this one: | ||
| # python -c 'import socket;print socket.gethostbyaddr("127.0.0.1")' | ||
| if test -f /etc/hosts; then | ||
| sed -i -e '1s/^/127.0.0.1 localhost localhost.localdomain\n/' /etc/hosts | ||
| else | ||
| echo '127.0.0.1 localhost localhost.localdomain' >/etc/hosts | ||
| fi | ||
|
|
||
| apt_get() { | ||
| # Work around apt-get not waiting for a lock if it's taken. We want to wait | ||
| # for it instead of bailing out. No good return code to check unfortunately, | ||
| # so we just have to look inside the log. | ||
|
|
||
| pid=$$ | ||
| # Maximum five minute wait (30 * 10 seconds) | ||
| attempts=30 | ||
|
|
||
| while true | ||
| do | ||
| ( /usr/bin/apt-get "$@" 2>&1 ; echo $? > /tmp/apt-get-return-code.$pid.txt ) | tee /tmp/apt-get.$pid.log | ||
| if [ $attempts -gt 0 ] && \ | ||
| [ "$(cat /tmp/apt-get-return-code.$pid.txt)" -ne 0 ] && \ | ||
| fgrep "Could not get lock" /tmp/apt-get.$pid.log > /dev/null | ||
| then | ||
| attempts=$(expr $attempts - 1 || true) | ||
| sleep 10 | ||
| else | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| ret_code=$(cat /tmp/apt-get-return-code.$pid.txt) | ||
| rm -f /tmp/apt-get-return-code.$pid.txt /tmp/apt-get.$pid.log | ||
|
|
||
| return $ret_code | ||
| } | ||
| alias apt=apt_get | ||
| alias apt-get=apt_get | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, I see why but wasnt expecting a macro for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup :)