@@ -7,62 +7,99 @@ LEAPREPO=/distribution/openSUSE-stable/repo/oss
77LEAPUPDATEREPO=/update/openSUSE-stable
88
99opensuse_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-)
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-)
1616
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
17+ case " $1 " in
18+ * -dockerbase)
19+ create_empty
20+ docker_prepare " opensuse/${DISTRO} " latest
21+
22+ # from this docker-taken opensuse image, generate a clean docker image using zypper
23+ echo ' nameserver 8.8.8.8' > " $WORK /etc/resolv.conf"
24+ echo ' nameserver 8.8.4.4' >> " $WORK /etc/resolv.conf"
25+
26+ case " $DISTRO " in
27+ tumbleweed)
28+ REPO=$TWREPO
29+ UPDATEREPO=$TWUPDATEREPO
30+ ;;
31+ leap)
32+ REPO=$LEAPREPO
33+ UPDATEREPO=$LEAPUPDATEREPO
34+ ;;
35+ * )
36+ echo " Unsupported openSUSE distro ($DISTRO ). Supported are tumbleweed and leap!"
37+ exit 1
38+ ;;
39+ esac
40+ run zypper -n --root /new-root ar -f $DLURL$REPO repo-oss
41+ run zypper -n --root /new-root ar -f $DLURL$UPDATEREPO repo-oss-update
42+ mkdir " $WORK /new-root/dev"
43+ mknod -m 600 " $WORK /new-root/dev/console" c 5 1
44+ mknod -m 666 " $WORK /new-root/dev/null" c 1 3
45+ mknod -m 666 " $WORK /new-root/dev/zero" c 1 5
46+ run zypper -n --root /new-root --gpg-auto-import-keys refresh
47+ run zypper -n --root /new-root install rpm zypper wget
5548
56- opensuse_cfg " $DISTRO " " $PATTERN "
57- ;;
58- esac
49+ echo " Generating opensuse-$DISTRO -dockerbase.tar.xz"
50+ tar cJf " opensuse-$DISTRO -dockerbase-$DATE .tar.xz" -C " $WORK /new-root" .
51+
52+ # perform prepare here so finalize makes something good
53+ prepare " opensuse-$DISTRO -dockerbase-$DATE .tar.xz"
54+ ;;
55+ * -base)
56+ create_empty
57+ ZYPPCMD=" zypper -n --root $WORK "
58+ if [ " $DISTRO " == " tumbleweed" ]; then
59+ REPO=$TWREPO
60+ UPDATEREPO=$TWUPDATEREPO
61+ elif [ " $DISTRO " == " leap" ]; then
62+ REPO=$LEAPREPO
63+ UPDATEREPO=$LEAPUPDATEREPO
64+ else
65+ echo " Unsupported openSUSE distro ($DISTRO ). Supported are tumbleweed and leap!"
66+ exit 1
67+ fi
68+ $ZYPPCMD ar -f $DLURL$REPO repo-oss
69+ $ZYPPCMD ar -f $DLURL$UPDATEREPO repo-oss-update
70+ $ZYPPCMD --gpg-auto-import-keys ref
71+ $ZYPPCMD install --download in-advance -t pattern enhanced_base x11
72+ $ZYPPCMD install --download in-advance NetworkManager spice-vdagent
73+ # we get a cloud-firstboot
74+ run systemctl mask systemd-firstboot
75+ # ensure networkmanager is enabled and not systemd-networkd
76+ run systemctl disable wicked
77+ run systemctl enable NetworkManager NetworkManager-wait-online
78+ run systemctl enable sshd
79+ # make sudo available without password (default for key auth)
80+ echo " %shellsuser ALL=(ALL) NOPASSWD: ALL" > " $WORK /etc/sudoers.d/01-shells" && chmod 440 " $WORK /etc/sudoers.d/01-shells"
81+ ;;
82+ * )
83+ # start from base
84+ if [ ! -f " opensuse-$DISTRO -base.qcow2" ]; then
85+ dodistro " opensuse-$DISTRO -base"
86+ fi
87+ prepare opensuse-$DISTRO -base
88+ ZYPPCMD=" zypper -n --root $WORK "
89+ $ZYPPCMD --gpg-auto-import-keys ref
90+ $ZYPPCMD dup
91+ $ZYPPCMD install --download in-advance -t pattern $PATTERN
92+
93+ opensuse_cfg " $DISTRO " " $PATTERN "
94+ ;;
95+ esac
5996}
6097
6198opensuse_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
99+ local DISTRO=$1
100+ local DESKTOP=$2
101+ if [ " $DESKTOP " == " gnome" ]; then
102+ cat >> " $WORK /usr/share/glib-2.0/schemas/30-Shells.gschema.override" << EOF
66103# disable gnome screen blanking, logout & power management
67104[org/gnome/desktop/screensaver]
68105lock-enabled=false
@@ -75,12 +112,12 @@ disable-log-out=true
75112[org/gnome/desktop/session]
76113idle-delay=uint32 0
77114EOF
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
115+ run /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas
116+ elif [ " $DESKTOP " == " kde" ]; then
117+ true # nothing to be done yet
118+ fi
82119
83- # add firstrun
84- add_firstrun NetworkManager-wait-online.service
85- do_linux_config
120+ # add firstrun
121+ add_firstrun NetworkManager-wait-online.service
122+ do_linux_config
86123}
0 commit comments