diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-03-10 15:31:04 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-03-10 15:31:04 -0300 |
commit | 0b64d3ff8ee12c876204e544362b90836b75a649 (patch) | |
tree | 90a212c900d6eb1a48c9079845cd1d4b121a6071 | |
parent | 5769e8a133653537c753ee53264a43bf1d38057d (diff) | |
download | kvmx-0b64d3ff8ee12c876204e544362b90836b75a649.tar.gz kvmx-0b64d3ff8ee12c876204e544362b90836b75a649.tar.bz2 |
Set hostname at kvmx_up
-rwxr-xr-x | kvmx | 22 | ||||
-rwxr-xr-x | provision/desktop-basic | 9 | ||||
-rwxr-xr-x | provision/development | 9 |
3 files changed, 22 insertions, 18 deletions
@@ -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 diff --git a/provision/desktop-basic b/provision/desktop-basic index d711383..dd5531f 100755 --- a/provision/desktop-basic +++ b/provision/desktop-basic @@ -26,15 +26,6 @@ DOMAIN="$2" MIRROR="$3" APT_INSTALL="sudo LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y" -# Set hostname -echo "$HOSTNAME.$DOMAIN" | sudo tee /etc/hostname > /dev/null -sudo hostname $HOSTNAME.$DOMAIN - -# 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 - # Configure keyboard cat <<-EOF | sudo tee /etc/default/keyboard > /dev/null # KEYBOARD CONFIGURATION FILE diff --git a/provision/development b/provision/development index fa7a323..e14d0ac 100755 --- a/provision/development +++ b/provision/development @@ -26,15 +26,6 @@ DOMAIN="$2" MIRROR="$3" APT_INSTALL="sudo LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y" -# Set hostname -echo "$HOSTNAME.$DOMAIN" | sudo tee /etc/hostname > /dev/null -sudo hostname $HOSTNAME.$DOMAIN - -# 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 - # Dependencies sudo sed -i -e "s|main$|main contrib non-free|g" /etc/apt/sources.list sudo apt-get update |