From 26280ad34578291e9b6f2a168a8b89d324218a4f Mon Sep 17 00:00:00 2001 From: neil Date: Fri, 10 Nov 2023 19:50:36 +0100 Subject: [PATCH] use libvirt --- .github/workflows/build.yml | 13 +++++++++---- .github/workflows/manual.yml | 11 ++++++++--- build.sh | 36 +++++++++++++++++------------------- conf/solaris-11.4.conf | 4 ++-- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 550f158..2e6e3af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,11 +25,16 @@ jobs: strategy: matrix: os: ["11.4"] - runs-on: macos-12 + runs-on: ubuntu-22.04 env: SEC_VBOX : ${{ secrets.SEC_VBOX }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: vmactions/cf-tunnel@v0 + id: tunnel + with: + protocol: http + port: 8000 - run: | bash build.sh conf/solaris-${{ matrix.os }}.conf - name: Upload Release Asset @@ -40,8 +45,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: files: | - solaris-${{ matrix.os }}.ova + solaris-${{ matrix.os }}.qcow2.xz solaris-${{ matrix.os }}-id_rsa.pub - solaris-${{ matrix.os }}-mac.id_rsa + solaris-${{ matrix.os }}-host.id_rsa diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml index a795c4a..847038a 100644 --- a/.github/workflows/manual.yml +++ b/.github/workflows/manual.yml @@ -5,7 +5,7 @@ on: jobs: build: - runs-on: macos-12 + runs-on: ubuntu-22.04 env: RELEASE: "11.4" DEBUG: 1 @@ -13,13 +13,18 @@ jobs: NGROK_TOKEN : ${{ secrets.NGROK_TOKEN }} SEC_VBOX : ${{ secrets.SEC_VBOX }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: vmactions/cf-tunnel@v0 + id: tunnel + with: + protocol: http + port: 8000 - name: Run establish a ngrok tunnel id: test uses: vmactions/ngrok-tunnel@v0.0.1 with: protocol: tcp - port: 3390 + port: 5900 - name: Sleep run: | for i in $(seq 1 10) ; do echo $i; sleep 1; done diff --git a/build.sh b/build.sh index 4f67d36..a46203b 100644 --- a/build.sh +++ b/build.sh @@ -60,7 +60,7 @@ fi chmod +x "$vmsh" -$vmsh addSSHHost $osname $sshport + @@ -70,22 +70,13 @@ if ! $vmsh clearVM $osname; then echo "vm does not exists" fi -$vmsh createVM $VM_ISO_LINK $osname $ostype $sshport - - $vmsh startWeb $osname -$vmsh startCF - - -_sleep=20 -echo "Sleep $_sleep seconds, please open the link in your browser." -sleep $_sleep +$vmsh createVM $VM_ISO_LINK $osname $ostype $sshport -$vmsh startVM $osname sleep 2 @@ -97,12 +88,12 @@ $vmsh processOpts $osname "$opts" $vmsh shutdownVM $osname -$vmsh detachISO $osname $vmsh startVM $osname + ############################################### waitForText "The highlighted entry will be executed automatically" @@ -118,13 +109,17 @@ inputKeys "string root; enter; sleep 1; string $VM_ROOT_PASSWORD ; enter" sleep 2 +if [ ! -e ~/.ssh/id_rsa ] ; then + ssh-keygen -f ~/.ssh/id_rsa -q -N "" +fi + echo "set -e" >enablessh.local echo "mkdir -p ~/.ssh" >>enablessh.local echo "touch ~/.ssh/authorized_keys" >>enablessh.local #add ssh key twice, to avoid bugs. -echo "echo '$(base64 ~/.ssh/id_rsa.pub)' | openssl base64 -d >>~/.ssh/authorized_keys" >>enablessh.local +echo "echo '$(base64 -w 0 ~/.ssh/id_rsa.pub)' | openssl base64 -d >>~/.ssh/authorized_keys" >>enablessh.local echo "" >>enablessh.local echo "echo '$(cat ~/.ssh/id_rsa.pub)' >>~/.ssh/authorized_keys" >>enablessh.local @@ -138,20 +133,23 @@ cat enablessh.txt >>enablessh.local $vmsh inputFile $osname enablessh.local + +############################################################### + +$vmsh addSSHHost $osname + + ssh $osname sh <.ssh/config echo "Host host" >>.ssh/config -echo " HostName 10.0.2.2" >>.ssh/config +echo " HostName 192.168.122.1" >>.ssh/config echo " User runner" >>.ssh/config echo " ServerAliveInterval 1" >>.ssh/config EOF -############################################################### - - if [ -e "hooks/postBuild.sh" ]; then ssh $osname sh<"hooks/postBuild.sh" fi @@ -179,13 +177,13 @@ $vmsh shutdownVM $osname -ova="$osname-$VM_RELEASE.ova" +ova="$osname-$VM_RELEASE.qcow2" echo "Exporting $ova" $vmsh exportOVA $osname "$ova" -cp ~/.ssh/id_rsa $osname-$VM_RELEASE-mac.id_rsa +cp ~/.ssh/id_rsa $osname-$VM_RELEASE-host.id_rsa ls -lah diff --git a/conf/solaris-11.4.conf b/conf/solaris-11.4.conf index 10b9baf..9e15dad 100644 --- a/conf/solaris-11.4.conf +++ b/conf/solaris-11.4.conf @@ -2,7 +2,7 @@ VM_ISO_LINK="https://github.com/vmactions/solaris-download/releases/download/v0.0.2/sol-11_4-text-x86.iso" VM_OS_NAME="solaris" -VM_OS_TYPE="Solaris_64" +VM_OS_TYPE="solaris11" VM_SSH_PORT=2223 VM_ROOT_PASSWORD="vmactions.org" @@ -23,4 +23,4 @@ VM_OPTS="conf/solaris-11.4.opts.txt" VM_VBOX="./vbox.sh" -VM_VBOX_LINK="https://raw.githubusercontent.com/vmactions/vbox/v0.0.3/vbox.sh" \ No newline at end of file +VM_VBOX_LINK="https://raw.githubusercontent.com/vmactions/vbox/v0.9.2/vbox.sh" \ No newline at end of file