Update with check if root

This commit is contained in:
Ulf 2021-11-25 19:50:35 +01:00
parent b9db7d80ec
commit 9816cd0d8d
2 changed files with 18 additions and 2 deletions

View file

@ -15,7 +15,7 @@ See also at [LUG-VS-Wiki Nützliche Scripte](https://lug-vs.org//lugvswiki/index
|[duc-index.sh](duc-index.sh)|Script to be added e.g. as cronjob, which generate an index w/o NFS and DavFS file system mounted files| |[duc-index.sh](duc-index.sh)|Script to be added e.g. as cronjob, which generate an index w/o NFS and DavFS file system mounted files|
|[make_exif-name.sh](make_exif-name.sh)|Add a comment in all *.jpg files in the actual and all subfolders| |[make_exif-name.sh](make_exif-name.sh)|Add a comment in all *.jpg files in the actual and all subfolders|
|[SavePC.sh](SavePC.sh)|Save some helpfull settings (not /home) and some general informatin| |[SavePC.sh](SavePC.sh)|Save some helpfull settings (not /home) and some general informatin|
|[SaveX11crash.sh](SaveX11crash.sh)|Save the X11 logs and the journalctl of the last 10 minutes| |[SaveX11crash.sh](SaveX11crash.sh)|Save the X11 logs and the journalctl of the last 10 minutes (requires root)|
|[SchredderHDD.sh](SchredderHDD.sh)|Delete a mechanical Hard Disk (HDD) reliably to ensure before forward it to the recycling, that no old data are there| |[SchredderHDD.sh](SchredderHDD.sh)|Delete a mechanical Hard Disk (HDD) reliably to ensure before forward it to the recycling, that no old data are there|
|[utf8.sh](utf8.sh)|Convert text from e.g. Windows latin1 to utf8 text (e.g. in READMEs or other text (not for office documents))| |[utf8.sh](utf8.sh)|Convert text from e.g. Windows latin1 to utf8 text (e.g. in READMEs or other text (not for office documents))|
|[wmf2svg.sh](wmf2svg.sh)|Example script converts WMF files in SVG to share it easily on the internet| |[wmf2svg.sh](wmf2svg.sh)|Example script converts WMF files in SVG to share it easily on the internet|

View file

@ -2,16 +2,32 @@
# SaveX11crash.sh save the X11 logs and the journalctl of the last 10 minutes # SaveX11crash.sh save the X11 logs and the journalctl of the last 10 minutes
# #
# (c) GPL by Ulf Bartholomäus ub1x@gmx.net # (c) GPL by Ulf Bartholomäus ub1x@gmx.net
VERSION="$( basename $0 ) Version 0.1.0 from 22.11.2021" VERSION="$( basename $0 ) Version 0.1.1 from 25.11.2021"
# #
# Input: n/a # Input: n/a
# Output: progress and 7z compressed logs # Output: progress and 7z compressed logs
# Returnvalue: 0 if finished OK and 10 if there was an issue at 7z # Returnvalue: 0 if finished OK and 10 if there was an issue at 7z
# #
# Changes:
# 0.1.1
# Detect if not root
# 0.1.0
# Initial version
## Verwendeten Pfad mit Datum und Uhrzeit definieren - da sich die Sekunden ändern könnten ## Verwendeten Pfad mit Datum und Uhrzeit definieren - da sich die Sekunden ändern könnten
MyPath="${HOME}/X11-Crash_$(date +%F_%H-%M-%S)" MyPath="${HOME}/X11-Crash_$(date +%F_%H-%M-%S)"
MyTime="-10m" # -10m = die letzten 10 minuten MyTime="-10m" # -10m = die letzten 10 minuten
## teste ob root rechte vorhanden
if [ "`whoami`" != "root" ] ; then
echo -e "Nicht ausreichend Rechte - bitte als "root" anmelden!\nsu -c '$0'"
exit 20
else
echo -e "MyPath=${MyPath}"
fi
## Pfad anlegen ## Pfad anlegen
mkdir -p ${MyPath} mkdir -p ${MyPath}