diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/vyos/apt-install.sh | 16 | ||||
-rw-r--r-- | scripts/vyos/apt-repo-debian.sh | 33 | ||||
-rw-r--r-- | scripts/vyos/apt-repo-vyos.sh | 33 | ||||
-rw-r--r-- | scripts/vyos/cloud-init-debian.sh | 23 | ||||
-rw-r--r-- | scripts/vyos/cloud-init-vyos.sh | 23 | ||||
-rw-r--r-- | scripts/vyos/init.sh | 11 | ||||
-rw-r--r-- | scripts/vyos/platform-qemu.sh | 13 | ||||
-rw-r--r-- | scripts/vyos/vyos-install-post.sh | 10 | ||||
-rw-r--r-- | scripts/vyos/vyos-install-pre.sh | 56 | ||||
-rw-r--r-- | scripts/vyos/vyos-install.sh | 19 |
10 files changed, 237 insertions, 0 deletions
diff --git a/scripts/vyos/apt-install.sh b/scripts/vyos/apt-install.sh new file mode 100644 index 0000000..0e47bce --- /dev/null +++ b/scripts/vyos/apt-install.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e +set -x + +export DEBIAN_FRONTEND=noninteractive + +# install missing vyos features, you can comment it if not needed +apt install -y \ + vim \ + net-tools + +# install packer-vyos requirements (it will be removed at cleanup.sh) +apt install -y \ + python3-pexpect \ + expect diff --git a/scripts/vyos/apt-repo-debian.sh b/scripts/vyos/apt-repo-debian.sh new file mode 100644 index 0000000..be360fb --- /dev/null +++ b/scripts/vyos/apt-repo-debian.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e +set -x + +if [[ "${CLOUD_INIT}" != "debian" ]]; then + echo "$0 - info: cloud_init not debian, skipping" + exit 0 +fi + +# set debian list according VYOS_VERSION_MAIN +if [[ "$VYOS_RELEASE" == "equuleus" ]]; then + debian_list_url="http://${PACKER_HTTP_IP}:${PACKER_HTTP_PORT}/debian_11.list" +elif [[ "$VYOS_RELEASE" == "current" || "$VYOS_RELEASE" == "sagitta" || "$VYOS_RELEASE" == "circinus" ]]; then + debian_list_url="http://${PACKER_HTTP_IP}:${PACKER_HTTP_PORT}/debian_12.list" +else + echo "vyos version unsupported, get github repo, fork and send a pull request" + exit 1 +fi + +tmp_file=$(mktemp) + +wget -O "$tmp_file" "$debian_list_url" || { echo "cant download debian.list from packer http repo"; exit 1; } + +mv "$tmp_file" /etc/apt/sources.list.d/debian.list + +apt update + + +#sudo bash -c 'echo "deb http://deb.debian.org/debian buster main contrib non-free" > /etc/apt/sources.list.d/debian.list' +#sudo bash -c 'echo "deb-src http://deb.debian.org/debian buster main contrib non-free" >> /etc/apt/sources.list.d/debian.list' +#sudo bash -c 'echo "deb http://security.debian.org/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list.d/debian.list' +#sudo bash -c 'echo "deb-src http://security.debian.org/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list.d/debian.list' diff --git a/scripts/vyos/apt-repo-vyos.sh b/scripts/vyos/apt-repo-vyos.sh new file mode 100644 index 0000000..db7d58a --- /dev/null +++ b/scripts/vyos/apt-repo-vyos.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e +set -x + +if [[ "${CLOUD_INIT}" != "vyos" ]]; then + echo "$0 - info: cloud_init not vyos, skipping" + exit 0 +fi + +# set debian list according VYOS_VERSION_MAIN +if [[ "$VYOS_RELEASE" == "equuleus" ]]; then + debian_list_url="http://${PACKER_HTTP_IP}:${PACKER_HTTP_PORT}/debian_11-vyos.list" +elif [[ "$VYOS_RELEASE" == "current" || "$VYOS_RELEASE" == "sagitta" || "$VYOS_RELEASE" == "circinus" ]]; then + debian_list_url="http://${PACKER_HTTP_IP}:${PACKER_HTTP_PORT}/debian_12-vyos.list" +else + echo "vyos version unsupported, get github repo, fork and send a pull request" + exit 1 +fi + +tmp_file=$(mktemp) + +wget -O "$tmp_file" "$debian_list_url" || { echo "cant download debian.list from packer http repo"; exit 1; } + +mv "$tmp_file" /etc/apt/sources.list.d/debian.list + +apt update + + +#sudo bash -c 'echo "deb http://deb.debian.org/debian buster main contrib non-free" > /etc/apt/sources.list.d/debian.list' +#sudo bash -c 'echo "deb-src http://deb.debian.org/debian buster main contrib non-free" >> /etc/apt/sources.list.d/debian.list' +#sudo bash -c 'echo "deb http://security.debian.org/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list.d/debian.list' +#sudo bash -c 'echo "deb-src http://security.debian.org/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list.d/debian.list' diff --git a/scripts/vyos/cloud-init-debian.sh b/scripts/vyos/cloud-init-debian.sh new file mode 100644 index 0000000..2cf398f --- /dev/null +++ b/scripts/vyos/cloud-init-debian.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e +set -x + +if [[ "${CLOUD_INIT}" != "debian" ]]; then + echo "$0 - info: cloud_init not debian, skipping" + exit 0 +fi + +export DEBIAN_FRONTEND=noninteractive + +apt purge -y \ + cloud-init \ + cloud-utils \ + ifupdown + +apt install -y \ + cloud-init \ + cloud-utils \ + ifupdown + +systemctl enable cloud-init diff --git a/scripts/vyos/cloud-init-vyos.sh b/scripts/vyos/cloud-init-vyos.sh new file mode 100644 index 0000000..92be545 --- /dev/null +++ b/scripts/vyos/cloud-init-vyos.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e +set -x + +if [[ "${CLOUD_INIT}" != "vyos" ]]; then + echo "$0 - info: cloud_init not vyos, skipping" + exit 0 +fi + +export DEBIAN_FRONTEND=noninteractive + +apt purge -y \ + cloud-init \ + cloud-utils \ + ifupdown + +apt install -t "$VYOS_RELEASE" --force-yes -y \ + cloud-init \ + cloud-utils \ + ifupdown + +systemctl enable cloud-init diff --git a/scripts/vyos/init.sh b/scripts/vyos/init.sh new file mode 100644 index 0000000..7f0db84 --- /dev/null +++ b/scripts/vyos/init.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e +set -x + +# configure machine-id +dbus-uuidgen > /etc/machine-id +ln -fs /etc/machine-id /var/lib/dbus/machine-id + +# disable logs +systemctl stop rsyslog diff --git a/scripts/vyos/platform-qemu.sh b/scripts/vyos/platform-qemu.sh new file mode 100644 index 0000000..d4049fa --- /dev/null +++ b/scripts/vyos/platform-qemu.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e +set -x + +if [[ "${PLATFORM}" != "qemu" ]]; then + echo "$0 - info: platform not qemu, skipping" + exit 0 +fi + +export DEBIAN_FRONTEND=noninteractive +apt install -y \ + qemu-guest-agent diff --git a/scripts/vyos/vyos-install-post.sh b/scripts/vyos/vyos-install-post.sh new file mode 100644 index 0000000..15b723e --- /dev/null +++ b/scripts/vyos/vyos-install-post.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e +set -x + +# removing temp scripts +#rm -f /root/answers.expect +rm -f /root/install-image.py + +#sleep 1000
\ No newline at end of file diff --git a/scripts/vyos/vyos-install-pre.sh b/scripts/vyos/vyos-install-pre.sh new file mode 100644 index 0000000..c61905d --- /dev/null +++ b/scripts/vyos/vyos-install-pre.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +set -e +set -x + +export DEBIAN_FRONTEND=noninteractive + +# delete interfaces ethernet eth0 address +# delete interfaces ethernet eth0 hw-id +# delete system name-server + +cat <<EOF > /home/vyos/cleanup-vyos.sh +#!/bin/vbash +source /opt/vyatta/etc/functions/script-template +configure +set system host-name host-name 'test' +commit +save +exit +EOF +chmod 0700 /home/vyos/cleanup-vyos.sh +chown vyos:users /home/vyos/cleanup-vyos.sh +su - vyos -c "/home/vyos/cleanup-vyos.sh" + +# reconfiguring ssh +rm -f /etc/ssh/ssh_host_* +dpkg-reconfigure openssh-server + +# those packages can't be removed since they are needed for next script vyos-install.sh +# apt remove -y \ +# python3-pexpect \ +# expect + +# cleanup apt +rm -f /etc/apt/sources.list.d/debian.list +apt -y autoremove --purge +apt-get clean + +# cleanup machine-id +truncate -s 0 /etc/machine-id + +# removing /tmp files +rm -rf /tmp/* + +# removing log files +rm -rf /var/log/* + +# removing history +export HISTFILE=0 +rm -f /home/vyos/.bash_history +rm -f /root/.bash_history + +# removing disk data +dd if=/dev/zero of=/EMPTY bs=1M || : +rm -f /EMPTY +sync diff --git a/scripts/vyos/vyos-install.sh b/scripts/vyos/vyos-install.sh new file mode 100644 index 0000000..aa23064 --- /dev/null +++ b/scripts/vyos/vyos-install.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e +set -x + +# answers_url=http://${PACKER_HTTP_IP}:${PACKER_HTTP_PORT}/answers.expect +# install_url=http://${PACKER_HTTP_IP}:${PACKER_HTTP_PORT}/install-image.vsh +install_url=http://${PACKER_HTTP_IP}:${PACKER_HTTP_PORT}/install-image.py + +# touch /root/answers.expect +# chmod 0600 /root/answers.expect +# wget $answers_url -O /root/answers.expect + +touch /root/install-image.py +chmod 0700 /root/install-image.py +wget $install_url -O /root/install-image.py + +python3 /root/install-image.py + |