summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/vyos/apt-install.sh12
-rw-r--r--scripts/vyos/apt-repo-debian.sh33
-rw-r--r--scripts/vyos/apt-repo-vyos.sh33
-rw-r--r--scripts/vyos/cleanup-vyos-configure.sh31
-rw-r--r--scripts/vyos/cleanup.sh39
-rw-r--r--scripts/vyos/cloud-init-datasource.sh17
-rw-r--r--scripts/vyos/cloud-init-debian.sh29
-rw-r--r--scripts/vyos/cloud-init-vyos.sh34
-rw-r--r--scripts/vyos/configure.sh24
-rw-r--r--scripts/vyos/grub-serial.sh25
-rw-r--r--scripts/vyos/init.sh12
-rw-r--r--scripts/vyos/osprep.sh14
-rw-r--r--scripts/vyos/platform-qemu.sh13
-rw-r--r--scripts/vyos/vyos-install-expect.sh19
-rw-r--r--scripts/vyos/vyos-install-post.sh10
15 files changed, 345 insertions, 0 deletions
diff --git a/scripts/vyos/apt-install.sh b/scripts/vyos/apt-install.sh
new file mode 100644
index 0000000..22f28dc
--- /dev/null
+++ b/scripts/vyos/apt-install.sh
@@ -0,0 +1,12 @@
+#!/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
+
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/cleanup-vyos-configure.sh b/scripts/vyos/cleanup-vyos-configure.sh
new file mode 100644
index 0000000..26f3bfd
--- /dev/null
+++ b/scripts/vyos/cleanup-vyos-configure.sh
@@ -0,0 +1,31 @@
+#!/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 'vyosbuild'
+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"
+
+# run cleanup on vyos configure using python vyos.configtree, since can't remove interfaces via configure cli
+config_update_url="http://${PACKER_HTTP_IP}:${PACKER_HTTP_PORT}/cleanup-vyos-configure.py"
+wget $config_update_url -O /home/vyos/cleanup-vyos-configure.py
+chown vyos:users /home/vyos/cleanup-vyos-configure.py
+chmod 0664 /home/vyos/cleanup-vyos-configure.py
+python3 /home/vyos/cleanup-vyos-configure.py
+rm -rf /home/vyos/cleanup-vyos-configure.py
diff --git a/scripts/vyos/cleanup.sh b/scripts/vyos/cleanup.sh
new file mode 100644
index 0000000..15e67b6
--- /dev/null
+++ b/scripts/vyos/cleanup.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+set -e
+set -x
+
+export DEBIAN_FRONTEND=noninteractive
+
+rm -rf /home/vyos/cleanup-vyos.sh
+
+# fix config permissions since if we edited with root user
+# sudo chown -R root:vyattacfg /opt/vyatta/config/active/
+
+# reconfiguring ssh
+rm -f /etc/ssh/ssh_host_*
+dpkg-reconfigure openssh-server
+
+# 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/cloud-init-datasource.sh b/scripts/vyos/cloud-init-datasource.sh
new file mode 100644
index 0000000..2573a19
--- /dev/null
+++ b/scripts/vyos/cloud-init-datasource.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+set -e
+set -x
+
+if [[ "${CLOUD_INIT}" == "debian" || "${CLOUD_INIT}" == "vyos" ]]; then
+ if [[ "${CLOUD_INIT_DATASOURCE}" == "nocloud_configdrive" ]]; then
+ cat <<EOF > /etc/cloud/cloud.cfg.d/99-datasource.cfg
+datasource_list: [ NoCloud, ConfigDrive ]
+EOF
+ else
+ echo "$0 - info: cloud_init_datasource will not run, not supported cloud_init_datasource"
+ exit 0
+ fi
+else
+ echo "$0 - info: cloud_init_datasource will not run, not supported cloud_init"
+fi
diff --git a/scripts/vyos/cloud-init-debian.sh b/scripts/vyos/cloud-init-debian.sh
new file mode 100644
index 0000000..0f12066
--- /dev/null
+++ b/scripts/vyos/cloud-init-debian.sh
@@ -0,0 +1,29 @@
+#!/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
+
+cat <<EOF > /etc/cloud/cloud.cfg.d/99-disable_network_config.cfg
+network: {config: disabled}
+EOF
+
+rm -rf /etc/network/interfaces.d/50-cloud-init || :
diff --git a/scripts/vyos/cloud-init-vyos.sh b/scripts/vyos/cloud-init-vyos.sh
new file mode 100644
index 0000000..0d10668
--- /dev/null
+++ b/scripts/vyos/cloud-init-vyos.sh
@@ -0,0 +1,34 @@
+#!/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
+
+cat <<EOF > /etc/cloud/cloud.cfg.d/99-disable_network_config.cfg
+network: {config: disabled}
+EOF
+
+cat <<EOF > /etc/cloud/cloud.cfg.d/90-disable_config_stage.cfg
+# Disable all config-stage modules
+cloud_config_modules:
+EOF
+
+rm -rf /etc/network/interfaces.d/50-cloud-init || :
diff --git a/scripts/vyos/configure.sh b/scripts/vyos/configure.sh
new file mode 100644
index 0000000..f52c336
--- /dev/null
+++ b/scripts/vyos/configure.sh
@@ -0,0 +1,24 @@
+#!/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/configure-vyos.sh
+#!/bin/vbash
+source /opt/vyatta/etc/functions/script-template
+configure
+set system host-name 'vyoshost'
+commit
+save
+exit
+EOF
+chmod 0700 /home/vyos/configure-vyos.sh
+chown vyos:users /home/vyos/configure-vyos.sh
+su - vyos -c "/home/vyos/configure-vyos.sh"
+rm -rf /home/vyos/configure-vyos.sh
diff --git a/scripts/vyos/grub-serial.sh b/scripts/vyos/grub-serial.sh
new file mode 100644
index 0000000..5beb889
--- /dev/null
+++ b/scripts/vyos/grub-serial.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+set -e
+set -x
+
+#GRUB_SERIAL=1
+if [[ "${GRUB_SERIAL}" -ne 1 ]]; then
+ echo "$0 - info: grub will keep default=0 (kvm). to use serial add to .env: GRUB_SERIAL=1"
+ exit 0
+fi
+
+GRUB_CFG="/boot/grub/grub.cfg"
+GRUB_DEFAULT="/etc/default/grub"
+
+sed -i 's/^set default=.*/set default=1/' $GRUB_CFG
+
+if grep -q "^GRUB_DEFAULT=" $GRUB_DEFAULT; then
+ sed -i 's/^GRUB_DEFAULT=.*/GRUB_DEFAULT=1/' $GRUB_DEFAULT
+else
+ echo "GRUB_DEFAULT=1" >> $GRUB_DEFAULT
+fi
+
+# update-grub
+
+
diff --git a/scripts/vyos/init.sh b/scripts/vyos/init.sh
new file mode 100644
index 0000000..863692c
--- /dev/null
+++ b/scripts/vyos/init.sh
@@ -0,0 +1,12 @@
+#!/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/osprep.sh b/scripts/vyos/osprep.sh
new file mode 100644
index 0000000..bb2c448
--- /dev/null
+++ b/scripts/vyos/osprep.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+set -x
+
+# vimrc no mouse
+cat <<EOF > /home/vyos/.vimrc
+set mouse=
+EOF
+
+cat <<EOF > /root/.vimrc
+set mouse=
+EOF
+
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-expect.sh b/scripts/vyos/vyos-install-expect.sh
new file mode 100644
index 0000000..aa23064
--- /dev/null
+++ b/scripts/vyos/vyos-install-expect.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
+
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