mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 04:02:37 +01:00
17b69f04ff
* replace heartbeat with health-check * instead of steady stream of newlines every 5s, now awaits input and responds with `vmstat` output * more reliably use host/config/vm-exec.json to get libvirt domain name for snapshot-revert, server address, serial ports, vagrant setting, etc * use iptables/nftables to disable networking * added guest/bin/disable-network-[iptables,nftables] * added guest/bin/enable-network-[iptables,nftables] * replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages * documentation updates and tweaks
75 lines
1.9 KiB
Bash
Executable File
75 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# File: setup-guest
|
|
#
|
|
# Purpose: Sets up PBot VM Guest. Copies necessary files to the appropriate
|
|
# location, sets up environment variables and various configuration details.
|
|
|
|
# SPDX-FileCopyrightText: 2022-2024 Pragmatic Software <pragma78@gmail.com>
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
# determine OS/distribution
|
|
if [ -f /etc/os-release ]; then
|
|
# freedesktop.org and systemd
|
|
. /etc/os-release
|
|
OS=$PRETTY_NAME
|
|
elif type lsb_release >/dev/null 2>&1; then
|
|
# linuxbase.org
|
|
OS=$(lsb_release -si)
|
|
elif [ -f /etc/lsb-release ]; then
|
|
# For some versions of Debian/Ubuntu without lsb_release command
|
|
. /etc/lsb-release
|
|
OS=$DISTRIB_ID
|
|
else
|
|
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
|
|
OS=$(uname -s)
|
|
fi
|
|
|
|
echo "Detected OS: $OS"
|
|
|
|
# run known provisioning scripts
|
|
case $OS in
|
|
'openSUSE Tumbleweed')
|
|
echo "Provisioning for $OS"
|
|
./guest/provision/tumbleweed
|
|
;;
|
|
'Debian GNU/Linux trixie/sid')
|
|
echo "Provisioning for $OS"
|
|
./guest/provision/debian-trixie
|
|
;;
|
|
*)
|
|
echo "!! No automatic provisioning script for $OS. Install packages manually. !!"
|
|
echo
|
|
;;
|
|
esac
|
|
|
|
# copy executable scripts
|
|
cp guest/bin/* /usr/local/bin
|
|
|
|
# lib and language support
|
|
mkdir -p /usr/local/share/pbot-vm/
|
|
cp -r guest/lib/* /usr/local/share/pbot-vm/
|
|
|
|
# C support and GDB integration
|
|
cp guest/include/prelude.h /usr/include
|
|
|
|
# require root password for polkit actions
|
|
cp guest/polkit/* /etc/polkit-1/rules.d/
|
|
|
|
# set environment variables
|
|
if ! grep -qF "pbot-vm" /root/.bashrc; then
|
|
echo '# pbot-vm' >> /root/.bashrc
|
|
echo unset DEBUGINFOD_URLS >> /root/.bashrc
|
|
echo export ASAN_OPTIONS=detect_leaks=0 >> /root/.bashrc
|
|
fi
|
|
|
|
export DEBUGINFOD_URLS
|
|
export ASAN_OPTIONS=detect_leaks=0
|
|
|
|
echo PBot Guest VM is set up.
|
|
echo
|
|
echo To start PBot Guest Server: guest-server
|
|
|
|
# make environment variables take effect
|
|
exec /bin/bash
|