Initial commit
This commit is contained in:
commit
98c6295dbe
1 changed files with 71 additions and 0 deletions
71
setup.sh
Executable file
71
setup.sh
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
# running in guest
|
||||
guest_name="$(qubesdb-read /name)"
|
||||
echo $(realpath ""$0"")
|
||||
guest_repo_dir="$(dirname $(realpath ""$0""))"
|
||||
echo $guest_repo_dir
|
||||
|
||||
pushd ${guest_repo_dir} >/dev/null
|
||||
|
||||
if git remote | grep -Fq 'dom0'; then
|
||||
echo "(${guest_name}) remote 'dom0' already exists" >&2
|
||||
else
|
||||
echo "(${guest_name}) setting up remote 'dom0' to pull changes via bundle" >&2
|
||||
echo "ehhh"
|
||||
echo ${guest_repo_dir}
|
||||
git remote add dom0 ${guest_repo_dir}/.bundles/qubes-mgmt-ansible
|
||||
fi
|
||||
|
||||
branch=$(git branch --show-current)
|
||||
echo "(${guest_name}) creating bundle for branch '${branch}'" >&2
|
||||
mkdir -p .bundles
|
||||
|
||||
git bundle create - --all > .bundles/qubes-mgmt-ansible
|
||||
|
||||
popd >/dev/null
|
||||
|
||||
# piped to bash in dom0
|
||||
|
||||
cat <<-DOM0
|
||||
set -eo pipefail
|
||||
|
||||
echo "(dom0) bringing bundle from qubes '${guest_name}'" >&2
|
||||
|
||||
qvm-run -p ${guest_name} "cat ${guest_repo_dir}/.bundles/qubes-mgmt-ansible" </dev/null >/tmp/ansiblestuff.bundle
|
||||
|
||||
echo "{dom0} cloning into \$1; checking out branch '${branch}'" >&2
|
||||
|
||||
git clone /tmp/ansiblestuff.bundle -b "${branch}" "\$1"
|
||||
|
||||
pushd "\$1"
|
||||
|
||||
echo "{dom0} setting up remote '${guest_name}' to push/pull changes via bundle" >&2
|
||||
|
||||
mkdir ./.bundles
|
||||
mv /tmp/ansiblestuff.bundle ./.bundles/qubes-mgmt-ansible
|
||||
git remote remove origin
|
||||
git remote add "${guest_name}" \$(pwd)/.bundles/qubes-mgmt-ansible
|
||||
|
||||
# ensure remote refs are present in each repo
|
||||
git fetch "${guest_name}" # ensure remote refs are present in the dom0 repo
|
||||
|
||||
git bundle create .bundles/qubes-mgmt-ansible main~1..main main
|
||||
|
||||
qvm-run -p "${guest_name}" "cat > ${guest_repo_dir}/.bundles/qubes-mgmt-ansible" <.bundles/qubes-mgmt-ansible
|
||||
|
||||
qvm-run -p "${guest_name}" "cd ${guest_repo_dir} && git fetch dom0" </dev/null
|
||||
|
||||
# configure pointer to guest VM and path
|
||||
|
||||
echo "GUEST=${guest_name}" > .bundle-env
|
||||
echo "GUEST_REPO=${guest_repo_dir}" >> .bundle-env
|
||||
|
||||
echo "${dom0} has pulled!" >&2
|
||||
|
||||
popd
|
||||
DOM0
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue