From 69aec6bfe5481c18dc9a19993e0f592d7a93bfa8 Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Tue, 25 May 2021 14:47:24 +0200 Subject: [PATCH] Alpine packer updates - Ostinato .apk building script generalized to use it for any package - Reset terminal mode using /etc/motd --- packer/alpine-linux/files/docker-apk-build | 34 +++++++++++++++++++ .../alpine-linux/files/ostinato/build-package | 20 ----------- packer/alpine-linux/scripts/frr.sh | 6 ++-- packer/alpine-linux/scripts/ostinato.sh | 6 ++-- packer/alpine-linux/scripts/setup.sh | 6 ++-- 5 files changed, 43 insertions(+), 29 deletions(-) create mode 100755 packer/alpine-linux/files/docker-apk-build delete mode 100755 packer/alpine-linux/files/ostinato/build-package diff --git a/packer/alpine-linux/files/docker-apk-build b/packer/alpine-linux/files/docker-apk-build new file mode 100755 index 0000000..7ce24bf --- /dev/null +++ b/packer/alpine-linux/files/docker-apk-build @@ -0,0 +1,34 @@ +#!/bin/sh + +package=$1 +version=$2 +if [ -z "$package" ]; then + echo "Usage: docker-apk-build []" >&2 + exit 1 +fi +[ -z "$version" ] && version="latest" + +mkdir -p "$package" +docker run --rm -i -v "$PWD/$package:/package" -e "package=$package" alpine:$version << 'EOF' +apk add alpine-sdk + +adduser -D builder +addgroup builder abuild +mkdir -p /var/cache/distfiles + +su - builder << END_OF_SU +mkdir -p .abuild +echo 'PACKAGER="GNS3 Packer "' > .abuild/abuild.conf +abuild-keygen -a -n -q + +git clone --depth 1 git://git.alpinelinux.org/aports +cd aports/*/"$package" +abuild -r +END_OF_SU + +alpine_version=$(cat /etc/alpine-release) +alpine_version=${alpine_version%.*} +mkdir -p "/package/${alpine_version}" +cp -p /home/builder/packages/*/*/*.apk "/package/${alpine_version}" +chown -R $(stat -c '%u:%g' /package) "/package/${alpine_version}" +EOF diff --git a/packer/alpine-linux/files/ostinato/build-package b/packer/alpine-linux/files/ostinato/build-package deleted file mode 100755 index 86f9bad..0000000 --- a/packer/alpine-linux/files/ostinato/build-package +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -alpine_version=3.12 - -mkdir -p "$alpine_version" -docker run --rm -i -v "$PWD/$alpine_version:/package" alpine:$alpine_version << 'EOF' -cd -apk add alpine-sdk -mkdir -p .abuild -echo 'PACKAGER="GNS3 Packer "' > .abuild/abuild.conf -abuild-keygen -a -n -q - -git clone --depth 1 git://git.alpinelinux.org/aports -cd aports/*/ostinato -abuild -F -r -cd - -cp -p packages/*/*/*.apk /package -chown $(stat -c '%u:%g' /package) /package/* -EOF diff --git a/packer/alpine-linux/scripts/frr.sh b/packer/alpine-linux/scripts/frr.sh index 8b6ba6d..91b1a68 100644 --- a/packer/alpine-linux/scripts/frr.sh +++ b/packer/alpine-linux/scripts/frr.sh @@ -42,13 +42,13 @@ sed -i -E '/zebra|bgp|ospf|rip|isis|pim|ldp|eigrp|static|bfd/ s/= *no/=yes/' /et echo "service integrated-vtysh-config" > /etc/frr/vtysh.conf chown frr:frr /etc/frr/vtysh.conf +# reset terminal modes +sed -i "$(printf '1i\e[?5l\e[?7h\e[?8h')" /etc/motd + # run vtysh in .profile cat > /root/.profile << 'EOF' # ~/.profile: executed by Bourne-compatible login shells. -# reset terminal modes -[ -t 1 ] && printf '\e[?5l\e[?7h\e[?8h' - if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc diff --git a/packer/alpine-linux/scripts/ostinato.sh b/packer/alpine-linux/scripts/ostinato.sh index 7ef77e6..d1e52eb 100644 --- a/packer/alpine-linux/scripts/ostinato.sh +++ b/packer/alpine-linux/scripts/ostinato.sh @@ -40,13 +40,13 @@ setcap cap_net_admin,cap_net_raw=eip /usr/bin/drone addgroup user ostinato addgroup user wireshark +# reset terminal modes +sed -i "$(printf '1i\e[?5l\e[?7h\e[?8h')" /etc/motd + # create .profile cat > /root/.profile << 'EOF' # ~/.profile: executed by Bourne-compatible login shells. -# reset terminal modes -[ -t 1 ] && printf '\e[?5l\e[?7h\e[?8h' - if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc diff --git a/packer/alpine-linux/scripts/setup.sh b/packer/alpine-linux/scripts/setup.sh index 015ea07..7b42840 100644 --- a/packer/alpine-linux/scripts/setup.sh +++ b/packer/alpine-linux/scripts/setup.sh @@ -1,13 +1,13 @@ # install additional packages apk add nano busybox-extras +# reset terminal modes +sed -i "$(printf '1i\e[?5l\e[?7h\e[?8h')" /etc/motd + # create .profile cat > /root/.profile << 'EOF' # ~/.profile: executed by Bourne-compatible login shells. -# reset terminal modes -[ -t 1 ] && printf '\e[?5l\e[?7h\e[?8h' - if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc