|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +DLURL=https://download.opensuse.org |
| 4 | +TWREPO=/tumbleweed/repo/oss |
| 5 | +TWUPDATEREPO=/update/tumbleweed |
| 6 | +LEAPREPO=/distribution/openSUSE-stable/repo/oss |
| 7 | +LEAPUPDATEREPO=/update/openSUSE-stable |
| 8 | + |
| 9 | +opensuse_distro() { |
| 10 | + # install distro using zypper into "$WORK" |
| 11 | + # $1 can be something like opensuse-tumbleweed-gnome or opensuse-leap-xfce |
| 12 | + # DISTRO is split out from $1, the 2nd 'parameter', i.e. tumbleweed or leap |
| 13 | + DISTRO=$(echo "$1" | cut -f2 -d-) |
| 14 | + # PATTERN is split out from $1, the 3rd 'parameter', i.e. gnome, kde, xfce |
| 15 | + local PATTERN=$(echo "$1" | cut -f3 -d-) |
| 16 | + |
| 17 | + case "$1" in |
| 18 | + *-base) |
| 19 | + create_empty |
| 20 | + ZYPPCMD="zypper -n --root $WORK" |
| 21 | + if [ "$DISTRO" == "tumbleweed" ]; then |
| 22 | + REPO=$TWREPO |
| 23 | + UPDATEREPO=$TWUPDATEREPO |
| 24 | + elif [ "$DISTRO" == "leap" ]; then |
| 25 | + REPO=$LEAPREPO |
| 26 | + UPDATEREPO=$LEAPUPDATEREPO |
| 27 | + else |
| 28 | + echo "Unsupported openSUSE distro ($DISTRO). Supported are tumbleweed and leap!" |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | + $ZYPPCMD ar -f $DLURL$REPO repo-oss |
| 32 | + $ZYPPCMD ar -f $DLURL$UPDATEREPO repo-oss-update |
| 33 | + $ZYPPCMD --gpg-auto-import-keys ref |
| 34 | + $ZYPPCMD install --download in-advance -t pattern enhanced_base x11 |
| 35 | + $ZYPPCMD install --download in-advance NetworkManager spice-vdagent |
| 36 | + # we get a cloud-firstboot |
| 37 | + run systemctl mask systemd-firstboot |
| 38 | + # ensure networkmanager is enabled and not systemd-networkd |
| 39 | + run systemctl disable wicked |
| 40 | + run systemctl enable NetworkManager NetworkManager-wait-online |
| 41 | + run systemctl enable sshd |
| 42 | + # make sudo available without password (default for key auth) |
| 43 | + echo "%shellsuser ALL=(ALL) NOPASSWD: ALL" > "$WORK/etc/sudoers.d/01-shells" && chmod 440 "$WORK/etc/sudoers.d/01-shells" |
| 44 | + ;; |
| 45 | + *) |
| 46 | + # start from base |
| 47 | + if [ ! -f "opensuse-$DISTRO-base.qcow2" ]; then |
| 48 | + dodistro "opensuse-$DISTRO-base" |
| 49 | + fi |
| 50 | + prepare opensuse-$DISTRO-base |
| 51 | + ZYPPCMD="zypper -n --root $WORK" |
| 52 | + $ZYPPCMD --gpg-auto-import-keys ref |
| 53 | + $ZYPPCMD dup |
| 54 | + $ZYPPCMD install --download in-advance -t pattern $PATTERN |
| 55 | + |
| 56 | + opensuse_cfg "$DISTRO" "$PATTERN" |
| 57 | + ;; |
| 58 | + esac |
| 59 | +} |
| 60 | + |
| 61 | +opensuse_cfg() { |
| 62 | + local DISTRO=$1 |
| 63 | + local DESKTOP=$2 |
| 64 | + if [ "$DESKTOP" == "gnome" ]; then |
| 65 | + cat >>"$WORK/usr/share/glib-2.0/schemas/30-Shells.gschema.override" <<EOF |
| 66 | +# disable gnome screen blanking, logout & power management |
| 67 | +[org/gnome/desktop/screensaver] |
| 68 | +lock-enabled=false |
| 69 | +idle-activation-enabled=false |
| 70 | +
|
| 71 | +[org/gnome/desktop/lockdown] |
| 72 | +disable-lock-screen=true |
| 73 | +disable-log-out=true |
| 74 | +
|
| 75 | +[org/gnome/desktop/session] |
| 76 | +idle-delay=uint32 0 |
| 77 | +EOF |
| 78 | + run /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas |
| 79 | + elif [ "$DESKTOP" == "kde" ]; then |
| 80 | + true # nothing to be done yet |
| 81 | + fi |
| 82 | + |
| 83 | + # add firstrun |
| 84 | + add_firstrun NetworkManager-wait-online.service |
| 85 | + do_linux_config |
| 86 | +} |
0 commit comments