Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:crameleon:temporary
opensuse-infrastructure-vm-bootstrap
initial_setup_prg2.sh
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File initial_setup_prg2.sh of Package opensuse-infrastructure-vm-bootstrap
#!/bin/sh # Fork from initial_setup.sh (credits to the original author) # Optimized for virtual machines in our PRG2 location - Georg Pfuetzenreuter <mail+opensuse@georg-pfuetzenreuter.net> set -e SALTMASTER='2a07:de40:b27e:1200::a' CHECKFILE='/var/adm/opensuse_infra_bootstrapped' if [ -f "$CHECKFILE" ] then echo 'Machine seems to already be bootstrapped, refusing to operate.' exit 1 fi help() { echo echo 'First boot configuration for infra.opensuse.org VMs hosted in PRG2' echo echo 'Options:' echo '-n VM_HOSTNAME Short hostname (NOT the FQDN)' echo '-v VM_VLAN Short VLAN name (NOT the ID), starting with "os-"' echo '-i VM_IP_ADDRESS Free IPv6 address inside this VLAN including the prefix' echo '-g VM_GATEWAY_IP Default gateway of this VLAN' echo '-r REBOOT Set to "no" to prevent the default automatic reboot' echo } while getopts n:v:i:g:r:h arg; do case ${arg} in n) VM_HOSTNAME="${OPTARG}" ;; v) VM_VLAN="${OPTARG}" ;; i) VM_IP="${OPTARG}" ;; g) VM_GWIP="${OPTARG}" ;; r) REBOOT="${OPTARG}" ;; h) help && exit ;; *) help && exit 1 ;; esac done if [ -z "$VM_HOSTNAME" ] || [ -z "$VM_IP" ] || [ -z "$VM_GWIP" ] then help exit 1 fi if echo "$VM_HOSTNAME" | grep -F '.' then echo 'Please provide the short hostname and NOT a domain.' exit 1 fi if ! echo "$VM_VLAN" | grep -q '^os-' then echo 'VLAN name does not match expected format.' exit 1 fi if [ -z "$REBOOT" ] then REBOOT='yes' fi set -Cu # # Network interface # if ! ip -br l sh | grep eth0 >/dev/null then echo 'Cannot locate default interface' exit 1 fi rm -f /etc/sysconfig/network/ifcfg-eth0 /etc/sysconfig/network/routes sed -i -e "s/eth0/$VM_VLAN/" /etc/udev/rules.d/70-persistent-net.rules printf 'BOOTPROTO=static\nSTARTMODE=auto\nIPADDR_0=%s\n' "$VM_IP" > "/etc/sysconfig/network/ifcfg-$VM_VLAN" printf 'default %s\n' "$VM_GWIP" > /etc/sysconfig/network/routes # # Hostname # FQDN="$VM_HOSTNAME.infra.opensuse.org" hostnamectl set-hostname "$FQDN" printf '%s %s %s\n' "${VM_IP%/*}" "$FQDN" "$VM_HOSTNAME" >> /etc/hosts # # Salt # printf 'salt_cluster: opensuse\n' > /etc/salt/grains printf 'master: %s\nsaltenv: production\nhash_type: sha512\nipv6: True\n' "$SALTMASTER" > /etc/salt/minion.d/bootstrap.conf # # Services # systemctl enable salt-minion sshd # # Finalize # zypper -n rm opensuse-infrastructure-vm-bootstrap touch "$CHECKFILE" if [ "$REBOOT" = 'yes' ] then shutdown -r now 'Rebooting to apply first boot configuration ...' fi
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor