diff options
Diffstat (limited to 'core/modules')
100 files changed, 1010 insertions, 122 deletions
diff --git a/core/modules/alsa/data/etc/systemd/system/multi-user.target.wants/alsa-default-card.service b/core/modules/alsa/data/etc/systemd/system/sound.target.wants/alsa-default-card.service index 55e393fd..55e393fd 120000 --- a/core/modules/alsa/data/etc/systemd/system/multi-user.target.wants/alsa-default-card.service +++ b/core/modules/alsa/data/etc/systemd/system/sound.target.wants/alsa-default-card.service diff --git a/core/modules/alsa/data/opt/openslx/scripts/alsa-default_card b/core/modules/alsa/data/opt/openslx/scripts/alsa-default_card index 4e372f9c..61e83e00 100755 --- a/core/modules/alsa/data/opt/openslx/scripts/alsa-default_card +++ b/core/modules/alsa/data/opt/openslx/scripts/alsa-default_card @@ -1,7 +1,20 @@ #!/bin/ash +export PATH=$PATH:/opt/openslx/sbin:/opt/openslx/bin + PROC="/proc/asound/pcm" +# give it some time if it is not directly found. +i=0 +while true; do + if [ "$i" -eq 10 ]; then + echo "'${PROC}' not found or not readable." + exit 1 + fi + [ -r "$PROC" ] && break + usleep "$(( ++i * 500000 ))" +done + if [ ! -r "$PROC" ]; then echo "'${PROC}' not found or not readable. Not setting default sound card." exit 0 diff --git a/core/modules/alsa/data/opt/openslx/vmchooser/sessionstart.d/default-sound-volume b/core/modules/alsa/data/opt/openslx/vmchooser/sessionstart.d/default-sound-volume new file mode 100755 index 00000000..2eaa7060 --- /dev/null +++ b/core/modules/alsa/data/opt/openslx/vmchooser/sessionstart.d/default-sound-volume @@ -0,0 +1,15 @@ +#!/bin/ash +# +# This hook evaluates the SLX_VM_SOUND configuration option +# and mutes the sound via ALSA if appropriate. This will only +# take effect in non-virtual sessions (determined by the +# env variable SESSION_TYPE given by vmchooser). + +if [ "$SESSION_TYPE" = "XSESSION" ]; then + . /opt/openslx/config + + if [ "$SLX_VM_SOUND" = "DEFAULT_MUTED" -o "$SLX_VM_SOUND" = "FORCE_MUTED" ]; then + amixer set Master mute + fi +fi +: # fake success to not trigger slxlog diff --git a/core/modules/alsa/module.conf.ubuntu b/core/modules/alsa/module.conf.ubuntu index bae01ed1..92ffbf36 100644 --- a/core/modules/alsa/module.conf.ubuntu +++ b/core/modules/alsa/module.conf.ubuntu @@ -6,6 +6,9 @@ REQUIRED_CONTENT_PACKAGES=" libasound2-data libasound2-plugins " +REQUIRED_INSTALLED_PACKAGES=" + $REQUIRED_CONTENT_PACKAGES +" REQUIRED_DIRECTORIES+=" /etc/modprobe.d diff --git a/core/modules/busybox/module.build b/core/modules/busybox/module.build index 9b83e1e7..2643bf15 100644 --- a/core/modules/busybox/module.build +++ b/core/modules/busybox/module.build @@ -34,10 +34,14 @@ build() { pinfo "Running make (if this hangs, check for unset options, ie. when you increased the REQUIRED_BRANCH)" make || perror "failed." pinfo "Running make install" - make CONFIG_PREFIX="$MODULE_BUILD_DIR" install || perror "failed" - rm -f "$MODULE_BUILD_DIR/bin/mount" "$MODULE_BUILD_DIR/bin/umount" "$MODULE_BUILD_DIR/bin/bash" + local INSTALL_PREFIX="${MODULE_BUILD_DIR}/opt/openslx" + make CONFIG_PREFIX="${INSTALL_PREFIX}" install || perror "failed" + rm -f "${INSTALL_PREFIX}/bin/mount" "${INSTALL_PREFIX}/bin/umount" "${INSTALL_PREFIX}/bin/bash" + cd - &> /dev/null } post_copy() { - : + mkdir -p "${TARGET_BUILD_DIR}/bin" || perror "Failed to create '${TARGET_BUILD_DIR}/bin'." + ln -sf "/opt/openslx/bin/busybox" "${TARGET_BUILD_DIR}/bin/ash" || \ + perror "Failed to link '${TARGET_BUILD_DIR}/bin/ash' to '/opt/openslx/bin/busybox'." } diff --git a/core/modules/busybox/module.conf b/core/modules/busybox/module.conf index 265f53f3..d5bb5c41 100644 --- a/core/modules/busybox/module.conf +++ b/core/modules/busybox/module.conf @@ -3,6 +3,6 @@ REQUIRED_GIT="git://git.busybox.net/busybox" REQUIRED_BRANCH="1_31_1" REQUIRED_BINARIES="busybox" REQUIRED_DIRECTORIES=" - /bin - /sbin + /opt/openslx/bin + /opt/openslx/sbin " diff --git a/core/modules/cron/module.conf b/core/modules/cron/module.conf index 31573eb0..0a9c52c3 100644 --- a/core/modules/cron/module.conf +++ b/core/modules/cron/module.conf @@ -1,4 +1,7 @@ #!/bin/bash +REQUIRED_MODULES=" + slxlog +" REQUIRED_GIT="https://github.com/cronie-crond/cronie.git" REQUIRED_COMMIT="d582556168e740fbd19e777a6733b404084e69d8" REQUIRED_BINARIES=" diff --git a/core/modules/demo-user/module.build b/core/modules/demo-user/module.build new file mode 100644 index 00000000..92c3dde3 --- /dev/null +++ b/core/modules/demo-user/module.build @@ -0,0 +1,13 @@ +#!/bin/bash +fetch_source() { + : +} + +build() { + : +} + +post_copy() { + DEMO_ID="$(USER=demo PASSWORD= USERHOME=/home/demo USERSHELL=/bin/bash add_user)" + [ -n "$DEMO_ID" ] && pinfo "Created user demo" +} diff --git a/core/modules/demo-user/module.conf b/core/modules/demo-user/module.conf new file mode 100644 index 00000000..8811668a --- /dev/null +++ b/core/modules/demo-user/module.conf @@ -0,0 +1,4 @@ +#!/bin/bash +REQUIRED_BINARIES="" +REQUIRED_LIBRARIES="" +REQUIRED_DIRECTORIES="" diff --git a/core/modules/dhcpc-busybox/data/etc/systemd/system/bridge-additional-nics.service b/core/modules/dhcpc-busybox/data/etc/systemd/system/bridge-additional-nics.service new file mode 100644 index 00000000..751f3598 --- /dev/null +++ b/core/modules/dhcpc-busybox/data/etc/systemd/system/bridge-additional-nics.service @@ -0,0 +1,8 @@ +[Unit] +Description=Setup bridges for addition network interfaces +Wants=systemd-udevd.service +After=systemd-udev-settle.service systemd-udevd.service + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-bridge_additional_nics diff --git a/core/modules/dhcpc-busybox/data/etc/udev/rules.d/99-openslx-net.rules b/core/modules/dhcpc-busybox/data/etc/udev/rules.d/99-openslx-net.rules index 17c0068c..1d8778dc 100644 --- a/core/modules/dhcpc-busybox/data/etc/udev/rules.d/99-openslx-net.rules +++ b/core/modules/dhcpc-busybox/data/etc/udev/rules.d/99-openslx-net.rules @@ -1 +1 @@ -ACTION=="add", SUBSYSTEM=="net", KERNEL=="br0|br-nic-*", TAG+="systemd", ENV{SYSTEMD_ALIAS}="/sys/subsystem/net/devices/$name", ENV{SYSTEMD_WANTS}="network-interface@$name.service" +ACTION=="add", SUBSYSTEM=="net", KERNEL=="br-nic-*", TAG+="systemd", ENV{SYSTEMD_ALIAS}="/sys/subsystem/net/devices/$name", ENV{SYSTEMD_WANTS}="network-interface@$name.service" diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-bridge_additional_nics b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-bridge_additional_nics new file mode 100755 index 00000000..fd820909 --- /dev/null +++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-bridge_additional_nics @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Small script scanning sysfs for physical network interfaces +# and creating additional network bridges 'br-nic-[0-9]'. + +. /opt/openslx/config + +# do nothing if not netbooted +[ -z "$SLX_PXE_NETIF" ] && exit 1 + +declare -g id=1 +for nic in /sys/class/net/*; do + # The presence of this symlink pointing to the physical device + # seems to be the better way to detect them. + [ -h "${nic}/device" ] || continue + + # do not handle the primary interface + [ "$SLX_PXE_NETIF" = "${nic##*/}" ] && continue + + # physical nic found, create a bridge with the same MAC + bridge="br-nic-${id}" + mac="$(cat "${nic}/address")" + if ! [[ $mac =~ ^([0-9a-f]{2}:){5}[0-9a-f]{2}$ ]]; then + echo "'$mac' does not seems like a valid MAC address." + continue + fi + + ( + set -e + brctl addbr "$bridge" + brctl stp "$bridge" 0 + ip link set addr "$mac" "$bridge" + ip link set dev "${nic##*/}" up + brctl addif "$bridge" "${nic##*/}" + ip link set dev "$bridge" up + ) + ret=$? + if [ "$ret" != 0 ]; then + echo "Failed to setup additional bridge '$bridge' for '$nic'." + brctl delbr "$bridge" + continue + fi + + # all fine, increase counter and continue + (( id++ )) +done + +exit 0 diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx index c034efb5..b2a4e896 100755 --- a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx +++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx @@ -155,10 +155,13 @@ case "$1" in rebuild_resolv_conf fi - + # NOTE: The udev rule triggering our network setup is changed in *installer* + # to only trigger this script on additional interfaces bridges. Keeping the code + # here for now and for easier merging... # Things that should only happen for the main interface that was used for booting if [ "$interface" = "$primary" ]; then - # Update IP + # Update IP, TODO: check if we really want/need to overwrite the PXE_IP, + # it might be better/clearer to change the SLX_DHCP_CLIENT_IP... sed -i "s/^\(SLX_PXE_CLIENT_IP=\).*$/\1'$ip'/" /opt/openslx/config # Write DOMAIN and SEARCH to /opt/openslx/config if empty if [ -z "$SLX_NET_DOMAIN" ] && [ -n "$domain" ]; then @@ -175,36 +178,6 @@ case "$1" in echo "SLX_NET_WINS='$wins'" >> /opt/openslx/config fi - # Only if network is not ready yet - if ! [ -e "/run/network/network-ready" ] || ! [ -e "/etc/hostname" ] || grep -q '^noname-' "/etc/hostname"; then - # Update hostname - if [ -z "$dns_fqdn" ] && [ -n "$domain" ] && [ -n "$hostname" ]; then - # fallback to what the dhcp told us - dns_fqdn="${hostname}.${domain}" - fi - if [ -z "$dns_fqdn" ]; then - # only if there is no /etc/hostname, we fall back (far back, that is) - [ ! -s "/etc/hostname" ] && dns_fqdn="slx-client" - fi - # finally, if dns_fqdn was set to anything, apply it - if [ -n "$dns_fqdn" ]; then - dns_short="${dns_fqdn%%.*}" - echo "$dns_short" > "/proc/sys/kernel/hostname" - echo "$dns_short" > "/etc/hostname" - if grep '^SLX_HOSTNAME=' /opt/openslx/config 2>/dev/null; then - sed -i "s/^\(SLX_HOSTNAME=\).*$/\1'$dns_short'/" /opt/openslx/config - else - echo "# Config written by openslx-dhcp-script (1)" >> /opt/openslx/config - echo "SLX_HOSTNAME='$dns_short'" >> /opt/openslx/config - fi - fi - - # Update /etc/issue for proper spacing - /opt/openslx/scripts/openslx-create_issue - touch "/run/network/network-ready" - # Mark network target as reached - systemctl start network.target & - fi # end "network not ready yet" # Remove any stray addresses; we expect the primary interface to only have one # address supplied via DHCP. We do this after adding the new one, obviously. rem_list=$( ip -o addr show "$interface" | awk '{ for (i=1;i<NF;++i) if ($i == "inet") print $(i+1) }' | grep -v "^${ip}/" ) @@ -217,7 +190,7 @@ case "$1" in done fi fi # end "primary only" - + # Hostname in /etc/hosts touch "/etc/hosts" hostlist="" @@ -238,20 +211,10 @@ case "$1" in fi # Get rid of orphaned lines in /etc/hosts sed -i -r '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s*$/d' /etc/hosts - - # "dns ready" target - if [ -n "$dns" ] && [ ! -e "/run/network/dns-ready" ]; then - touch "/run/network/dns-ready" - # Write to openslx-config - echo "# Config written by openslx-dhcp-script (2)" >> /opt/openslx/config - echo "SLX_DNS='$dns'" >> /opt/openslx/config - systemctl start network-dns.target & - fi - # "default route exists" target - if [ -n "$router" ] && [ ! -e "/run/network/gateway-ready" ]; then - touch "/run/network/gateway-ready" - systemctl start network-gateway.target & - fi + # Write to openslx-config + echo "# Config written by openslx-dhcp-script (2)" >> /opt/openslx/config + sed -i "/^SLX_DNS=/d" /opt/openslx/config + echo "SLX_DNS='$dns'" >> /opt/openslx/config ;; deconfig) diff --git a/core/modules/dhcpc-busybox/module.conf b/core/modules/dhcpc-busybox/module.conf index d8961801..8dd62c4c 100644 --- a/core/modules/dhcpc-busybox/module.conf +++ b/core/modules/dhcpc-busybox/module.conf @@ -1,4 +1,5 @@ #!/bin/bash REQUIRED_MODULES=" + slxlog rdns " diff --git a/core/modules/disk-partitions/data/etc/systemd/system/local-fs.target.wants/setup-partitions.service b/core/modules/disk-partitions/data/etc/systemd/system/local-fs.target.wants/setup-partitions.service new file mode 120000 index 00000000..af2957f8 --- /dev/null +++ b/core/modules/disk-partitions/data/etc/systemd/system/local-fs.target.wants/setup-partitions.service @@ -0,0 +1 @@ +../setup-partitions.service
\ No newline at end of file diff --git a/core/modules/disk-partitions/data/etc/systemd/system/setup-partitions.service b/core/modules/disk-partitions/data/etc/systemd/system/setup-partitions.service new file mode 100644 index 00000000..16e3b990 --- /dev/null +++ b/core/modules/disk-partitions/data/etc/systemd/system/setup-partitions.service @@ -0,0 +1,11 @@ +[Unit] +Description=Setup local disk partitions (tmp, swap) +After=systemd-udev-settle.service systemd-udevd.service +Wants=tmp.target systemd-udevd.service +Before=tmp.target +DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-setup_partitions +RemainAfterExit=yes diff --git a/core/modules/disk-partitions/data/etc/systemd/system/tmp.target b/core/modules/disk-partitions/data/etc/systemd/system/tmp.target new file mode 100644 index 00000000..12f8a679 --- /dev/null +++ b/core/modules/disk-partitions/data/etc/systemd/system/tmp.target @@ -0,0 +1,2 @@ +[Unit] +Description=Backwards compatibility target diff --git a/core/modules/disk-partitions/data/opt/openslx/scripts/systemd-setup_partitions b/core/modules/disk-partitions/data/opt/openslx/scripts/systemd-setup_partitions new file mode 100755 index 00000000..641ae372 --- /dev/null +++ b/core/modules/disk-partitions/data/opt/openslx/scripts/systemd-setup_partitions @@ -0,0 +1,272 @@ +#!/bin/bash +# Arrays etc and $(( )) with big numbers +# ----------------------------------------------------------------------------- +# +# Copyright (c) 2018 bwLehrpool-Projektteam +# +# This program/file is free software distributed under the GPL version 2. +# See https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# If you have any feedback please consult https://bwlehrpool.de and +# send your feedback to bwlehrpool@hs-offenburg.de. +# +# General information about bwLehrpool can be found at https://bwlehrpool.de +# +# ----------------------------------------------------------------------------- +# +# Local hard disk autodetection script for OpenSLX linux stateless clients, +# detecting swap and special partitions + +############################################################################# + +. /opt/openslx/bin/slx-tools + +# Mount point for persistent scratch partition (type 45) +MOUNT_POINT_45="/opt/openslx/persistent" +PARTITION_FILE="/run/openslx/partitions" +readonly MOUNT_POINT_45 PARTITION_FILE +mkdir -p "/run/openslx" + +declare -a TMPFILES +gettmp () { + local vn file + for vn in "$@"; do + file=$(mktemp -p /run/openslx) # since we fiddle around with /tmp in this script + declare -g "${vn}=${file}" + TMPFILES+=("$file") + done +} +delalltmp () { + rm -f -- "${TMPFILES[@]}" +} +trap delalltmp EXIT + +# get_mount_options <fstype> <varname> +get_mount_options () { + case "$1" in + ext2) + declare -ag "${2}=(-o nocheck)" + ;; + ext4) + declare -ag "${2}=(-o 'errors=remount-ro,data=ordered,relatime,quota')" + ;; + *) + declare -ag "${2}=()" + esac +} + +# General formatter for the /tmp partition on a local harddisk +format_disk () { + declare -ag MOUNT_OPTIONS_SET_BY_FORMAT_DISK=() # Global var! + local target="$1" + local fslist="xfs jfs ext3 ext2 ext4" + local fs + declare -a fopt + [ $# -ge 2 ] && fslist="$2" + for fs in $fslist ; do + if grep -q "\\b${fs}\\b" "/proc/filesystems"; then + # Filesystem already supported by running kernel + : + elif modprobe "${fs}"; then + # Filesystem module could be loaded and should be supported now + : + else + # Not supported, try next one + continue + fi + if which "mkfs.$fs" ; then + case "$fs" in + reiserfs) + fopt=("-f") + ;; + xfs) + fopt=("-f" "-K") + ;; + ext2|ext3) + fopt=("-F") + ;; + ext4) + fopt=(-F -b 4096 -O "extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize,quota" -E "nodiscard,quotatype=usrquota:prjquota" -I 256) + ;; + jfs) + fopt=() + ;; + *) + fopt=() + ;; + esac + get_mount_options "$fs" MOUNT_OPTIONS_SET_BY_FORMAT_DISK + "mkfs.$fs" "${fopt[@]}" "${target}" && return 0 # Success! + fi + done + return 1 +} + +wait_for_udev () { + local upid ctr hdd + hdd= + if [ "x$1" = "x--hdd" ]; then + hdd=true + shift + fi + ctr=$(( "$1" * 10 )) + if ! [ "$ctr" -gt 0 ]; then # Negation to catch NaN + ctr=1 + fi + udevadm trigger & + usleep 20000 # 20ms + udevadm settle &> /dev/null & # --timeout doesn't work reliably, sometimes the process just hangs + upid=$! + while [ "$ctr" -gt 0 ]; do + [ -n "$hdd" ] && has_hdd && break + [ -z "$hdd" ] && ! [ -d "/proc/$upid" ] && break + usleep 100000 # 100ms + ctr=$(( ctr - 1 )) + done + if [ -d "/proc/$upid" ]; then + kill -9 "$upid" &> /dev/null & + fi +} + +has_hdd () { + [ -n "$( ls -U -1 /dev/disk/by-path/ )" ] +} + +wait_for_udev 2 + +if ! has_hdd; then + wait_for_udev --hdd 4 +fi + +shopt -s extglob +for disk in /dev/disk/by-path/!(*-part*|*-usb-*); do + [ -L "$disk" ] || continue + fdisk -l "$( readlink -f "$disk" )" +done > "$PARTITION_FILE" +shopt -u extglob +if ! [ -s "$PARTITION_FILE" ]; then + echo "none" > "$PARTITION_FILE" +fi +echo "Partitions:" +cat "$PARTITION_FILE" + +# Check for standard swap partitions and make them available to the system +HAVE_SWAP=no +for PART_DEV in $(dev_find_partitions "82" "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"); do + if swapon "$PART_DEV" -p 10; then + HAVE_SWAP=yes # low priority, in case we have zram swap, prefer that) + echo -e "$PART_DEV\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab" + fi +done + +# Put detected linux partitions (83) into /etc/fstab with "noauto" +for PART_DEV in $(dev_find_partitions "83"); do + mkdir -p "/media/${PART_DEV#/dev/*}" + echo -e "${PART_DEV}\t/media/${PART_DEV#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab" +done + +# special partition 45 (persistent scratch) to $MOUNT_POINT_45 +HAVE_PARTITION_45=no +get_mount_options "ext4" mopts +# try all the ID45 partitions until one succeeds, from large to small +for PART_DEV in $(dev_find_partitions "45" "87f86132-ff94-4987-b250-454545454545"); do + mkdir -p "$MOUNT_POINT_45" + # Let's see if this is an ext4 partition and if so, whether it has the proper size + # Any fixing should happen first + gettmp "logfile" + COUNT=0 + while true; do + [ "$COUNT" -ge 4 ] && break + let COUNT++ + fsck.ext4 -y "$PART_DEV" &> "$logfile" + RET=$? + if [ "$(( RET & 7 ))" = 4 ]; then + slxlog "partition-45-fsck" "Error fixing file system errors on ID45 partition" "$logfile" + break + fi + [ "$(( RET & 3 ))" != 1 ] && break + done + # awk script to take block count and block size from dumpe2fs output and multiply them to get byte size + fs_size=$(dumpe2fs -h "$PART_DEV" | awk -F: 'BEGIN{a=0;b=0}{if ($1 == "Block count") a=$2; if($1 == "Block size") b=$2;}END{ if (a>0 && b>0) print a" * "b}' | bc) + echo "$PART_DEV has ext4 fs of size $fs_size" + if [ -n "$fs_size" ] && [ "$fs_size" -gt 1000000 ]; then + # It's ext4, see if partition size was changed offline + dev_size=$(blockdev --getsize64 "$PART_DEV") + echo "$PART_DEV has actual size of $dev_size" + if [ -n "$dev_size" ] && [ "$dev_size" -gt 1000000 ]; then + # somewhat sane, see what to do + dev_mb=$(( dev_size / 1024 / 1024 )) + fs_mb=$(( fs_size / 1024 / 1024 )) + echo "Dev: $dev_mb, fs: $fs_mb" + if [ "$(( fs_mb + 100 ))" -lt "$dev_mb" ]; then + # dev size plus 100MB is still smaller than reported fs size -- resize fs + gettmp "logfile" + fsck.ext4 -f -y "$PART_DEV" &> "$logfile" + if resize2fs "$PART_DEV" &>> "$logfile"; then + slxlog "partition-45-resize-ok" "Resized partition $PART_DEV from $fs_mb MiB to $dev_mb MiB" "$logfile" + else + slxlog "partition-45-resize-fail" "Could not enlarge file system size of $PART_DEV from $fs_mb MiB to $dev_mb MiB" "$logfile" + dd if=/dev/zero of="$PART_DEV" bs=1M count=1 &>/dev/null + fi + elif [ "$dev_size" -lt "$fs_size" ]; then + # partition is smaller than expected by fs -- killall + slxlog "partition-45-shrink" "$PART_DEV has ext4 file system which is $fs_mb MiB, but partition size is only $dev_mb MiB. Will wipe partition to be safe..." + dd if=/dev/zero of="$PART_DEV" bs=1M count=1 &>/dev/null + fi + fi + fi + # try to mount + if ! mount -v -t ext4 "${mopts[@]}" "${PART_DEV}" "$MOUNT_POINT_45"; then + # failed, try to format + gettmp "logfile" + if ! format_disk "$PART_DEV" "ext4" &> "$logfile"; then + slxlog "partition-45-format" "Cannot format $PART_DEV with ext4" "$logfile" + continue + fi + gettmp "logfile" + if ! mount -v -t ext4 "${mopts[@]}" "${PART_DEV}" "$MOUNT_POINT_45" &> "$logfile"; then + slxlog "partition-45-newmount" "Cannot mount $PART_DEV with ext4 right after formatting" "$logfile" + continue + fi + fi + # Mount success -- clean up lost+found + find "${MOUNT_POINT_45}/slx_lost+found" -mindepth 1 -maxdepth 1 -mtime +90 -type d -exec rm -rf -- {} \; + if [ -d "${MOUNT_POINT_45}/lost+found" ]; then + touch "${MOUNT_POINT_45}/lost+found" + mkdir -p "${MOUNT_POINT_45}/slx_lost+found" + mv -f -- "${MOUNT_POINT_45}/lost+found" "${MOUNT_POINT_45}/slx_lost+found/$(date +%s)_$$-$RANDOM" + fi + chmod 0700 "${MOUNT_POINT_45}/slx_lost+found" + chown 0:0 "${MOUNT_POINT_45}/slx_lost+found" + # fstab entry + echo -e "${PART_DEV}\t${MOUNT_POINT_45}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab" + HAVE_PARTITION_45=yes + break # success, done +done + +# and 46 to /media/devXX +for PART_DEV in $(dev_find_partitions "46"); do + mkdir -p "/media/${PART_DEV#/dev/*}" + echo -e "${PART_DEV}\t/media/${PART_DEV#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab" +done + +# finally, prepare the data subdir on persistent part +if [ "$HAVE_PARTITION_45" = "yes" ]; then + mkdir -p "$MOUNT_POINT_45/data" + chown root:root "$MOUNT_POINT_45" "$MOUNT_POINT_45/data" + chmod a+rwxt "$MOUNT_POINT_45/data" +elif [ -d "$MOUNT_POINT_45" ]; then + rm -f -- "$MOUNT_POINT_45" +fi + +mount -a + +if [ "$HAVE_SWAP" = "no" ]; then + TOTAL_RAM=$(grep ^MemTotal /proc/meminfo | awk '{print $2}') + if [ -n "$TOTAL_RAM" ] && [ "$TOTAL_RAM" -lt "3000000" ]; then + slxlog "partition-swap" "Have no (formatted) swap partition, using zram swap only!" "$PARTITION_FILE" + fi +fi + +exit 0 + diff --git a/core/modules/disk-partitions/module.build b/core/modules/disk-partitions/module.build new file mode 100644 index 00000000..241bcd5e --- /dev/null +++ b/core/modules/disk-partitions/module.build @@ -0,0 +1,12 @@ +#!/bin/bash +fetch_source() { + : +} + +build() { + pinfo "Static module, nothing to build." +} + +post_copy() { + : +} diff --git a/core/modules/disk-partitions/module.conf b/core/modules/disk-partitions/module.conf new file mode 100644 index 00000000..d5d021fa --- /dev/null +++ b/core/modules/disk-partitions/module.conf @@ -0,0 +1,2 @@ +#!/bin/bash +# Nothing diff --git a/core/modules/disk-partitions/module.conf.ubuntu b/core/modules/disk-partitions/module.conf.ubuntu new file mode 100644 index 00000000..33a76ec0 --- /dev/null +++ b/core/modules/disk-partitions/module.conf.ubuntu @@ -0,0 +1,5 @@ +REQUIRED_INSTALLED_PACKAGES=" + xfsprogs + e2fsprogs + dosfstools +" diff --git a/core/modules/distro-logo/module.build b/core/modules/distro-logo/module.build index 4e30667f..8c2813c8 100644 --- a/core/modules/distro-logo/module.build +++ b/core/modules/distro-logo/module.build @@ -13,6 +13,7 @@ post_copy() { local DIST=$(lsb_release -si) if [ -n "$DIST" ]; then [ -z "$CFG_DISTLOGO_URL" ] && CFG_DISTLOGO_URL='http://mltk-services.ruf.uni-freiburg.de/distro_logo.php?distro=' + mkdir -p "$TARGET_BUILD_DIR/etc" wget -t 3 -T 3 -O "$TARGET_BUILD_DIR/etc/distro.png" "${CFG_DISTLOGO_URL}${DIST}" if [ ! -s "$TARGET_BUILD_DIR/etc/distro.png" ]; then rm -f "$TARGET_BUILD_DIR/etc/distro.png" diff --git a/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-setup_dnbd3_proxy b/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-setup_dnbd3_proxy index e45272a6..771bc707 100755 --- a/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-setup_dnbd3_proxy +++ b/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-setup_dnbd3_proxy @@ -283,6 +283,30 @@ if [ -n "$islocal" ]; then adduser dnbd3 fuse # Start service, is not symlinked when not in proxy mode systemctl --no-block start dnbd3-proxy.service + ( + # give it some time to start + usleep 500000 + for i in 1 2 3 4 5 ""; do + [ -z "$i" ] && exit 1 + if echo | busybox timeout 1 busybox nc 127.0.0.1 "$DNBD3_PORT"; then + break + fi + echo "fail #$i" + sleep 1 + done + + # it's up, so let's try to add the server + if ! dnbd3-client -A 127.0.0.1 -d /dev/dnbd0; then + # failed, either the dnbd3-client doesn't support -A or + # it is still not up. + exit 1 + fi + + if ! dnbd3-client -s 127.0.0.1 -d /dev/dnbd0; then + # localhost still not found even though its in alt-servers !? + exit 1337 + fi + ) & fi exit 0 diff --git a/core/modules/dnbd3-proxy-mode/module.build b/core/modules/dnbd3-proxy-mode/module.build index a2c0bd22..4ab661f9 100644 --- a/core/modules/dnbd3-proxy-mode/module.build +++ b/core/modules/dnbd3-proxy-mode/module.build @@ -8,6 +8,6 @@ build() { } post_copy() { - add_group "dnbd3" - USER="dnbd3" GROUP="dnbd3" add_user + add_system_group "dnbd3" + USER="dnbd3" GROUP="dnbd3" add_system_user } diff --git a/core/modules/dnbd3/module.build b/core/modules/dnbd3/module.build index 671bf120..1c877c8f 100644 --- a/core/modules/dnbd3/module.build +++ b/core/modules/dnbd3/module.build @@ -38,5 +38,5 @@ build() { } post_copy() { - : + add_system_group "fuse" } diff --git a/core/modules/dnbd3/module.conf b/core/modules/dnbd3/module.conf index e671dcdf..575d7de7 100644 --- a/core/modules/dnbd3/module.conf +++ b/core/modules/dnbd3/module.conf @@ -1,4 +1,8 @@ #!/bin/bash +REQUIRED_MODULES=" + kernel + slxlog +" REQUIRED_MODULES="kernel" REQUIRED_GIT="https://git.openslx.org/dnbd3.git" REQUIRED_BINARIES=" diff --git a/core/modules/gdisk/module.conf b/core/modules/gdisk/module.conf index 2c00fc76..58915682 100644 --- a/core/modules/gdisk/module.conf +++ b/core/modules/gdisk/module.conf @@ -1,6 +1,7 @@ #!/bin/bash REQUIRED_MODULES=" kernel + slxlog " REQUIRED_BINARIES=" sgdisk diff --git a/core/modules/gfx-driver/data/etc/systemd/system/load-gfx-driver.service b/core/modules/gfx-driver/data/etc/systemd/system/load-gfx-driver.service new file mode 100644 index 00000000..0534f45c --- /dev/null +++ b/core/modules/gfx-driver/data/etc/systemd/system/load-gfx-driver.service @@ -0,0 +1,9 @@ +[Unit] +Description=Load DRM GFX driver and 3D +Before=sysinit.target shutdown.target +DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-load_gfx_driver +RemainAfterExit=yes diff --git a/core/modules/gfx-driver/data/etc/systemd/system/sysinit.target.wants/load-gfx-driver.service b/core/modules/gfx-driver/data/etc/systemd/system/sysinit.target.wants/load-gfx-driver.service new file mode 120000 index 00000000..b72d0453 --- /dev/null +++ b/core/modules/gfx-driver/data/etc/systemd/system/sysinit.target.wants/load-gfx-driver.service @@ -0,0 +1 @@ +../load-gfx-driver.service
\ No newline at end of file diff --git a/core/modules/gfx-driver/data/opt/openslx/scripts/systemd-load_gfx_driver b/core/modules/gfx-driver/data/opt/openslx/scripts/systemd-load_gfx_driver new file mode 100755 index 00000000..7d6ddb88 --- /dev/null +++ b/core/modules/gfx-driver/data/opt/openslx/scripts/systemd-load_gfx_driver @@ -0,0 +1,7 @@ +#!/bin/ash +# nvidia-libs is handled as a stage4 addon during stage3 + +# Seems we can finally always do that; in fact, not doing so seems to crash VMs left and right +echo -e "# Written by load-gfx-driver\nSLX_VMWARE_3D=yes" >> "/opt/openslx/config" + +exit 0 diff --git a/core/modules/gfx-driver/module.build b/core/modules/gfx-driver/module.build new file mode 100644 index 00000000..241bcd5e --- /dev/null +++ b/core/modules/gfx-driver/module.build @@ -0,0 +1,12 @@ +#!/bin/bash +fetch_source() { + : +} + +build() { + pinfo "Static module, nothing to build." +} + +post_copy() { + : +} diff --git a/core/modules/gfx-driver/module.conf b/core/modules/gfx-driver/module.conf new file mode 100644 index 00000000..bcd2acc3 --- /dev/null +++ b/core/modules/gfx-driver/module.conf @@ -0,0 +1,3 @@ +REQUIRED_MODULES=" + rootfs-kernel +" diff --git a/core/modules/idleaction/module.conf b/core/modules/idleaction/module.conf index 24d0a301..503a35a7 100644 --- a/core/modules/idleaction/module.conf +++ b/core/modules/idleaction/module.conf @@ -1,4 +1,7 @@ #!/bin/bash +REQUIRED_MODULES=" + slxlog +" REQUIRED_BINARIES=" idle-daemon xprintidle diff --git a/core/modules/iptables-helper/module.conf b/core/modules/iptables-helper/module.conf index 46eb4e93..2c41c13c 100644 --- a/core/modules/iptables-helper/module.conf +++ b/core/modules/iptables-helper/module.conf @@ -1,4 +1,5 @@ #!/bin/bash REQUIRED_MODULES=" + slxlog iptables " diff --git a/core/modules/kdm-theme-bwlp/module.build b/core/modules/kdm-theme-bwlp/module.build index 135bddfc..48733d91 100644 --- a/core/modules/kdm-theme-bwlp/module.build +++ b/core/modules/kdm-theme-bwlp/module.build @@ -1,14 +1,26 @@ #!/bin/bash - -fetch_source () { +fetch_source() { : } -build () { +build() { : } post_copy() { - : + # Try to fetch distro logo + if [ ! -s "$TARGET_BUILD_DIR/etc/distro.png" ]; then + local DIST=$(lsb_release -si) + if [ -n "$DIST" ]; then + [ -z "$CFG_DISTLOGO_URL" ] && CFG_DISTLOGO_URL='http://mltk-services.ruf.uni-freiburg.de/distro_logo.php?distro=' + wget -t 3 -T 3 -O "$TARGET_BUILD_DIR/etc/distro.png" "${CFG_DISTLOGO_URL}${DIST}" + if [ ! -s "$TARGET_BUILD_DIR/etc/distro.png" ]; then + rm -f "$TARGET_BUILD_DIR/etc/distro.png" + pwarning "Could not download distro-logo" + fi + else + pwarning "Could not determine distribution" + fi + fi } diff --git a/core/modules/kernel-vanilla/module.build b/core/modules/kernel-vanilla/module.build index a6a33f48..ffa1f53d 100644 --- a/core/modules/kernel-vanilla/module.build +++ b/core/modules/kernel-vanilla/module.build @@ -34,13 +34,15 @@ fetch_source() { rm -rf "./ksrc" git clone --depth 1 "${REQUIRED_GIT}" -b "v${REQUIRED_KERNEL}" ksrc || perror "Could not clone kernel git." fi - # check for aufs - local RSL=$(find ksrc/ -type d -name aufs) - if [ -z "$RSL" ]; then - pinfo "aufs not found in kernel sources, patching it..." - patch_aufs - else - pinfo "aufs detected in kernel source :)" + if [ "$REMOTE_LOCAL_INSTALL" -eq 0 ]; then + # check for aufs + local RSL=$(find ksrc/ -type d -name aufs) + if [ -z "$RSL" ]; then + pinfo "aufs not found in kernel sources, patching it..." + patch_aufs + else + pinfo "aufs detected in kernel source :)" + fi fi # Other patches local patch diff --git a/core/modules/kexec-reboot/data/etc/systemd/system/basic.target.wants/enable-kexec-reboot.service b/core/modules/kexec-reboot/data/etc/systemd/system/basic.target.wants/enable-kexec-reboot.service deleted file mode 120000 index 510ad25a..00000000 --- a/core/modules/kexec-reboot/data/etc/systemd/system/basic.target.wants/enable-kexec-reboot.service +++ /dev/null @@ -1 +0,0 @@ -../enable-kexec-reboot.service
\ No newline at end of file diff --git a/core/modules/kexec-reboot/data/etc/systemd/system/ctrl-alt-del.target b/core/modules/kexec-reboot/data/etc/systemd/system/ctrl-alt-del.target new file mode 120000 index 00000000..b202bdcb --- /dev/null +++ b/core/modules/kexec-reboot/data/etc/systemd/system/ctrl-alt-del.target @@ -0,0 +1 @@ +/lib/systemd/system/kexec.target
\ No newline at end of file diff --git a/core/modules/kexec-reboot/data/etc/systemd/system/enable-kexec-reboot.service b/core/modules/kexec-reboot/data/etc/systemd/system/enable-kexec-reboot.service deleted file mode 100644 index 9b0bf175..00000000 --- a/core/modules/kexec-reboot/data/etc/systemd/system/enable-kexec-reboot.service +++ /dev/null @@ -1,7 +0,0 @@ -[Unit] -Description=Enable kexec-reboot via ctrl-alt-del -DefaultDependencies=no - -[Service] -Type=oneshot -ExecStart=/bin/sh -c "rm -f /etc/systemd/system/ctrl-alt-del.target; systemctl enable kexec.target; exit 0" diff --git a/core/modules/kexec-reboot/data/opt/openslx/scripts/systemd-kexec_load b/core/modules/kexec-reboot/data/opt/openslx/scripts/systemd-kexec_load index c7dae7bc..27be324a 100755 --- a/core/modules/kexec-reboot/data/opt/openslx/scripts/systemd-kexec_load +++ b/core/modules/kexec-reboot/data/opt/openslx/scripts/systemd-kexec_load @@ -53,15 +53,15 @@ kexec_load() { if ! dl_long "${base}/boot/ipxe?type=bash&entryid=$ipxeId&uuid=$(cat /etc/system-uuid)" > "${tempdir}/bootentry"; then echo "Could not download iPXE menu entry, falling back..." else - local ip="$( ip addr show dev br0 | awk '{ if ($1 == "inet") { print $2; exit 0 }}' )" - local gateway="$( ip route show dev br0 | awk '{ if ($1 == "default") {print $3; exit 0 }}' )" + local ip="$( ip addr show dev $SLX_PXE_NETIF | awk '{ if ($1 == "inet") { print $2; exit 0 }}' )" + local gateway="$( ip route show dev $SLX_PXE_NETIF | awk '{ if ($1 == "default") {print $3; exit 0 }}' )" local dns="${SLX_DNS// /,}" local hostname="${SLX_HOSTNAME}" local domain="${SLX_NET_DOMAIN}" local dnssl="${SLX_NET_SEARCH// /,}" local mac="${SLX_PXE_MAC}" local ntpsrv="${SLX_NTP_SERVER// /,}" - [ -z "$mac" ] && mac="$( ip addr show dev br0 | awk '{ if ($1 == "link/ether") { print $2; exit 0 }}' )" + [ -z "$mac" ] && mac="$( ip addr show dev $SLX_PXE_NETIF | awk '{ if ($1 == "link/ether") { print $2; exit 0 }}' )" . "${tempdir}/bootentry" if [ -z "$kernel" ]; then echo "iPXE boot entry is missing kernel, falling back..." diff --git a/core/modules/kiosk-chromium/module.conf.ubuntu b/core/modules/kiosk-chromium/module.conf.ubuntu index f5d87627..7cb1575c 100644 --- a/core/modules/kiosk-chromium/module.conf.ubuntu +++ b/core/modules/kiosk-chromium/module.conf.ubuntu @@ -1,10 +1,13 @@ #!/bin/bash REQUIRED_CONTENT_PACKAGES=" + chromium-browser + chromium-browser-l10n + fonts-noto-color-emoji jq xbindkeys libnss3-tools " -REQUIRED_INSTALLED_PACKAGES="$REQUIRED_CONTENT_PACKAGES" +REQUIRED_INSTALLED_PACKAGES="" REQUIRED_BINARIES="" REQUIRED_LIBRARIES="" REQUIRED_DIRECTORIES="" diff --git a/core/modules/lightdm-greeter-bwlp/module.build b/core/modules/lightdm-greeter-bwlp/module.build index 9698970e..e3d51560 100644 --- a/core/modules/lightdm-greeter-bwlp/module.build +++ b/core/modules/lightdm-greeter-bwlp/module.build @@ -18,9 +18,14 @@ build() { popd &>/dev/null # "install" mkdir -p "${DESTDIR}" || perror "Could not mkdir ${DESTDIR}!" - mv "${BUILDDIR}/qt-lightdm-greeter" "${DESTDIR}" - mkdir -p "${MODULE_BUILD_DIR}/usr/share/xgreeters" - cp "${SRCDIR}/qt-lightdm-greeter.desktop" "${MODULE_BUILD_DIR}/usr/share/xgreeters" + mv "${BUILDDIR}/qt-lightdm-greeter" "${DESTDIR}" || \ + perror "Failed to mv greeter to ${DESTDIR}." + mkdir -p "${MODULE_BUILD_DIR}/usr/share/xgreeters" || \ + perror "Failed to mkdir: ${MODULE_BUILD_DIR}/usr/share/xgreeters" + sed 's;^Exec=.*;Exec='"${DESTDIR#${MODULE_BUILD_DIR}}"'/qt-lightdm-greeter;' \ + "${SRCDIR}/qt-lightdm-greeter.desktop" > \ + "${MODULE_BUILD_DIR}/usr/share/xgreeters/qt-lightdm-greeter.desktop" \ + perror "Failed to fix greeter's path in .desktop file." COPYLIST="list_dpkg_output" [ -e "$COPYLIST" ] && rm "$COPYLIST" diff --git a/core/modules/lightdm/data/etc/X11/default-display-manager b/core/modules/lightdm/data/etc/X11/default-display-manager new file mode 100644 index 00000000..7d4e29bb --- /dev/null +++ b/core/modules/lightdm/data/etc/X11/default-display-manager @@ -0,0 +1 @@ +/usr/sbin/lightdm diff --git a/core/modules/lightdm/data/etc/systemd/system/display-manager.service b/core/modules/lightdm/data/etc/systemd/system/display-manager.service deleted file mode 120000 index 4fcfbb14..00000000 --- a/core/modules/lightdm/data/etc/systemd/system/display-manager.service +++ /dev/null @@ -1 +0,0 @@ -lightdm.service
\ No newline at end of file diff --git a/core/modules/lightdm/module.build b/core/modules/lightdm/module.build index 656d71a9..a86d0baa 100644 --- a/core/modules/lightdm/module.build +++ b/core/modules/lightdm/module.build @@ -12,9 +12,29 @@ build() { post_copy() { mkdir -p "${TARGET_BUILD_DIR}/var/lib/lightdm"{,-data} - local LDMUID=$(add_user "lightdm") - local LDMGID=$(add_group "lightdm") + local LDMUID=$(add_system_user "lightdm") + local LDMGID=$(add_system_group "lightdm") pinfo "lightdm user and group is $LDMUID $LDMGID" - chown -R "${LDMUID}:${LDMGID}" "${TARGET_BUILD_DIR}/var/lib/lightdm/" || perror "chowning '${TARGET_BUILD_DIR}/var/lib/lightdm/' failed." + chown -R "${LDMUID}:${LDMGID}" "${TARGET_BUILD_DIR}/var/lib/lightdm/" || \ + perror "chowning '${TARGET_BUILD_DIR}/var/lib/lightdm/' failed." + + # NOTE this might cause problems on systemd-based systems where use our + # own systemd module instead of using the distro's module, which we shouldn't + # in the first place! First, check if service file is present on system: + local LIGHTDM_SERVICE_PATH="$(systemctl show -p FragmentPath lightdm.service | cut -c 14-)" + if [ -z "${LIGHTDM_SERVICE_PATH}" ]; then + # Not found, so use our template + local LIGHTDM_SERVICE_TPL="${MODULE_DIR}/templates/lightdm.service" + [ -s "${LIGHTDM_SERVICE_TPL}" ] || perror "Unable to find template at ${LIGHTDM_SERVICE_TPL}." + local LIGHTDM_SERVICE_DEST="${TARGET_BUILD_DIR}/etc/systemd/system/lightdm.service" + mkdir -p "${LIGHTDM_SERVICE_DEST%/*}" || perror "Could not create '${LIGHTDM_SERVICE_DEST%/*}'." + cp "${MODULE_DIR}/templates/lightdm.service" "${LIGHTDM_SERVICE_DEST}" || \ + perror "Could not cp lightdm.service template to '${LIGHTDM_SERVICE_DEST}'." + LIGHTDM_SERVICE_PATH="${LIGHTDM_SERVICE_DEST//${TARGET_BUILD_DIR}/}" + fi + # either way link display-manager to LIGHTDM_SERVICE_PATH + ln -sf "${LIGHTDM_SERVICE_PATH}" \ + "${TARGET_BUILD_DIR}/etc/systemd/system/display-manager.service" || \ + perror "Could not set lightdm as display-manager!" } diff --git a/core/modules/lightdm/data/etc/systemd/system/lightdm.service b/core/modules/lightdm/templates/lightdm.service index baa93f2f..d9002404 100644 --- a/core/modules/lightdm/data/etc/systemd/system/lightdm.service +++ b/core/modules/lightdm/templates/lightdm.service @@ -1,7 +1,7 @@ [Unit] Description=LightDM Display Manager Conflicts=getty@tty7.service -After=dev-tty7.device systemd-user-sessions.service load-gfx-driver.service setup-slx-addon@vmware.service setup-slx-addon@virtualbox.service +After=systemd-user-sessions.service load-gfx-driver.service [Service] ExecStart=/usr/sbin/lightdm diff --git a/core/modules/network-online-slx-targets/data/etc/systemd/system/network-online.target.d/00-slx-targets.conf b/core/modules/network-online-slx-targets/data/etc/systemd/system/network-online.target.d/00-slx-targets.conf index 898d20b1..81208043 100644 --- a/core/modules/network-online-slx-targets/data/etc/systemd/system/network-online.target.d/00-slx-targets.conf +++ b/core/modules/network-online-slx-targets/data/etc/systemd/system/network-online.target.d/00-slx-targets.conf @@ -1,3 +1,4 @@ [Unit] -Wants=network-gateway.target network-dns.target +Wants=network-gateway.target network-dns.target network.target Before=network-gateway.target network-dns.target +After=network.target diff --git a/core/modules/nvidia-libs/data/addon-init b/core/modules/nvidia-libs/data/addon-init index ae0734c2..ebbf0b62 100755 --- a/core/modules/nvidia-libs/data/addon-init +++ b/core/modules/nvidia-libs/data/addon-init @@ -1,10 +1,10 @@ #!/bin/ash -[ -e "/opt/openslx/etc/nvidia.whiteout" ] || exit 0 +[ -e "/opt/openslx/etc/nvidia_libs.whiteout" ] || exit 0 while read line; do rm -f -- "$line" -done < "/opt/openslx/etc/nvidia.whiteout" +done < "/opt/openslx/etc/nvidia_libs.whiteout" exit 0 diff --git a/core/modules/nvidia-libs/module.build b/core/modules/nvidia-libs/module.build index b35e6fd2..d2a5ee63 100644 --- a/core/modules/nvidia-libs/module.build +++ b/core/modules/nvidia-libs/module.build @@ -9,3 +9,11 @@ module_load() { MODULE_BUILD_DIR="$SRC" } +post_copy() { + # generate addon-required for this version + cat <<-EOF > "${TARGET_BUILD_DIR}/addon-required" + #!/bin/ash + [ "\$( cat /sys/module/nvidia/version )" = "$VERSION" ] + EOF + chmod +x "${TARGET_BUILD_DIR}/addon-required" +} diff --git a/core/modules/pam-bwidm/module.conf b/core/modules/pam-bwidm/module.conf index 237dd69c..c8a55dfb 100644 --- a/core/modules/pam-bwidm/module.conf +++ b/core/modules/pam-bwidm/module.conf @@ -1,3 +1,6 @@ #!/bin/bash +REQUIRED_MODULES=" + slxlog +" REQUIRED_BINARIES=" " diff --git a/core/modules/pam-common-share/module.conf b/core/modules/pam-common-share/module.conf index 8811668a..f20668f6 100644 --- a/core/modules/pam-common-share/module.conf +++ b/core/modules/pam-common-share/module.conf @@ -1,4 +1,7 @@ #!/bin/bash +REQUIRED_MODULES=" + slxlog +" REQUIRED_BINARIES="" REQUIRED_LIBRARIES="" REQUIRED_DIRECTORIES="" diff --git a/core/modules/pam/data/etc/profile.d/00-user-env.sh b/core/modules/pam/data/etc/profile.d/00-user-env.sh new file mode 100644 index 00000000..a2d10989 --- /dev/null +++ b/core/modules/pam/data/etc/profile.d/00-user-env.sh @@ -0,0 +1,14 @@ +#!/bin/ash + +# Stuff we might wanna know +PWENT= +[ -n "$UID" ] && PWENT=`getent passwd "$UID"` +[ -z "$PWENT" ] && [ -n "$PAM_USER" ] && PWENT=`getent passwd "$PAM_USER"` +if [ -n "$PWENT" ]; then + export USER=`echo "$PWENT" | awk -F ':' '{print $1}'` + export GID=`echo "$PWENT" | awk -F ':' '{print $4}'` + export HOME=`echo "$PWENT" | awk -F ':' '{print $6}'` + export GROUP=`id -gn` + export LOGNAME=$USER + export HOSTNAME=`hostname` +fi diff --git a/core/modules/pam/module.conf b/core/modules/pam/module.conf index 86b91b8d..7789139d 100644 --- a/core/modules/pam/module.conf +++ b/core/modules/pam/module.conf @@ -1,4 +1,7 @@ #!/bin/bash +REQUIRED_MODULES=" + slxlog +" REQUIRED_BINARIES=" ldapsearch rpc.gssd diff --git a/core/modules/polkit/module.build b/core/modules/polkit/module.build index b956f23c..b1e61f66 100644 --- a/core/modules/polkit/module.build +++ b/core/modules/polkit/module.build @@ -17,6 +17,6 @@ build () { post_copy() { #Add Polkit User/Group/Shadow to Stage3.2, required on opensuse pinfo "Adding polkitd user to target system..." - add_user "polkitd" + add_system_user "polkitd" } diff --git a/core/modules/printergui/data/opt/openslx/scripts/systemd-printergui_preparation b/core/modules/printergui/data/opt/openslx/scripts/systemd-printergui_preparation index 29971666..d130f470 100755 --- a/core/modules/printergui/data/opt/openslx/scripts/systemd-printergui_preparation +++ b/core/modules/printergui/data/opt/openslx/scripts/systemd-printergui_preparation @@ -13,7 +13,7 @@ mv -n "$SRCDIR"/* "$DESTDIR" cd "$SRCDIR" for i in "$DESTDIR"/*; do - ln -s "$PRINTPWGUI" $(basename "$i") + ln -sf "$PRINTPWGUI" $(basename "$i") done exit 0 diff --git a/core/modules/printergui/module.conf b/core/modules/printergui/module.conf index 2746168f..3875944b 100644 --- a/core/modules/printergui/module.conf +++ b/core/modules/printergui/module.conf @@ -1,4 +1,7 @@ #!/bin/bash +REQUIRED_MODULES=" + slxlog +" REQUIRED_GIT="git://git.openslx.org/openslx-ng/printergui.git" REQUIRED_COMMIT="HEAD" REQUIRED_BINARIES=" diff --git a/core/modules/redsocks/module.build b/core/modules/redsocks/module.build index 9dacd88b..b1298c9d 100644 --- a/core/modules/redsocks/module.build +++ b/core/modules/redsocks/module.build @@ -20,6 +20,6 @@ build () { } post_copy() { - add_user redsocks + add_system_user redsocks } diff --git a/core/modules/run-virt/data/etc/systemd/system/graphical.target.wants/run-virt-dhcpd.service b/core/modules/run-virt/data/etc/systemd/system/basic.target.wants/run-virt-dhcpd.service index a47d9c0b..a47d9c0b 120000 --- a/core/modules/run-virt/data/etc/systemd/system/graphical.target.wants/run-virt-dhcpd.service +++ b/core/modules/run-virt/data/etc/systemd/system/basic.target.wants/run-virt-dhcpd.service diff --git a/core/modules/run-virt/data/etc/systemd/system/graphical.target.wants/run-virt-env.service b/core/modules/run-virt/data/etc/systemd/system/basic.target.wants/run-virt-env.service index c47218eb..c47218eb 120000 --- a/core/modules/run-virt/data/etc/systemd/system/graphical.target.wants/run-virt-env.service +++ b/core/modules/run-virt/data/etc/systemd/system/basic.target.wants/run-virt-env.service diff --git a/core/modules/run-virt/data/etc/systemd/system/run-virt-env.service b/core/modules/run-virt/data/etc/systemd/system/run-virt-env.service index 88b76789..2c602076 100644 --- a/core/modules/run-virt/data/etc/systemd/system/run-virt-env.service +++ b/core/modules/run-virt/data/etc/systemd/system/run-virt-env.service @@ -1,8 +1,9 @@ [Unit] Description=Sets up the virtualization environment Before=graphical.target system-check.service -Wants=network-dns.target system-check.service -After=network-dns.target +After=systemd-tmpfiles-setup.service bridge-additional-nics.service +Wants=systemd-tmpfiles-setup.service system-check.service bridge-additional-nics.service +DefaultDependencies=no [Service] Type=oneshot diff --git a/core/modules/run-virt/data/etc/tmpfiles.d/openslx-log.conf b/core/modules/run-virt/data/etc/tmpfiles.d/openslx-log.conf new file mode 100644 index 00000000..4d93fb9c --- /dev/null +++ b/core/modules/run-virt/data/etc/tmpfiles.d/openslx-log.conf @@ -0,0 +1 @@ +d /var/log/openslx 0777 root root diff --git a/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env b/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env index 6b79d0ec..2a4d75da 100755 --- a/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env +++ b/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env @@ -24,6 +24,7 @@ ################################################################################ # source config file with vars (e.g. ipaddr, macaddr, HOSTNAME) +[ -s /opt/openslx/config ] || exit 0 . /opt/openslx/config # from plugins/vmchooser/XX_vmchooser.sh @@ -193,8 +194,13 @@ getips () { # Output in one line by using echo without quotes echo $(busybox timeout 2 nslookup "$1" 2>/dev/null | grep -A 4 '^Name:' | grep -E '^Address\s*[0-9]*: ' | awk -F': ' '{print $2}' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | awk '{print $1}') } - +getresolvconf() { + awk -vattr="$1" '$1 == attr {for (i=2; i<=NF; i++) printf "%s ",$i}' /etc/resolv.conf +} # read the DNS configuration and configure the udhcpd +SLX_DNS="$(getresolvconf nameserver)" +SLX_NET_DOMAIN="$(getresolvconf domain)" +SLX_NET_SEARCH="$(getresolvconf search)" [ -z "${SLX_DNS}" ] && SLX_DNS="8.8.8.8 8.8.4.4" [ -z "${SLX_NET_DOMAIN}" ] && SLX_NET_DOMAIN="$FALLBACK_DOMAIN" [ -z "${SLX_NET_SEARCH}" ] && SLX_NET_SEARCH="$FALLBACK_DOMAIN" diff --git a/core/modules/run-virt/module.conf b/core/modules/run-virt/module.conf index b6de1789..0af71cbe 100644 --- a/core/modules/run-virt/module.conf +++ b/core/modules/run-virt/module.conf @@ -1,5 +1,7 @@ #!/bin/bash REQUIRED_MODULES=" + busybox + slxlog iptables " REQUIRED_BINARIES=" diff --git a/core/modules/safe-mode/data/etc/systemd/system/exam.service b/core/modules/safe-mode/data/etc/systemd/system/exam.service index 14473a6f..646c8b36 100644 --- a/core/modules/safe-mode/data/etc/systemd/system/exam.service +++ b/core/modules/safe-mode/data/etc/systemd/system/exam.service @@ -1,7 +1,8 @@ [Unit] Description=Sets up safe mode (no magic keys, no tty switch, no openbox menu) DefaultDependencies=no -Before=graphical.target display-manager.target +Before=basic.target systemd-logind.service +After=systemd-sysctl.service [Service] Type=oneshot diff --git a/core/modules/slx-issue/data/etc/systemd/system/update-etc_issue.service b/core/modules/slx-issue/data/etc/systemd/system/update-etc_issue.service index bdfab085..287b2b44 100644 --- a/core/modules/slx-issue/data/etc/systemd/system/update-etc_issue.service +++ b/core/modules/slx-issue/data/etc/systemd/system/update-etc_issue.service @@ -1,7 +1,7 @@ [Unit] Description=Update /etc/issue -After=setup-partitions.service -Before=getty.target shutdown.target +Requires=getty-pre.target +Before=getty-pre.target shutdown.target DefaultDependencies=no [Service] diff --git a/core/modules/slxlog/data/opt/openslx/bin/slxlog b/core/modules/slxlog/data/opt/openslx/bin/slxlog new file mode 100755 index 00000000..09cb9b79 --- /dev/null +++ b/core/modules/slxlog/data/opt/openslx/bin/slxlog @@ -0,0 +1,104 @@ +#!/bin/ash + +################## +# Remote logging # +################## +# +# Usage: slxlog [-e | --echo] "logtype" "Human readable string" ["file name which's contents should be sent too"] +# -e or --echo will echo message to stdout too +# + +export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin" + +. /opt/openslx/config +[ -z "$SLX_REMOTE_LOG" ] && exit 3 + +USER=$(whoami) +LOGCHECK="/tmp/remote_log_check-$USER" +NOW=$(date +%s) +DELFILE= +SYNC= + +while [ $# -gt 0 ]; do + case "$1" in + -e|--echo) + echo "$@" + ;; + -d|--delete) + DELFILE=yes + ;; + -s|--sync) + SYNC=yes + ;; + *) + break + ;; + esac + shift +done + +[ $# -eq 0 ] && exit 0 + +TYPE="$1" + +# Simple spamcheck. Not very tamper-proof, but if you'd want to spam the server +# you could do it anyways. This is to protect from accidental loops calling this. +if [ -r "$LOGCHECK" ]; then + # Allow max 150 messages in total + LINES=$(cat "$LOGCHECK" | wc -l) + [ "$LINES" -gt "150" ] && exit 1 + # Allow max 5 of same type messages in 30 seconds + LINES=$(grep "$TYPE" "$LOGCHECK" | wc -l) + if [ "$LINES" -ge "5" ]; then + LAST=$(grep "$TYPE" "$LOGCHECK" | tail -n 5 | head -n 1 | awk '{print $1}') + if [ -n "$LAST" ]; then + DIFF="$(( $NOW - $LAST ))" + [ "$DIFF" -lt "30" ] && exit 2 + fi + fi +fi +echo "$NOW $TYPE" >> "$LOGCHECK" +chmod 0600 "$LOGCHECK" 2>/dev/null + +if [ $# -lt 2 ]; then + MSG="Missing text for $@" +else + MSG="$2" +fi +MSG="[$USER] $MSG" + +if [ $# -gt 2 ]; then + EXTRA="$3" +fi + +if [ -n "$SLX_DEBUG" ]; then + CURLLOG="/tmp/slxlog.$USER" +else + CURLLOG="/dev/null" +fi + +UUID= +if [ -s /run/system-uuid ]; then + UUID=$(cat /run/system-uuid) +fi + +submitlog () { + if [ -n "$EXTRA" ] && [ -r "$EXTRA" -a -s "$EXTRA" ] && [ "$(stat -c %s "$EXTRA")" -lt "10000" ]; then # valid file attachment + curl --data-urlencode "uuid=$UUID" --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc@$EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 + elif [ -z "$EXTRA" ]; then # no attachment + curl --data-urlencode "uuid=$UUID" --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 + elif [ -s "$EXTRA" ]; then # attachment file to big (more than 10k) + curl --data-urlencode "uuid=$UUID" --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Attachment too large: $EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 + else # empty attachment file (or missing) + curl --data-urlencode "uuid=$UUID" --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Attachment missing/empty: $EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 + fi + [ -n "$DELFILE" ] && [ -n "$EXTRA" ] && rm -f -- "$EXTRA" +} + +if [ -z "$SYNC" ]; then + submitlog & + exit 0 +fi + +submitlog + diff --git a/core/modules/slxlog/module.build b/core/modules/slxlog/module.build new file mode 100644 index 00000000..241bcd5e --- /dev/null +++ b/core/modules/slxlog/module.build @@ -0,0 +1,12 @@ +#!/bin/bash +fetch_source() { + : +} + +build() { + pinfo "Static module, nothing to build." +} + +post_copy() { + : +} diff --git a/core/modules/slxlog/module.conf b/core/modules/slxlog/module.conf new file mode 100644 index 00000000..d5d021fa --- /dev/null +++ b/core/modules/slxlog/module.conf @@ -0,0 +1,2 @@ +#!/bin/bash +# Nothing diff --git a/core/modules/smartctl/module.conf b/core/modules/smartctl/module.conf index a2c8a665..36738c3e 100644 --- a/core/modules/smartctl/module.conf +++ b/core/modules/smartctl/module.conf @@ -1,4 +1,7 @@ #!/bin/bash +REQUIRED_MODULES=" + slxlog +" REQUIRED_BINARIES=" smartctl " diff --git a/core/modules/sshd/data/etc/issue.net b/core/modules/sshd/data/etc/issue.net index 7dfbddb5..b59a27ea 100644 --- a/core/modules/sshd/data/etc/issue.net +++ b/core/modules/sshd/data/etc/issue.net @@ -1,6 +1,6 @@ ++++++++++++++++++++++++++++++++++++++ + + -+ MiniLinux SSH Session + ++ MaxiLinux SSH Session + + + ++++++++++++++++++++++++++++++++++++++ diff --git a/core/modules/sshd/data/etc/systemd/system/ssh.service b/core/modules/sshd/data/etc/systemd/system/ssh.service new file mode 120000 index 00000000..4899eed6 --- /dev/null +++ b/core/modules/sshd/data/etc/systemd/system/ssh.service @@ -0,0 +1 @@ +sshd.service
\ No newline at end of file diff --git a/core/modules/sshd/data/etc/systemd/system/sshd.service b/core/modules/sshd/data/etc/systemd/system/sshd.service index fc711808..999187cd 100644 --- a/core/modules/sshd/data/etc/systemd/system/sshd.service +++ b/core/modules/sshd/data/etc/systemd/system/sshd.service @@ -1,5 +1,7 @@ [Unit] Description=OpenSSH Daemon +Requires=systemd-tmpfiles-setup.service +After=systemd-tmpfiles-setup.service [Service] ExecStart=/usr/sbin/sshd -D diff --git a/core/modules/systemd/module.build b/core/modules/systemd/module.build index 2e11bcd7..3cca1928 100644 --- a/core/modules/systemd/module.build +++ b/core/modules/systemd/module.build @@ -96,7 +96,7 @@ build () { } post_copy() { - add_user "kvm" - add_user "systemd-journal-upload" + add_system_user "kvm" + add_system_user "systemd-journal-upload" } diff --git a/core/modules/vbox-src/data/addon-init b/core/modules/vbox-src/data/addon-init deleted file mode 100755 index e52bf941..00000000 --- a/core/modules/vbox-src/data/addon-init +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/ash - -addgroup --system vboxusers - -systemctl daemon-reload -systemctl start vbox -exit 0 - diff --git a/core/modules/vbox-src/data/etc/systemd/system/graphical.target.wants/vbox.service b/core/modules/vbox-src/data/etc/systemd/system/basic.target.wants/vbox.service index b8591bd1..b8591bd1 120000 --- a/core/modules/vbox-src/data/etc/systemd/system/graphical.target.wants/vbox.service +++ b/core/modules/vbox-src/data/etc/systemd/system/basic.target.wants/vbox.service diff --git a/core/modules/vbox-src/data/etc/systemd/system/vbox.service b/core/modules/vbox-src/data/etc/systemd/system/vbox.service index 6b6347da..14645f19 100644 --- a/core/modules/vbox-src/data/etc/systemd/system/vbox.service +++ b/core/modules/vbox-src/data/etc/systemd/system/vbox.service @@ -1,7 +1,8 @@ [Unit] Description=Sets up the virtual box environment -Requires=run-virt-env.service setup-partitions.service network.target -After=run-virt-env.service setup-partitions.service network.target +Requires=run-virt-env.service +After=run-virt-env.service +DefaultDependencies=no [Service] Type=oneshot diff --git a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc index ec0e4dde..a511a911 100755 --- a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc +++ b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc @@ -182,8 +182,8 @@ setup_usb() { } setup_sound() { - # force ALSA driver for now and change when others become available - set_attr "/VirtualBox/Machine/Hardware/AudioAdapter" "driver" "ALSA" + # Use Pulse driver + set_attr "/VirtualBox/Machine/Hardware/AudioAdapter" "driver" "Pulse" } setup_displays() { diff --git a/core/modules/vbox-src/module.build b/core/modules/vbox-src/module.build index c5d89c65..4d4daa60 100644 --- a/core/modules/vbox-src/module.build +++ b/core/modules/vbox-src/module.build @@ -106,5 +106,5 @@ build() { } post_copy() { - : + add_system_group "vboxusers" } diff --git a/core/modules/vmchooser2/data/etc/lightdm/lightdm.conf.d/00-slx-xsessions.conf b/core/modules/vmchooser2/data/etc/lightdm/lightdm.conf.d/00-slx-xsessions.conf new file mode 100644 index 00000000..7ba5cd56 --- /dev/null +++ b/core/modules/vmchooser2/data/etc/lightdm/lightdm.conf.d/00-slx-xsessions.conf @@ -0,0 +1,2 @@ +[LightDM] +sessions-directory=/opt/openslx/xsessions diff --git a/core/modules/vmchooser2/module.conf b/core/modules/vmchooser2/module.conf index c62a84c9..e73bbbbd 100644 --- a/core/modules/vmchooser2/module.conf +++ b/core/modules/vmchooser2/module.conf @@ -1,5 +1,6 @@ #!/bin/bash REQUIRED_MODULES=" + slxlog qt5core " REQUIRED_GIT="git://git.openslx.org/openslx-ng/vmchooser2.git" diff --git a/core/modules/vmware-common/data/etc/systemd/system/graphical.target.wants/vmware.service b/core/modules/vmware-common/data/etc/systemd/system/basic.target.wants/vmware.service index 7deb4820..7deb4820 120000 --- a/core/modules/vmware-common/data/etc/systemd/system/graphical.target.wants/vmware.service +++ b/core/modules/vmware-common/data/etc/systemd/system/basic.target.wants/vmware.service diff --git a/core/modules/vmware-common/data/etc/systemd/system/vmware.service b/core/modules/vmware-common/data/etc/systemd/system/vmware.service index 78f75726..baab3747 100644 --- a/core/modules/vmware-common/data/etc/systemd/system/vmware.service +++ b/core/modules/vmware-common/data/etc/systemd/system/vmware.service @@ -1,7 +1,8 @@ [Unit] Description=Sets up the vmware environment -Requires=run-virt-env.service setup-partitions.service network.target -After=run-virt-env.service setup-partitions.service network.target +Requires=run-virt-env.service +After=run-virt-env.service +DefaultDependencies=no [Service] Type=oneshot diff --git a/core/modules/vmware-common/data/opt/openslx/pam/hooks/session-open.d/vmware-tmpfs-dir b/core/modules/vmware-common/data/opt/openslx/pam/hooks/session-open.d/vmware-tmpfs-dir new file mode 100644 index 00000000..ed5633ed --- /dev/null +++ b/core/modules/vmware-common/data/opt/openslx/pam/hooks/session-open.d/vmware-tmpfs-dir @@ -0,0 +1,17 @@ +create_vmware_tmpdir() { + local tmpdir="/tmp/vmware-${PAM_USER}" + [ -d "$tmpdir" ] || mkdir -p "$tmpdir" + grep -qE '^tmpfs\s+'"$tmpdir" /proc/mounts && return 0 + + local mount_opts="-o mode=0700,size=100%" + local user_uid="$(id -u $PAM_USER)" + [ -n "$user_uid" ] && mount_opts="${mount_opts},uid=${user_uid}" + local user_gid="$(id -g $PAM_USER)" + [ -n "$user_gid" ] && mount_opts="${mount_opts},gid=${user_gid}" + # NO QUOTES!!!1 + mount -t tmpfs tmpfs ${mount_opts} "$tmpdir" +} +if [ "x$PAM_SERVICE" != "xsu" -a "x$PAM_SERVICE" != "xsudo" ]; then + create_vmware_tmpdir +fi +true diff --git a/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc b/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc index 41f5840e..4c62bb38 100644 --- a/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc +++ b/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc @@ -158,6 +158,9 @@ setup_vcpu_ram() { MemAllowAutoScaleDown = "FALSE" MemTrimRate = "-1" HEREEND + + # temporary solution: RAM backing file on a tmpfs + echo 'mainmem.backing = "unnamed"' >> "$TMPCONFIG" } setup_usb() { diff --git a/core/modules/vmware-common/module.conf b/core/modules/vmware-common/module.conf index 8811668a..9b75fd6b 100644 --- a/core/modules/vmware-common/module.conf +++ b/core/modules/vmware-common/module.conf @@ -1,4 +1,5 @@ #!/bin/bash +REQUIRED_MODULES="slxlog" REQUIRED_BINARIES="" REQUIRED_LIBRARIES="" REQUIRED_DIRECTORIES="" diff --git a/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version b/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version index 887e995b..7d1190c5 100755 --- a/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version +++ b/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version @@ -2,6 +2,9 @@ # This script checks whether given VMware version supports the CPU: # * Intel: check for "VMX Unrestricted Guest" CPU flag # * AMD: check if CPU family is Bulldozer or newer +# +# It can be called inside a dracut context and tries to do +# chroot magic to call/load the required tools. VIRTTYPE="$( grep -m1 '^flags\s*:' /proc/cpuinfo | grep -woF -e svm -e vmx )" diff --git a/core/modules/vmware12/data/addon-required b/core/modules/vmware12/data/addon-required new file mode 100644 index 00000000..6261292c --- /dev/null +++ b/core/modules/vmware12/data/addon-required @@ -0,0 +1,19 @@ +#!/bin/bash + +# the vmware helper needs the kmod msr and the tool rdmsr, +# /dev, /sys and /proc to properly detect the CPU info. + +bindmount=("/dev" "/proc" "/sys") + +for bm in "${bindmount[@]}"; do + mount --bind "$bm" "${NEWROOT}/${bm}" +done + +export PATH="$PATH:/opt/openslx/sbin:/opt/openslx/bin" +version="$(chroot "$NEWROOT" vmware-get-supported-version)" + +for bm in "${bindmount[@]}"; do + umount "${NEWROOT}/${bm}" +done + +[ -n "$version" ] && [ "$version" = "legacy" ] diff --git a/core/modules/vmware12/data/opt/openslx/bin/vmplayer b/core/modules/vmware12/data/opt/openslx/bin/vmplayer index f94c8794..afac3c94 100755 --- a/core/modules/vmware12/data/opt/openslx/bin/vmplayer +++ b/core/modules/vmware12/data/opt/openslx/bin/vmplayer @@ -9,7 +9,10 @@ PROG=$(basename $0) # various hacks to help vmplayer find its own libs -.- export VMWARE_USE_SHIPPED_LIBS=force -export LD_LIBRARY_PATH=$( find /usr/lib/vmware/lib/ -maxdepth 1 -mindepth 1 -type d | awk 'BEGIN{p=""}{p=p$0":"}END{print p}' ) +export LD_LIBRARY_PATH=$( \ + find /usr/lib/vmware/lib/ -maxdepth 1 -mindepth 1 -type d \ + | grep -v libfontconfig \ + | awk 'BEGIN{p=""}{p=p$0":"}END{print p}' ) exec "$PREFIX/lib/wrapper-gtk24.sh" \ "$PREFIX/lib" \ diff --git a/core/modules/vmware15/data/addon-required b/core/modules/vmware15/data/addon-required new file mode 100644 index 00000000..a86e41bc --- /dev/null +++ b/core/modules/vmware15/data/addon-required @@ -0,0 +1,19 @@ +#!/bin/bash + +# the vmware helper needs the kmod msr and the tool rdmsr, +# /dev, /sys and /proc to properly detect the CPU info. + +bindmount=("/dev" "/proc" "/sys") + +for bm in "${bindmount[@]}"; do + mount --bind "$bm" "${NEWROOT}/${bm}" +done + +export PATH="$PATH:/opt/openslx/sbin:/opt/openslx/bin" +version="$(chroot "$NEWROOT" vmware-get-supported-version)" + +for bm in "${bindmount[@]}"; do + umount "${NEWROOT}/${bm}" +done + +[ -n "$version" ] && [ "$version" = "new" ] diff --git a/core/modules/vmware15/module.build b/core/modules/vmware15/module.build index c85754ad..f5e96f9c 100644 --- a/core/modules/vmware15/module.build +++ b/core/modules/vmware15/module.build @@ -185,9 +185,6 @@ post_copy() { "$guid" "${TARGET_BUILD_DIR}/usr/share/icons/hicolor/" done - # fix vmware-usbarbitrator bug - date +'%Y.%m.%d' >"${TARGET_BUILD_DIR}/etc/arch-release" - mkdir -p "$TARGET_BUILD_DIR/lib/modules/vmware/" cp "${MODULE_BUILD_DIR}/lib/modules/$TARGET_KERNEL_LONG/vmplayer/"* "$TARGET_BUILD_DIR/lib/modules/vmware/" || perror "Could not cp vmware modules to target!" diff --git a/core/modules/vmware16/data/addon-required b/core/modules/vmware16/data/addon-required new file mode 100644 index 00000000..a86e41bc --- /dev/null +++ b/core/modules/vmware16/data/addon-required @@ -0,0 +1,19 @@ +#!/bin/bash + +# the vmware helper needs the kmod msr and the tool rdmsr, +# /dev, /sys and /proc to properly detect the CPU info. + +bindmount=("/dev" "/proc" "/sys") + +for bm in "${bindmount[@]}"; do + mount --bind "$bm" "${NEWROOT}/${bm}" +done + +export PATH="$PATH:/opt/openslx/sbin:/opt/openslx/bin" +version="$(chroot "$NEWROOT" vmware-get-supported-version)" + +for bm in "${bindmount[@]}"; do + umount "${NEWROOT}/${bm}" +done + +[ -n "$version" ] && [ "$version" = "new" ] diff --git a/core/modules/xorg/data/etc/X11/Xsession b/core/modules/xorg/data/etc/X11/Xsession index 33a003ac..86ecfc14 100755 --- a/core/modules/xorg/data/etc/X11/Xsession +++ b/core/modules/xorg/data/etc/X11/Xsession @@ -28,8 +28,10 @@ errormsg () { # Make sure we source the global profile - needed for ssh-agent, etc. [ -e "/etc/profile" ] && . "/etc/profile" -# Workaround to start Xsession. The original Xsession script includes error handling functionality and sources other scrips from the Xsession.d/ directory. +# Make sure we source the global profile - needed for ssh-agent, etc. +[ -e "/etc/profile" ] && source "/etc/profile" +# Workaround to start Xsession. The original Xsession script includes error handling functionality and sources other scrips from the Xsession.d/ directory. SESSIONDIR="/etc/X11/Xsession.d" tmpfile="$( mktemp "/tmp/xsession-log-$( date +%s )-XXXXXX" )" diff --git a/core/modules/xorg/data/usr/share/backgrounds/bwlp-1920x1080.png b/core/modules/xorg/data/usr/share/backgrounds/bwlp-1920x1080.png Binary files differnew file mode 100644 index 00000000..bcad928e --- /dev/null +++ b/core/modules/xorg/data/usr/share/backgrounds/bwlp-1920x1080.png diff --git a/core/modules/xorg/module.conf b/core/modules/xorg/module.conf index dfa86b3a..402b22e1 100644 --- a/core/modules/xorg/module.conf +++ b/core/modules/xorg/module.conf @@ -1,4 +1,7 @@ #!/bin/bash +REQUIRED_MODULES=" + slxlog +" REQUIRED_BINARIES=" X Xorg diff --git a/core/modules/zram-swap/data/etc/systemd/system/sysinit.target.wants/zram-swap.service b/core/modules/zram-swap/data/etc/systemd/system/sysinit.target.wants/zram-swap.service new file mode 120000 index 00000000..c1754b11 --- /dev/null +++ b/core/modules/zram-swap/data/etc/systemd/system/sysinit.target.wants/zram-swap.service @@ -0,0 +1 @@ +../zram-swap.service
\ No newline at end of file diff --git a/core/modules/zram-swap/data/etc/systemd/system/zram-swap.service b/core/modules/zram-swap/data/etc/systemd/system/zram-swap.service new file mode 100644 index 00000000..a458b380 --- /dev/null +++ b/core/modules/zram-swap/data/etc/systemd/system/zram-swap.service @@ -0,0 +1,10 @@ +[Unit] +Description=Setup zram swap partitions +DefaultDependencies=no +Wants=swap.target +Before=swap.target + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-zram_swap +RemainAfterExit=yes diff --git a/core/modules/zram-swap/data/opt/openslx/scripts/systemd-zram_swap b/core/modules/zram-swap/data/opt/openslx/scripts/systemd-zram_swap new file mode 100755 index 00000000..28a803d8 --- /dev/null +++ b/core/modules/zram-swap/data/opt/openslx/scripts/systemd-zram_swap @@ -0,0 +1,116 @@ +#!/bin/ash +# ----------------------------------------------------------------------------- +# +# Copyright (c) 2013..2018 bwLehrpool-Projektteam +# +# This program/file is free software distributed under the GPL version 2. +# See https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# If you have any feedback please consult https://bwlehrpool.de and +# send your feedback to support@bwlehrpool.de. +# +# General information about bwLehrpool can be found at https://bwlehrpool.de +# +# ----------------------------------------------------------------------------- +# +# Local hard disk autodetection script for OpenSLX linux stateless clients, +# detecting swap and special partitions + +############################################################################# + +export PATH=$PATH:/opt/openslx/sbin:/opt/openslx/bin + +# Add zram swap +# Some older ubuntu kernels had a problem here, see https://bugs.launchpad.net/ubuntu/+source/linux-lts-raring/+bug/1217189 +# So make sure you're up to date + +make_swap () { + [ $# -ne 3 ] && echo "make_swap: Wrong parameter count $#" && return 1 + local USE="$1" + local DEV="$2" + local STREAMS="$3" + echo "$USE" > "/sys/block/zram${DEV}/disksize" || return 1 + [ -n "$STREAMS" ] && echo "$STREAMS" > "/sys/block/zram${DEV}/max_comp_streams" + ( + mkswap "/dev/zram${DEV}" + swapon "/dev/zram${DEV}" -p 1000 # high priority (in case we have hdd swap 0x82, prefer zram) + ) & +} + +# Count physical CPUs +CPUS=$(cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | sort -u | wc -l) # cat for * +if [ -z "$CPUS" ]; then + echo "ERROR: Could not determine CPU core count" +else + CPUS=1 +fi + +KERN=$(uname -r) +if [ "${KERN%%.*}" -le 4 ]; then + DEVS=$CPUS + [ "$DEVS" -gt "16" ] && DEVS=16 # zram can only handle up to 32 devices, the system can apparently even just handle 29 swap partitions, so use a reasonable upper limit + STREAMS= +else + DEVS=1 + STREAMS=$CPUS +fi + +if [ -e "/sys/class/zram-control/hot_add" ]; then + : # nothing to do, loaded and hot_add available +elif ! modprobe zram "num_devices=$DEVS"; then + echo "ERROR: Could not load zram module" + exit 1 +fi + +TOTAL=$(grep ^MemTotal /proc/meminfo | awk '{print $2}') +USE=$(( TOTAL / ( 2 * DEVS ) )) +echo "Have $CPUS cores, $TOTAL kb mem, use $USE kb zram swap each for $DEVS devices." +USE=$(( USE * 1024 )) +DEV=0 +NUM=0 +FAILS=0 +while [ "$NUM" -lt "$DEVS" ]; do + if [ -e "/sys/block/zram${DEV}" ]; then + if ! [ -e "/sys/block/zram${DEV}/initstate" ] || [ "$(cat "/sys/block/zram${DEV}/initstate")" = 0 ]; then + if make_swap "$USE" "$DEV" "$STREAMS"; then + NUM=$(( NUM + 1 )) + fi + fi + DEV=$(( DEV + 1 )) + elif [ -e "/sys/class/zram-control/hot_add" ]; then + DEV=$(cat /sys/class/zram-control/hot_add) + if [ -z "$DEV" ]; then + echo "ERROR: Cannot hot_add another zram device" + break + fi + if make_swap "$USE" "$DEV" "$STREAMS"; then + NUM=$(( NUM + 1 )) + else + FAILS=$(( FAILS + 1 )) + if [ "$FAILS" -gt 4 ]; then + echo "ERROR: Could not swap on hot added device -- giving up" + break + fi + fi + DEV=$(( DEV + 1 )) + else + echo "ERROR: Cannot add another zram device: No hot_add support" + break + fi +done + +# Increase min free memory so we have enough mem available when trying to move +# something to zram swap. We want 1%, or at least 64MiB +CURRENT=$(cat "/proc/sys/vm/min_free_kbytes") +TOTAL=$(awk '{ if ($1 == "MemTotal:") { print $2; exit } }' /proc/meminfo) +WANT=$(( TOTAL / 100 )) +[ "$WANT" -gt 65535 ] || WANT=65535 # minimum 64M +if [ "$CURRENT" -lt "$WANT" ]; then + echo "$WANT" > "/proc/sys/vm/min_free_kbytes" +fi + +# Wait, so we don't trigger swap.target too early +wait + +exit 0 + diff --git a/core/modules/zram-swap/module.build b/core/modules/zram-swap/module.build new file mode 100644 index 00000000..302131f1 --- /dev/null +++ b/core/modules/zram-swap/module.build @@ -0,0 +1,20 @@ +#!/bin/bash +fetch_source() { + : +} + +build() { + local BIN_LOCS= + for BIN in ${REQUIRED_BINARIES}; do + pinfo "checking $BIN" + BIN_LOCS+="$(which $BIN) " + pinfo "BINLOC: $BIN_LOC" + [ $? -ne 0 ] && perror "Failed to find ${BIN} on this system." + done + pinfo "TARCOPY: $BIN_LOCS" + tarcopy "${BIN_LOCS}" "${MODULE_BUILD_DIR}" +} + +post_copy() { + : +} diff --git a/core/modules/zram-swap/module.conf b/core/modules/zram-swap/module.conf new file mode 100644 index 00000000..6c9a90e4 --- /dev/null +++ b/core/modules/zram-swap/module.conf @@ -0,0 +1,4 @@ +REQUIRED_BINARIES=" + mkswap + swapon +" diff --git a/core/modules/zram-swap/module.conf.ubuntu b/core/modules/zram-swap/module.conf.ubuntu new file mode 100644 index 00000000..b009a960 --- /dev/null +++ b/core/modules/zram-swap/module.conf.ubuntu @@ -0,0 +1,3 @@ +REQUIRED_INSTALLED_PACKAGES=" + util-linux +" |