Skip to content

Instantly share code, notes, and snippets.

@mschmitt
Last active August 19, 2020 15:23
Show Gist options
  • Save mschmitt/809d3a307fa7b1f94f0b2bc1f724a187 to your computer and use it in GitHub Desktop.
Save mschmitt/809d3a307fa7b1f94f0b2bc1f724a187 to your computer and use it in GitHub Desktop.
#!/usr/bin/haserl --upload-limit=100000 --shell=/bin/bash
Content-Type: text/plain
<%
targetdir=/var/tmp
if [[ "$POST_upload_token" == "yolo" ]]
then
find "$targetdir" -name 'sosreport*tar.xz' -mtime +7 -print0 | xargs -0 rm
if [[ -s "$HASERL_file_path" ]]
then
cp -- "$HASERL_file_path" "$targetdir/$FORM_file_name"
chmod go+rw -- "$targetdir/$FORM_file_name"
ls -l -- "$targetdir/$FORM_file_name"
else
echo "Internal error: 01"
fi
else
echo "Internal error: 00"
fi
%>
Done.
#!/bin/bash
set -e
export DEBIAN_FRONTEND=noninteractive
apt-get install -y sosreport uuid curl
case_id="$(uuid)"
upload_url='https://1.2.3.4/cgi-bin/sosreport-receiver'
upload_token='yolo'
name="$(hostname --short)"
sosreport --batch --verify --name "${name}" --case-id "${case_id}"
reportfile="$(ls -tr /tmp/sosreport*${name}*${case_id}*z | tail -n 1)"
reportname="$(basename "${reportfile}")"
curl --insecure --silent --form "file=@\"${reportfile}\";filename=\"${reportname}\"" \
--form "upload_token=${upload_token}" "${upload_url}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment