summaryrefslogtreecommitdiffstats
path: root/remote/rootfs/rootfs-stage32/data/opt
diff options
context:
space:
mode:
Diffstat (limited to 'remote/rootfs/rootfs-stage32/data/opt')
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog58
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue77
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver9
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions181
4 files changed, 221 insertions, 104 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog
index 52320c1a..09cb9b79 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog
@@ -13,13 +13,29 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/o
. /opt/openslx/config
[ -z "$SLX_REMOTE_LOG" ] && exit 3
-LOGCHECK="/tmp/remote_log_check"
+USER=$(whoami)
+LOGCHECK="/tmp/remote_log_check-$USER"
NOW=$(date +%s)
+DELFILE=
+SYNC=
-if [ "x$1" = "x-e" -o "x$1" = "x--echo" ]; then
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -e|--echo)
+ echo "$@"
+ ;;
+ -d|--delete)
+ DELFILE=yes
+ ;;
+ -s|--sync)
+ SYNC=yes
+ ;;
+ *)
+ break
+ ;;
+ esac
shift
- echo "$@"
-fi
+done
[ $# -eq 0 ] && exit 0
@@ -42,14 +58,13 @@ if [ -r "$LOGCHECK" ]; then
fi
fi
echo "$NOW $TYPE" >> "$LOGCHECK"
-chmod 0666 "$LOGCHECK" 2>/dev/null
+chmod 0600 "$LOGCHECK" 2>/dev/null
if [ $# -lt 2 ]; then
MSG="Missing text for $@"
else
MSG="$2"
fi
-USER=$(whoami)
MSG="[$USER] $MSG"
if [ $# -gt 2 ]; then
@@ -62,15 +77,28 @@ else
CURLLOG="/dev/null"
fi
-if [ -n "$EXTRA" ] && [ -r "$EXTRA" -a -s "$EXTRA" ] && [ "$(stat -c %s "$EXTRA")" -lt "10000" ]; then # valid file attachment
- curl --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 "type=$TYPE" --data-urlencode "description=$MSG" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 &
-elif [ -s "$EXTRA" ]; then # empty attachment file (or missing)
- curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Attachment too large: $EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 &
-else # attachment file to big (more than 10k)
- curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Attachment missing/empty: $EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 &
+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
-exit 0
+submitlog
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
index 4d2de8b7..c70e0356 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
@@ -1,4 +1,5 @@
-#!/bin/ash
+#!/bin/bash
+# Needs bash for string manipulation
# Copyright (c) 2013, 2014 - bwLehrpool Projekt
# Copyright (c) 2012 - OpenSLX GmbH
#
@@ -14,11 +15,73 @@
#############################################################################
# Set greeting and add information about the booted system
-len=$(expr length "$(cat /etc/hostname)")
-while [ $len -le 56 ] ; do
- space="$space "
- len=$(($len + 1))
-done
-sed "s/%space%/$space/g" /opt/openslx/etc/issue.template > /etc/issue
+declare -rg INFILE=/opt/openslx/etc/issue.template
+declare -rg TMPFILE=$(mktemp)
+declare -rg OUTFILE=/etc/issue
+
+. /opt/openslx/config
+
+# Replace known variables and determine maximum line length
+MAX=0
+while IFS='' read -r line || [ -n "$line" ]; do
+ line="${line//"%ip%"/"$SLX_PXE_CLIENT_IP"}"
+ line="${line//"%hostname%"/"$SLX_HOSTNAME"}"
+ tst="${line//"%space%"/}"
+ len=${#tst}
+ [ "$len" -gt "$MAX" ] && MAX=$len
+ echo "$line"
+done < "$INFILE" > "$TMPFILE"
+player=$(< /etc/vmware/config grep -m1 '^product.version' | awk -F= '{print $2}')
+kernel=$(uname -r)
+system="$(dmidecode -s system-manufacturer | grep -vP "unknown|filled|^#") $(dmidecode -s system-product-name | grep -vP "unknown|filled|^#")"
+linkspeed=$(cat /sys/class/net/eth0/speed)
+tmpstatus=$(grep -m1 ' /tmp ' /proc/mounts | awk '{print $3}')
+if [ -z "$tmpstatus" ] || [ "$tmpstatus" = "tmpfs" ]; then
+ tmpstatus="RAMDISK"
+else
+ tmpstatus="HDD"
+fi
+tmpstatus="$(df -P | grep -m1 ' /tmp$' | awk '{printf "%.1f", $2 / 1024 / 1024}')GiB ($tmpstatus)"
+
+cat >> "$TMPFILE" <<EOF
+System model: %space% $system
+Kernel version: %space% $kernel
+Temporary directory: %space% $tmpstatus
+Boot server: %space% $SLX_PXE_SERVER_IP
+EOF
+if [ -n "$linkspeed" ]; then
+ echo "Link speed: %space% ${linkspeed}MBit" >> "$TMPFILE"
+fi
+if [ -n "$SLX_SHUTDOWN_SCHEDULE" ]; then
+ echo "Scheduled shutdown: %space% $SLX_SHUTDOWN_SCHEDULE" >> "$TMPFILE"
+fi
+if [ -n "$SLX_REBOOT_SCHEDULE" ]; then
+ echo "Scheduled reboot: %space% $SLX_REBOOT_SCHEDULE" >> "$TMPFILE"
+fi
+if [ -n "$player" ]; then
+ echo "VMware version: %space% ${player//'"'/}" >> "$TMPFILE"
+fi
+
+echo "" >> "$TMPFILE"
+
+# Fix up spacing for right-aligned text
+while IFS='' read -r line || [ -n "$line" ]; do
+ tst=${line/"%space%"/}
+ if [ "$(( ${#line} - ${#tst} ))" -eq 7 ]; then
+ space=
+ while true; do
+ tst=${line/"%space%"/"$space"}
+ if [ "${#tst}" -ge "$MAX" ]; then
+ line="$tst"
+ break
+ fi
+ space=" $space"
+ done
+ fi
+ echo "$line"
+done < "$TMPFILE" > "$OUTFILE"
+
+rm -f -- "$TMPFILE"
+
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver
index 3ca2f334..e6fd32cf 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver
@@ -7,13 +7,14 @@ if ! lspci -n > "$PCIFILE"; then
exit 1
fi
-if grep -q -E ' (8086:0102|8086:0152|8086:0162|8086:0412|8086:0416|1002:6779)( |$)' "$PCIFILE"; then
- echo "i915 - enable 3D"
- echo -e "# Written by load-gfx-driver\nSLX_VMWARE_3D=yes" >> "/opt/openslx/config"
-elif lsmod | grep -q '^nvidia\s'; then
+if lsmod | grep -q '^nvidia\s'; then
# nvidia kernel module was loaded in stage31 - download libs
+ echo "Proprietary nvidia kernel drivers loaded - fetch user space libs"
systemctl start setup-slx-addon@nvidia_libs &
echo -e "# Written by load-gfx-driver\nSLX_VMWARE_3D=yes" >> "/opt/openslx/config"
+elif grep -q -E ' (8086:0102|8086:0152|8086:0162|8086:0412|8086:0416|1002:6779)( |$)' "$PCIFILE"; then
+ echo "i915 - enable 3D"
+ echo -e "# Written by load-gfx-driver\nSLX_VMWARE_3D=yes" >> "/opt/openslx/config"
fi
exit 0
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
index 0c352241..4dc84828 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
@@ -15,53 +15,61 @@
#############################################################################
# Mount point for persistent scratch partition (type 45)
-PERSISTENT="/opt/openslx/persistent"
+MOUNT_POINT_45="/opt/openslx/persistent"
+PARTITION_FILE="/run/openslx/partitions"
+readonly MOUNT_POINT_45 PARTITION_FILE
+mkdir -p "/run/openslx"
# General formatter for the /tmp partition on a local harddisk
-diskfm () {
- mopt="" # Global var!
+format_disk () {
+ MOUNT_OPTIONS_SET_BY_FORMAT_DISK="" # Global var!
local target="$1"
local fslist="xfs jfs ext3 ext2 ext4"
local fs
local path
[ $# -ge 2 ] && fslist="$2"
for fs in $fslist ; do
- unset available
- case $(cat /proc/filesystems) in
- *${fs}*) available=yes;;
- *) modprobe "${fs}" && available=yes;;
- esac
- if [ -n "${available}" ]; then
- unset found
- if which "mkfs.$fs" ; then
- found=yes
- case "mkfs.$fs" in
- mkfs.xfs)
- fopt="-f -b size=4k -s size=4k -l size=512b" # fastest formatting possible :)
- mopt="-o noexec"
- ;;
- mkfs.ext2)
- fopt="-Fq"
- mopt="-o nocheck,noexec"
- ;;
- mkfs.ext3|mkfs.ext4)
- fopt="-Fq"
- mopt="-o noexec"
- ;;
- mkfs.reiserfs)
- fopt="-f"
- mopt="-o noexec"
- ;;
- mkfs.jfs)
- fopt="-q"
- mopt="-o noexec"
- ;;
- esac
- mkfs.$fs ${fopt} "${target}"
- fi
- [ -n "$found" ] && break
+ 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
+ xfs)
+ fopt="-f -b size=4k -s size=4k -l size=512b" # fastest formatting possible :)
+ MOUNT_OPTIONS_SET_BY_FORMAT_DISK="-o noexec"
+ ;;
+ ext2)
+ fopt="-Fq"
+ MOUNT_OPTIONS_SET_BY_FORMAT_DISK="-o nocheck,noexec"
+ ;;
+ ext3|ext4)
+ fopt="-Fq"
+ MOUNT_OPTIONS_SET_BY_FORMAT_DISK="-o noexec"
+ ;;
+ reiserfs)
+ fopt="-f"
+ MOUNT_OPTIONS_SET_BY_FORMAT_DISK="-o noexec"
+ ;;
+ jfs)
+ fopt="-q"
+ MOUNT_OPTIONS_SET_BY_FORMAT_DISK="-o noexec"
+ ;;
+ *)
+ fopt=
+ MOUNT_OPTIONS_SET_BY_FORMAT_DISK=
+ ;;
+ esac
+ mkfs.$fs ${fopt} "${target}" && return 0 # Success!
fi
done
+ return 1
}
mount_temp () {
@@ -89,33 +97,42 @@ mount_temp_fallback () {
return 0
}
-fdisk -l | sed -n "/^\/dev\//p" > "/etc/disk.partition"
+fdisk -l | grep '^/dev/' > "$PARTITION_FILE"
-if [ ! -s "/etc/disk.partition" ]; then
+if [ ! -s "$PARTITION_FILE" ]; then
+ udevadm trigger
sleep 3
- fdisk -l | sed -n "/^\/dev\//p" > "/etc/disk.partition"
+ udevadm settle
+ fdisk -l | grep '^/dev/' > "$PARTITION_FILE"
fi
echo "Partitions:"
-cat "/etc/disk.partition"
+cat "$PARTITION_FILE"
+
+# Get all partitions with given id (list of /dev/sdXX)
+get_all_with_id () {
+ [ -z "$1" ] && return
+ local ID=$1
+ awk '{if (($2 == "*" && $6 == "'$ID'") || ($2 != "*" && $5 == "'$ID'")) print $1}' "$PARTITION_FILE" # watch out for non-spaced '$ID'
+}
# Check for standard swap partitions and make them available to the system
HAVE_SWAP=no
-for hdpartnr in $(sed -n -e "/ 82 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do
- echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab"
- swapon "$hdpartnr" -p 10 && HAVE_SWAP=yes # low priority, in case we have zram swap, prefer that)
+for PART_DEV in $(get_all_with_id 82); do
+ echo -e "$PART_DEV\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab"
+ swapon "$PART_DEV" -p 10 && HAVE_SWAP=yes # low priority, in case we have zram swap, prefer that)
done
# We use special non assigned partition type (id44) for harddisk scratch
# space, thus no normal filesystem will be incidentally deleted or
# corrupted
HAVE_TEMP=no
-for hdpartnr in $(sed -n -e "/ 44 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do
+for PART_DEV in $(get_all_with_id 44); do
# check for supported filesystem and formatter
- if diskfm "$hdpartnr"; then
- # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready
- mount_temp "$mopt" "$hdpartnr" || continue
- echo -e "${hdpartnr}\t/tmp\t\tauto\t\tnoexec\t 0 0" >> "/etc/fstab"
+ if format_disk "$PART_DEV"; then
+ # echo "$PART_DEV is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready
+ mount_temp "$MOUNT_OPTIONS_SET_BY_FORMAT_DISK" "$PART_DEV" || continue
+ echo -e "${PART_DEV}\t/tmp\t\tauto\t\tnoexec\t 0 0" >> "/etc/fstab"
HAVE_TEMP=yes
break
else
@@ -123,44 +140,52 @@ for hdpartnr in $(sed -n -e "/ 44 /p" "/etc/disk.partition" | sed -e "s/[[:space
fi # Made this non-forking, systemd should handle it - 2013-05-28
done
-# Put detected linux partitions (83) into /etc/fstab with "noauto", special
-# partition 45 (persistent scratch) to /var/scratch and 46 to /var/openslx
-HAVE_PERSISTENT=no
-for partid in 83 45 46 ; do
- for hdpartnr in $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do
- if [ "${partid}" -eq 83 ]; then
- mkdir -p "/media/${hdpartnr#/dev/*}"
- echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab"
- elif [ "${partid}" -eq 45 -a "$HAVE_PERSISTENT" = "no" ]; then
- mkdir -p "$PERSISTENT"
- if ! mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT"; then
- diskfm "$hdpartnr" "jfs xfs ext3" || continue
- mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT" || continue
- fi
- HAVE_PERSISTENT=yes
- echo -e "${hdpartnr}\t${PERSISTENT}\tauto\t\tnoauto,noexec\t\t 0 0" >> "/etc/fstab"
- elif [ "${partid}" -eq 46 ]; then
- mkdir -p "/media/${hdpartnr#/dev/*}"
- #mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\
- #test -d /mnt/media/${hdpartnr#/dev/*}/home && \
- # ln -sf /media/${hdpartnr#/dev/*} /var/home
- echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab"
- fi
- done
+# Put detected linux partitions (83) into /etc/fstab with "noauto"
+HAVE_PARTITION_45=no
+for PART_DEV in $(get_all_with_id 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
-[ "$HAVE_PERSISTENT" = "no" -a -d "$PERSISTENT" ] && rm -f "$PERSISTENT"
+
+# special partition 45 (persistent scratch) to $MOUNT_POINT_45
+for PART_DEV in $(get_all_with_id 45); do
+ mkdir -p "$MOUNT_POINT_45"
+ if ! mount -t auto -o noexec "${PART_DEV}" "$MOUNT_POINT_45"; then
+ format_disk "$PART_DEV" "ext4 xfs jfs ext3" || continue
+ mount -t auto -o noexec "${PART_DEV}" "$MOUNT_POINT_45" || continue
+ fi
+ echo -e "${PART_DEV}\t${MOUNT_POINT_45}\tauto\t\tnoauto,noexec\t\t 0 0" >> "/etc/fstab"
+ HAVE_PARTITION_45=yes
+ break
+done
+
+# and 46 to /media/devXX
+for PART_DEV in $(get_all_with_id 46); do
+ mkdir -p "/media/${PART_DEV#/dev/*}"
+ #mount -t auto ${PART_DEV} /mnt/media/${PART_DEV#/dev/*} \n\
+ #test -d /mnt/media/${PART_DEV#/dev/*}/home && \
+ # ln -sf /media/${PART_DEV#/dev/*} /var/home
+ echo -e "${PART_DEV}\t/media/${PART_DEV#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab"
+done
+if [ "$HAVE_PARTITION_45" = "no" ] && [ -d "$MOUNT_POINT_45" ]; then
+ rm -f -- "$MOUNT_POINT_45"
+fi
mount -a
-# Make huge tmpfs if nothing could be mounted for /tmp
+# Make tmpfs if nothing could be mounted for /tmp
+# 2016-10-12: Use a sane size of 66% which should be generous enough and prevent the machine from
+# just crashing if RAM is too full. We previously hugely oversized since vmware wants at least as
+# much free space as the VMs RAM; however, this requirement can be disabled with a vmx setting,
+# which we're now doing.
if [ "$HAVE_TEMP" = "no" ]; then
- mount_temp -t tmpfs -o size=60G none
- slxlog "partition-temp" "Running /tmp on tmpfs only!" "/etc/disk.partition"
+ mount_temp -t tmpfs -o size=66% none
+ slxlog "partition-temp" "Running /tmp on tmpfs only!" "$PARTITION_FILE"
fi
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!" "/etc/disk.partition"
+ slxlog "partition-swap" "Have no (formatted) swap partition, using zram swap only!" "$PARTITION_FILE"
fi
fi