summaryrefslogtreecommitdiffstats
path: root/remote
diff options
context:
space:
mode:
authorJonathan Bauer2013-11-27 14:14:40 +0100
committerJonathan Bauer2013-11-27 14:14:40 +0100
commit77f98843204cdb62ec29dee515b0865e9b1b5e61 (patch)
tree5f2f1e1dbf790898a816c7ef2d35415b3cd2ccb1 /remote
parent[export_target] more help messages if rsync fails (diff)
parent[cups] Missing printer UB1COLOR added. (diff)
downloadtm-scripts-77f98843204cdb62ec29dee515b0865e9b1b5e61.tar.gz
tm-scripts-77f98843204cdb62ec29dee515b0865e9b1b5e61.tar.xz
tm-scripts-77f98843204cdb62ec29dee515b0865e9b1b5e61.zip
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
Diffstat (limited to 'remote')
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog53
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export23
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions14
-rw-r--r--remote/rootfs/rootfs-stage32/rootfs-stage32.conf8
-rw-r--r--remote/rootfs/rootfs-stage32/rootfs-stage32.conf.opensuse1
-rw-r--r--remote/rootfs/rootfs-stage32/rootfs-stage32.conf.ubuntu1
6 files changed, 86 insertions, 14 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog
new file mode 100755
index 00000000..4df68cc0
--- /dev/null
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog
@@ -0,0 +1,53 @@
+#!/opt/openslx/bin/ash
+
+##################
+# Remote logging #
+##################
+
+. /opt/openslx/config
+[ -z "$SLX_REMOTE_LOG" ] && exit 3
+
+LOGCHECK="/tmp/remote_log_check"
+NOW=$(date +%s)
+
+[ $# -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 500 messages in total
+ LINES=$(cat "$LOGCHECK" | wc -l)
+ [ "$LINES" -gt 500 ] && exit 1
+ # Allow max 5 of same type messages in 30 seconds
+ 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
+echo "$NOW $TYPE" >> "$LOGCHECK"
+chmod 0666 "$LOGCHECK"
+
+if [ $# -lt 2 ]; then
+ MSG="Missing text for $@"
+else
+ MSG="$2"
+fi
+MSG="[$(whoami)] $MSG"
+
+if [ $# -gt 2 ]; then
+ EXTRA="$3"
+fi
+
+if [ -r "$EXTRA" ]; then
+ curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc@$EXTRA" "$SLX_REMOTE_LOG" > /dev/null 2>&1
+elif [ -n "$EXTRA" ]; then
+ curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Missing $EXTRA" "$SLX_REMOTE_LOG" > /dev/null 2>&1
+else
+ curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" "$SLX_REMOTE_LOG" > /dev/null 2>&1
+fi
+
+exit 0
+
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export
index c71dc9f6..c76634c7 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export
@@ -23,17 +23,32 @@ if [[ "$SLX_STAGE4" == dnbd3* ]]; then
echo "... didn't work ($RET)"
sleep 2
done
- [ "$RET" -ne "0" ] && exit $RET
+ if [ "$RET" -ne "0" ]; then
+ slxlog "mount-stage4" "Could not get stage4 via dnbd3 ($IMAGE) ($SLX_DNBD3_PRIO_SERVERS / $SERVERS)"
+ exit $RET
+ fi
echo "Mounting $dnbd3 to $MOUNTPOINT"
- mount -t squashfs -o ro "$dnbd3" "$MOUNTPOINT" || { echo "Fail."; exit 1; }
+ if ! mount -t squashfs -o ro "$dnbd3" "$MOUNTPOINT"; then
+ slxlog "mount-stage4" "Could not mount stage4 from '$dnbd3' to '$MOUNTPOINT' ($SRV, $IMAGE)"
+ echo "Fail."
+ exit 1
+ fi
else
# Try nfs
echo "Mounting ${SLX_STAGE4} to $MOUNTPOINT"
- mount -t nfs -o ro,async,nolock,vers=3 "$SLX_STAGE4" "$MOUNTPOINT" || { echo "Fail." && exit 1; }
+ if ! mount -t nfs -o ro,async,nolock,vers=3 "$SLX_STAGE4" "$MOUNTPOINT"; then
+ slxlog "mount-stage4" "Could not mount stage4 from '$SLX_STAGE4' to '$MOUNTPOINT'"
+ echo "Fail."
+ exit 1
+ fi
fi
echo "Appending $MOUNTPOINT to /"
-mount -o "remount,add:1:$MOUNTPOINT=ro" / || { echo "Fail." && exit 1; }
+if ! mount -o "remount,add:1:$MOUNTPOINT=ro" /; then
+ slxlog "mount-stage4" "Could not append mounted stage4 at '$MOUNTPOINT to aufs at /"
+ echo "Fail."
+ exit 1
+fi
# dbus reload needed eg. for gnome etc. and perhaps other service files which stage4 needs:
systemctl reload dbus.service
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 0f419366..07bd628e 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
@@ -14,6 +14,7 @@
#############################################################################
+# Mount point for persistent scratch partition (type 45)
PERSISTENT="/opt/openslx/persistent"
# General formatter for the /tmp partition on a local harddisk
@@ -105,20 +106,23 @@ echo "Partitions:"
cat "/etc/disk.partition"
# 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
+ swapon "$hdpartnr" -p 10 && HAVE_SWAP=yes
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
# 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"
+ HAVE_TEMP=yes
break
else
echo "formatting failed for some reason"
@@ -155,8 +159,12 @@ done
mount -a
# Make huge tmpfs if nothing could be mounted for /tmp
-if [ "$(mount | grep -c "on /tmp ")" = "0" ]; then
- mount_temp -t tmpfs -o size=10G none
+if [ "$HAVE_TEMP" = "no" ]; then
+ mount_temp -t tmpfs -o size=20G none
+ slxlog "partition-temp" "Running /tmp on tmpfs only!" "/etc/disk.partition"
+fi
+if [ "$HAVE_SWAP" = "no" ]; then
+ slxlog "partition-swap" "Have no (formatted) swap partition, using zram swap only!" "/etc/disk.partition"
fi
# Add zram swap
diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf
index 5d8966f1..085b6ecc 100644
--- a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf
+++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf
@@ -3,25 +3,19 @@ REQUIRED_MODULES="
"
REQUIRED_BINARIES="
bash
- more
+ curl
less
agetty
- cat
- false
loadkeys
setfont
login
sulogin
- mount
- umount
mount.nfs4
umount.nfs4
- fdisk
mkfs.xfs
mkfs.ext3
mkfs.ext4
mkfs.jfs
- rm
blkid
modprobe
ps
diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.opensuse b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.opensuse
index 91e28a7b..b5630284 100644
--- a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.opensuse
+++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.opensuse
@@ -5,6 +5,7 @@ REQUIRED_INSTALLED_PACKAGES="
timezone
libcap2
jfsutils
+ curl
"
REQUIRED_CONTENT_PACKAGES="
timezone
diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.ubuntu b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.ubuntu
index 2df7df77..646c39a0 100644
--- a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.ubuntu
+++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.ubuntu
@@ -5,6 +5,7 @@ REQUIRED_INSTALLED_PACKAGES="
xfsprogs
ntpdate
jfsutils
+ curl
"
REQUIRED_DIRECTORIES="
/lib/xtables