From ce3d781df0af02da96f9830b3558129d1057610b Mon Sep 17 00:00:00 2001 From: neil Date: Mon, 18 Jul 2022 23:32:26 +0800 Subject: [PATCH] Speed up loading time. --- conf/12.3.conf | 13 +++++++++++-- conf/13.0.conf | 13 +++++++++++-- conf/13.1.conf | 13 +++++++++++-- run.sh | 25 +++++++++++++++---------- 4 files changed, 48 insertions(+), 16 deletions(-) diff --git a/conf/12.3.conf b/conf/12.3.conf index f77800f..4d46b5f 100644 --- a/conf/12.3.conf +++ b/conf/12.3.conf @@ -1,3 +1,12 @@ -OVA_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v0.1.2/freebsd-12.3.ova.7z" -CONF_LINK="https://raw.githubusercontent.com/vmactions/freebsd-builder/v0.1.2/conf/freebsd-12.3.conf" +BUILDER_VERSION=0.1.3 + + +CONF_LINK="https://raw.githubusercontent.com/vmactions/freebsd-builder/v${BUILDER_VERSION}/conf/freebsd-${VM_RELEASE}.conf" + +OVA_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v${BUILDER_VERSION}/freebsd-${VM_RELEASE}.ova" + +VM_PUBID_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v${BUILDER_VERSION}/freebsd-${VM_RELEASE}-id_rsa.pub" + +HOST_ID_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v${BUILDER_VERSION}/freebsd-${VM_RELEASE}-mac.id_rsa" + diff --git a/conf/13.0.conf b/conf/13.0.conf index 4ab99a4..4d46b5f 100644 --- a/conf/13.0.conf +++ b/conf/13.0.conf @@ -1,3 +1,12 @@ -OVA_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v0.1.2/freebsd-13.0.ova.7z" -CONF_LINK="https://raw.githubusercontent.com/vmactions/freebsd-builder/v0.1.2/conf/freebsd-13.0.conf" +BUILDER_VERSION=0.1.3 + + +CONF_LINK="https://raw.githubusercontent.com/vmactions/freebsd-builder/v${BUILDER_VERSION}/conf/freebsd-${VM_RELEASE}.conf" + +OVA_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v${BUILDER_VERSION}/freebsd-${VM_RELEASE}.ova" + +VM_PUBID_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v${BUILDER_VERSION}/freebsd-${VM_RELEASE}-id_rsa.pub" + +HOST_ID_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v${BUILDER_VERSION}/freebsd-${VM_RELEASE}-mac.id_rsa" + diff --git a/conf/13.1.conf b/conf/13.1.conf index 9fd1726..4d46b5f 100644 --- a/conf/13.1.conf +++ b/conf/13.1.conf @@ -1,3 +1,12 @@ -OVA_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v0.1.2/freebsd-13.1.ova.7z" -CONF_LINK="https://raw.githubusercontent.com/vmactions/freebsd-builder/v0.1.2/conf/freebsd-13.1.conf" +BUILDER_VERSION=0.1.3 + + +CONF_LINK="https://raw.githubusercontent.com/vmactions/freebsd-builder/v${BUILDER_VERSION}/conf/freebsd-${VM_RELEASE}.conf" + +OVA_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v${BUILDER_VERSION}/freebsd-${VM_RELEASE}.ova" + +VM_PUBID_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v${BUILDER_VERSION}/freebsd-${VM_RELEASE}-id_rsa.pub" + +HOST_ID_LINK="https://github.com/vmactions/freebsd-builder/releases/download/v${BUILDER_VERSION}/freebsd-${VM_RELEASE}-mac.id_rsa" + diff --git a/run.sh b/run.sh index 9f6005b..494ce56 100644 --- a/run.sh +++ b/run.sh @@ -23,6 +23,8 @@ if [ -z "$VM_RELEASE" ]; then VM_RELEASE=$DEFAULT_RELEASE fi +export VM_RELEASE + #load the release conf if [ ! -e "conf/$VM_RELEASE.conf" ]; then @@ -65,12 +67,7 @@ osname="$VM_OS_NAME" ostype="$VM_OS_TYPE" sshport=$VM_SSH_PORT -ova="$VM_OVA_NAME.ova" - -ovazip="$(echo "$OVA_LINK" | rev | cut -d / -f 1 | rev)" - - -ovafile="$ova" +ovafile="$osname-$VM_RELEASE.ova" @@ -81,15 +78,23 @@ importVM() { bash $vmsh setup - if [ ! -e "$ovazip" ]; then + if [ ! -e "$ovafile" ]; then echo "Downloading $OVA_LINK" - wget -q "$OVA_LINK" + wget -O "$ovafile" -q "$OVA_LINK" fi - if [ ! -e "$ovafile" ]; then - 7za e -y $ovazip -o. + if [ ! -e "id_rsa.pub" ]; then + echo "Downloading $VM_PUBID_LINK" + wget -O "id_rsa.pub" -q "$VM_PUBID_LINK" + fi + + if [ ! -e "mac.id_rsa" ]; then + echo "Downloading $VM_PUBID_LINK" + wget -O "mac.id_rsa" -q "$HOST_ID_LINK" fi + ls -lah + bash $vmsh addSSHAuthorizedKeys id_rsa.pub cat mac.id_rsa >$HOME/.ssh/mac.id_rsa chmod 600 $HOME/.ssh/mac.id_rsa