Autoinstall: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Thomas (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „=virsh= *virt-install --name abba --ram 1024 --force --disk pool=default,size=10240,format=qcow2 --network bridge=dmz-telekom,mac=52:54:00:00:00:11 --grap…“) |
Thomas (Diskussion | Beiträge) |
||
| Zeile 15: | Zeile 15: | ||
exec /bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1 | exec /bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1 | ||
<pre> | <pre> | ||
| + | |||
| + | *cat /usr/local/sbin/mkmachine | ||
| + | <pre> | ||
| + | #!/bin/bash | ||
| + | source /usr/local/lib/mksystem.lib | ||
| + | SYSTEM=$1 | ||
| + | HN=$2 | ||
| + | IP=$3 | ||
| + | test -z "$SYSTEM" && SYSTEM="ubuntu" | ||
| + | test -z "$HN" && HN="rumburak" | ||
| + | test -z "$IP" && IP="192.168.252.69" | ||
| + | NM="255.255.255.0" | ||
| + | GW="192.168.252.1" | ||
| + | DN="192.168.252.20" | ||
| + | SE="taribo.lan xinux.org" | ||
| + | PA="iptraf" | ||
| + | US="stunk" | ||
| + | PW="oimel" | ||
| + | GR="sudo" | ||
| + | RD="/mnt/new" | ||
| + | CR="chroot $RD" | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | part_format | ||
| + | |||
| + | echo $SYSTEM | ||
| + | case $SYSTEM in | ||
| + | |||
| + | ubuntu) | ||
| + | echo ubuntu | ||
| + | SY="ubuntu-14.04-v5.tgz" | ||
| + | UR="http://waka.xinux.org/images/$SY" | ||
| + | mount_build | ||
| + | ubuntu_netmodify | ||
| + | ubuntu_modify | ||
| + | ;; | ||
| + | centos) | ||
| + | SY="centos-7-v2.tgz" | ||
| + | UR="http://waka.xinux.org/images/$SY" | ||
| + | mount_build | ||
| + | centos_netmodify | ||
| + | centos_modify | ||
| + | ;; | ||
| + | arch) | ||
| + | SY="archlinux-bootstrap-2015.10.01-x86_64.tar.gz" | ||
| + | UR="http://waka.xinux.org/images/$SY" | ||
| + | mount_build | ||
| + | #centos_netmodify | ||
| + | #centos_modify | ||
| + | ;; | ||
| + | esac | ||
| + | |||
| + | #unmount | ||
| + | </pre> | ||
| + | |||
| + | |||
| + | cat /usr/local/lib/mksystem.lib | ||
| + | <pre> | ||
| + | #!/bin/bash | ||
| + | |||
| + | function part_format() { | ||
| + | echo "mklabel" | ||
| + | parted -s /dev/vda mklabel msdos | ||
| + | echo "mkpart swap" | ||
| + | parted -s /dev/vda mkpart primary linux-swap 1 2000 | ||
| + | echo "mkpart /" | ||
| + | parted -s /dev/vda mkpart primary ext2 2000 100% | ||
| + | echo "mkswap" | ||
| + | mkswap /dev/vda1 > /dev/null 2>&1 | ||
| + | echo "mkfs.ext4" | ||
| + | mkfs.ext4 /dev/vda2 > /dev/null 2>&1 | ||
| + | test -d $RD || mkdir $RD | ||
| + | } | ||
| + | |||
| + | function mount_build() { | ||
| + | echo "mount new filesystem" | ||
| + | mount /dev/vda2 $RD | ||
| + | echo "unpackings system - wait" | ||
| + | wget -q -O - $UR | tar -C $RD -xzf - | ||
| + | echo "mount /dev /proc /sys" | ||
| + | mount -o bind /dev $RD/dev | ||
| + | mount -o bind /sys $RD/sys | ||
| + | mount -o bind /proc $RD/proc | ||
| + | } | ||
| + | |||
| + | |||
| + | function unmount() { | ||
| + | umount $RD/proc | ||
| + | umount $RD/sys | ||
| + | umount $RD/dev | ||
| + | umount $RD | ||
| + | } | ||
| + | |||
| + | |||
| + | function ubuntu_netmodify() { | ||
| + | echo $HN > $RD/etc/hostname | ||
| + | |||
| + | if test -z "IP" | ||
| + | then | ||
| + | cat<<HERE > "$RD/etc/network/interfaces" | ||
| + | auto lo | ||
| + | iface lo inet loopback | ||
| + | |||
| + | auto eth0 | ||
| + | iface eth0 inet dhcp | ||
| + | HERE | ||
| + | else | ||
| + | |||
| + | cat<<HERE > "$RD/etc/network/interfaces" | ||
| + | auto lo | ||
| + | iface lo inet loopback | ||
| + | |||
| + | auto eth0 | ||
| + | iface eth0 inet static | ||
| + | address $IP | ||
| + | netmask $NM | ||
| + | gateway $GW | ||
| + | dns-nameservers $DN | ||
| + | dns-search $SE | ||
| + | HERE | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | function centos_netmodify() { | ||
| + | echo $HN > $RD/etc/hostname | ||
| + | if test -z "IP" | ||
| + | then | ||
| + | : | ||
| + | else | ||
| + | cat<<HERE > "$RD/etc/sysconfig/network-scripts/ifcfg-eth0" | ||
| + | TYPE="Ethernet" | ||
| + | BOOTPROTO="none" | ||
| + | DEFROUTE="yes" | ||
| + | IPV4_FAILURE_FATAL="no" | ||
| + | IPV6INIT="yes" | ||
| + | IPV6_AUTOCONF="yes" | ||
| + | IPV6_DEFROUTE="yes" | ||
| + | IPV6_FAILURE_FATAL="no" | ||
| + | NAME="eth0" | ||
| + | UUID="56aa41e7-7911-49a4-aa24-98375f52522e" | ||
| + | DEVICE="eth0" | ||
| + | ONBOOT="yes" | ||
| + | DNS1=$DN | ||
| + | DOMAIN=$SE | ||
| + | IPADDR=$IP | ||
| + | PREFIX="24" | ||
| + | GATEWAY=$GW | ||
| + | IPV6_PEERDNS="yes" | ||
| + | IPV6_PEERROUTES="yes" | ||
| + | IPV6_PRIVACY="no" | ||
| + | HERE | ||
| + | echo "nameserver $DN" > $RD/etc/resolv.conf | ||
| + | echo "search $SE" >> $RD/etc/resolv.conf | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | function ubuntu_modify() { | ||
| + | mv $RD/etc/resolv.conf $RD/etc/resolv.conf.org | ||
| + | echo "nameserver 8.8.8.8" > $RD/etc/resolv.conf | ||
| + | $CR apt-get update | ||
| + | $CR apt-get -y install $PA | ||
| + | $CR useradd -m -s /bin/bash -G $GR $US | ||
| + | echo "$US:$PW" | $CR chpasswd | ||
| + | echo "grub-install" | ||
| + | grub-install --root-directory=$RD --boot-directory=$RD/boot /dev/vda | ||
| + | echo "update-grub" | ||
| + | $CR update-grub | ||
| + | rm $RD/etc/resolv.conf | ||
| + | mv $RD/etc/resolv.conf.org $RD/etc/resolv.conf | ||
| + | } | ||
| + | |||
| + | function centos_modify() { | ||
| + | mv $RD/etc/resolv.conf $RD/etc/resolv.conf.org | ||
| + | echo "nameserver 8.8.8.8" > $RD/etc/resolv.conf | ||
| + | $CR yum -y update | ||
| + | $CR yum -y install $PA | ||
| + | echo "GRUB_DISABLE_LINUX_UUID=true" >> $RD/etc/default/grub | ||
| + | echo "GRUB_ENABLE_LINUX_LABEL=true" >> $RD/etc/default/grub | ||
| + | echo "SELINUX=disabled" > $RD/etc/sysconfig/selinux | ||
| + | echo "SELINUXTYPE=targeted" >> $RD/etc/sysconfig/selinux | ||
| + | sed -i.org -e '/GRUB_CMDLINE_LINUX/s/.$/ net.ifnames=0 biosdevname=0"/' $RD/etc/default/grub | ||
| + | echo "grub-install" | ||
| + | $CR grub2-install /dev/vda | ||
| + | echo "update-grub" | ||
| + | $CR grub2-mkconfig -o /boot/grub2/grub.cfg | ||
| + | $CR useradd -m -s /bin/bash $US | ||
| + | echo "$US:$PW" | $CR chpasswd | ||
| + | rm $RD/etc/resolv.conf | ||
| + | mv $RD/etc/resolv.conf.org $RD/etc/resolv.conf | ||
| + | } | ||
| + | </pre> | ||
Version vom 4. Dezember 2015, 19:59 Uhr
virsh
- virt-install --name abba --ram 1024 --force --disk pool=default,size=10240,format=qcow2 --network bridge=dmz-telekom,mac=52:54:00:00:00:11 --graphics vnc --pxe
autologin
- cat /etc/init/tty1.conf
start on stopped rc RUNLEVEL=[2345] and (
not-container or
container CONTAINER=lxc or
container CONTAINER=lxc-libvirt)
stop on runlevel [!2345]
respawn
#exec /sbin/getty -8 38400 tty1
exec /bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1
<pre>
*cat /usr/local/sbin/mkmachine
<pre>
#!/bin/bash
source /usr/local/lib/mksystem.lib
SYSTEM=$1
HN=$2
IP=$3
test -z "$SYSTEM" && SYSTEM="ubuntu"
test -z "$HN" && HN="rumburak"
test -z "$IP" && IP="192.168.252.69"
NM="255.255.255.0"
GW="192.168.252.1"
DN="192.168.252.20"
SE="taribo.lan xinux.org"
PA="iptraf"
US="stunk"
PW="oimel"
GR="sudo"
RD="/mnt/new"
CR="chroot $RD"
part_format
echo $SYSTEM
case $SYSTEM in
ubuntu)
echo ubuntu
SY="ubuntu-14.04-v5.tgz"
UR="http://waka.xinux.org/images/$SY"
mount_build
ubuntu_netmodify
ubuntu_modify
;;
centos)
SY="centos-7-v2.tgz"
UR="http://waka.xinux.org/images/$SY"
mount_build
centos_netmodify
centos_modify
;;
arch)
SY="archlinux-bootstrap-2015.10.01-x86_64.tar.gz"
UR="http://waka.xinux.org/images/$SY"
mount_build
#centos_netmodify
#centos_modify
;;
esac
#unmount
cat /usr/local/lib/mksystem.lib
#!/bin/bash
function part_format() {
echo "mklabel"
parted -s /dev/vda mklabel msdos
echo "mkpart swap"
parted -s /dev/vda mkpart primary linux-swap 1 2000
echo "mkpart /"
parted -s /dev/vda mkpart primary ext2 2000 100%
echo "mkswap"
mkswap /dev/vda1 > /dev/null 2>&1
echo "mkfs.ext4"
mkfs.ext4 /dev/vda2 > /dev/null 2>&1
test -d $RD || mkdir $RD
}
function mount_build() {
echo "mount new filesystem"
mount /dev/vda2 $RD
echo "unpackings system - wait"
wget -q -O - $UR | tar -C $RD -xzf -
echo "mount /dev /proc /sys"
mount -o bind /dev $RD/dev
mount -o bind /sys $RD/sys
mount -o bind /proc $RD/proc
}
function unmount() {
umount $RD/proc
umount $RD/sys
umount $RD/dev
umount $RD
}
function ubuntu_netmodify() {
echo $HN > $RD/etc/hostname
if test -z "IP"
then
cat<<HERE > "$RD/etc/network/interfaces"
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
HERE
else
cat<<HERE > "$RD/etc/network/interfaces"
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address $IP
netmask $NM
gateway $GW
dns-nameservers $DN
dns-search $SE
HERE
fi
}
function centos_netmodify() {
echo $HN > $RD/etc/hostname
if test -z "IP"
then
:
else
cat<<HERE > "$RD/etc/sysconfig/network-scripts/ifcfg-eth0"
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="eth0"
UUID="56aa41e7-7911-49a4-aa24-98375f52522e"
DEVICE="eth0"
ONBOOT="yes"
DNS1=$DN
DOMAIN=$SE
IPADDR=$IP
PREFIX="24"
GATEWAY=$GW
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_PRIVACY="no"
HERE
echo "nameserver $DN" > $RD/etc/resolv.conf
echo "search $SE" >> $RD/etc/resolv.conf
fi
}
function ubuntu_modify() {
mv $RD/etc/resolv.conf $RD/etc/resolv.conf.org
echo "nameserver 8.8.8.8" > $RD/etc/resolv.conf
$CR apt-get update
$CR apt-get -y install $PA
$CR useradd -m -s /bin/bash -G $GR $US
echo "$US:$PW" | $CR chpasswd
echo "grub-install"
grub-install --root-directory=$RD --boot-directory=$RD/boot /dev/vda
echo "update-grub"
$CR update-grub
rm $RD/etc/resolv.conf
mv $RD/etc/resolv.conf.org $RD/etc/resolv.conf
}
function centos_modify() {
mv $RD/etc/resolv.conf $RD/etc/resolv.conf.org
echo "nameserver 8.8.8.8" > $RD/etc/resolv.conf
$CR yum -y update
$CR yum -y install $PA
echo "GRUB_DISABLE_LINUX_UUID=true" >> $RD/etc/default/grub
echo "GRUB_ENABLE_LINUX_LABEL=true" >> $RD/etc/default/grub
echo "SELINUX=disabled" > $RD/etc/sysconfig/selinux
echo "SELINUXTYPE=targeted" >> $RD/etc/sysconfig/selinux
sed -i.org -e '/GRUB_CMDLINE_LINUX/s/.$/ net.ifnames=0 biosdevname=0"/' $RD/etc/default/grub
echo "grub-install"
$CR grub2-install /dev/vda
echo "update-grub"
$CR grub2-mkconfig -o /boot/grub2/grub.cfg
$CR useradd -m -s /bin/bash $US
echo "$US:$PW" | $CR chpasswd
rm $RD/etc/resolv.conf
mv $RD/etc/resolv.conf.org $RD/etc/resolv.conf
}