aboutsummaryrefslogtreecommitdiff
path: root/kvmx
diff options
context:
space:
mode:
Diffstat (limited to 'kvmx')
-rwxr-xr-xkvmx22
1 files changed, 22 insertions, 0 deletions
diff --git a/kvmx b/kvmx
index 7c60af9..cb0e0a0 100755
--- a/kvmx
+++ b/kvmx
@@ -123,6 +123,28 @@ function kvmx_up {
done
echo " done."
+ echo "Setting hostname..."
+ $SSH_COMMAND -o ConnectTimeout=2 -p $SSH $SSH_LOGIN@127.0.0.1 <<EOF
+ ##### BEGIN REMOTE SCRIPT #####
+ OLD_HOST="\$(hostname)"
+
+ # Set hosts entry
+ if ! grep -q "^127.0.0.1 $hostname.$domain $hostname$" /etc/hosts; then
+ echo "127.0.0.1 $hostname.$domain $hostname" | sudo tee -a /etc/hosts > /dev/null
+ fi
+
+ echo "$hostname.$domain" | sudo tee /etc/hostname > /dev/null
+ sudo hostname $hostname.$domain
+
+ # Remove old hostname from hosts file
+ if [ "\$OLD_HOST" != "$hostname.$domain" ]; then
+ if grep -q \$OLD_HOST /etc/hosts; then
+ sudo sed -i -e '|\$OLD_HOST|d' /etc/hosts
+ fi
+ fi
+ ##### END REMOTE SCRIPT #######
+EOF
+
# Somehow it is starting before DBUS and then crashing, so we try to start again
echo "Ensure spice-vdagent is running..."
echo "sudo /usr/sbin/service spice-vdagent start" | kvmx_ssh