summaryrefslogtreecommitdiffstats
path: root/core/rootfs
diff options
context:
space:
mode:
authorJonathan Bauer2017-10-09 18:31:58 +0200
committerJonathan Bauer2017-10-09 18:31:58 +0200
commitef7279aaa989c1e020bc4c66eb93406bdd9c55a5 (patch)
tree403993798c28f3e92037e1dfa6fdee5c6dcf1a07 /core/rootfs
parent[bwlp] add "raw" bwlp target (diff)
downloadmltk-ef7279aaa989c1e020bc4c66eb93406bdd9c55a5.tar.gz
mltk-ef7279aaa989c1e020bc4c66eb93406bdd9c55a5.tar.xz
mltk-ef7279aaa989c1e020bc4c66eb93406bdd9c55a5.zip
externalize slxlog to its own module
Diffstat (limited to 'core/rootfs')
-rw-r--r--core/rootfs/rootfs-stage31/data/inc/activate_sysconfig2
-rw-r--r--core/rootfs/rootfs-stage31/module.conf1
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog104
-rw-r--r--core/rootfs/rootfs-stage32/module.conf1
4 files changed, 3 insertions, 105 deletions
diff --git a/core/rootfs/rootfs-stage31/data/inc/activate_sysconfig b/core/rootfs/rootfs-stage31/data/inc/activate_sysconfig
index 0ce6bfae..eafff082 100644
--- a/core/rootfs/rootfs-stage31/data/inc/activate_sysconfig
+++ b/core/rootfs/rootfs-stage31/data/inc/activate_sysconfig
@@ -21,7 +21,7 @@ fetch_text_config() {
}
#########################################################################
#
-# This function downloads the config.tgz and unpacks it to $TARGET_PATH <-- no it doesn't!
+# This function downloads the config.tgz (but does not unpack it)
#
fetch_config_tgz() {
[ -e "${CONFIG}.tgz" ] && echo "config.tgz already downloaded." && return 0
diff --git a/core/rootfs/rootfs-stage31/module.conf b/core/rootfs/rootfs-stage31/module.conf
index 49d49a56..d3865d09 100644
--- a/core/rootfs/rootfs-stage31/module.conf
+++ b/core/rootfs/rootfs-stage31/module.conf
@@ -5,6 +5,7 @@ REQUIRED_BINARIES="
REQUIRED_MODULES="
busybox
kernel
+ slxlog
system-uuid
"
REQUIRED_KERNEL_MODULES="
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog b/core/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog
deleted file mode 100755
index f1ee4816..00000000
--- a/core/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/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 /etc/system-uuid ]; then
- UUID=$(cat /etc/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/rootfs/rootfs-stage32/module.conf b/core/rootfs/rootfs-stage32/module.conf
index 84b98d1f..20baddbd 100644
--- a/core/rootfs/rootfs-stage32/module.conf
+++ b/core/rootfs/rootfs-stage32/module.conf
@@ -1,6 +1,7 @@
#!/bin/bash
REQUIRED_MODULES="
kernel
+ slxlog
"
REQUIRED_BINARIES="
bash