Commit 22a1656e authored by Stefano Capitani's avatar Stefano Capitani
Browse files

Add the ability to use in live mode to inspect a failed manjaro installation....

Add the ability to use in live mode to inspect a failed manjaro installation. Thank you @papajoke

 for the great addition
Signed-off-by: Stefano Capitani's avatarStefano Capitani <stefano@manjaro.org>
parent 594848ba
......@@ -20,14 +20,16 @@
#
# Forked from EndeavourOS: Author: manuel-192
PARTITION=""
mlh_yad() {
local icon=/usr/share/icons/manjaro/maia/maia.svg
local window_icon=/usr/share/icons/manjaro/maia/32x32.png
if [ -r "$icon" ] ; then
GDK_BACKEND=x11 /usr/bin/yad --center --window-icon="$icon" --image="$window_icon" --title="Manjaro Log Helper" "$@"
GDK_BACKEND=x11 /usr/bin/yad --center --window-icon="$icon" --image="$window_icon" --title="Manjaro Log Helper ${PARTITION}" "$@"
else
GDK_BACKEND=x11 /usr/bin/yad --center --title="Manjaro log tools" "$@"
GDK_BACKEND=x11 /usr/bin/yad --center --title="Manjaro log tools ${PARTITION}" "$@"
fi
}
......@@ -70,7 +72,11 @@ Cmd() {
pkexec)
shift
SUDO_CMDS+=" ; echo '$(Header "$@")' >> $FILE_OF_LOGS"
SUDO_CMDS+=" ; $* >> $FILE_OF_LOGS"
if [[ "$1" == "journalctl" && -n "$PARTITION" ]]; then
SUDO_CMDS="mount ${PARTITION} /mnt/ --read-only; ${SUDO_CMDS}; $* --no-pager -D /mnt/var/log/journal >> $FILE_OF_LOGS; umount /mnt"
else
SUDO_CMDS+=" ; $* >> $FILE_OF_LOGS"
fi
SUDO_CMDS+=" ; echo '$(Footer)' >> $FILE_OF_LOGS"
return
;;
......@@ -90,20 +96,26 @@ SendToInternet() {
RemovePersonalData # always before sending logs to the internet
url=$(pastebinit -b paste.ubuntu.com $FILE_OF_LOGS)
local url=$(pastebinit -b paste.ubuntu.com $FILE_OF_LOGS)
echo -e "\n\n-------------------------\npaste.ubuntu.com:\t ${url}"
echo "$(date '+%Y-%m-%d %H:%M:%s'): $url" >> "$DIR_OF_CONFIG"/url-list.txt
if [[ -x /usr/bin/xclip ]]; then
mlh_yad --text="$url" --button="Cancel":1 --button="Copy":0 --button="Open":2 --button="Open in a text editor":3 --title="Result URL" --width=300
opt=$?
case $opt in
0) echo "$url" | xclip -i -selection clipboard ;;
1) mlh_yad --text-info --width=300 --title="Result URL" --text="$url";;
2) xdg-open $url ;;
3) xdg-open $FILE_OF_LOGS
esac
fi
sendToInternet=yes
mlh_yad --text="$url" --button="Cancel":1 --button="Copy":0 --button="Open":2 --button="Open in a text editor":3 --title="Result URL" --width=300
local opt=$?
case $opt in
0) if [[ "DESKTOP_SESSION" =~ "plasma" ]]; then
qdbus org.kde.klipper /klipper setClipboardContents "$url"
elif [[ -x /usr/bin/xclip ]]; then
echo "$url" | xclip -i -selection clipboard
#TODO
#if wayland ???
fi ;;
1) mlh_yad --text-info --width=300 --title="Result URL" --text="$url";;
2) xdg-open $url ;;
3) xdg-open $FILE_OF_LOGS
esac
isSendToInternet=${#url}
}
UserNames() {
......@@ -175,6 +187,25 @@ RemovePersonalData() {
removePersonalInfo=yes
}
get_Manjaro_Partitions(){
#test by sudo ./mlh -getparts
mountdir="/tmp/mnt-"
mkdir "${mountdir}"
declare -a manjaros=()
while read -r partition label; do
#echo -e "\n:: ${partition} (${label})??"
if mount "${partition}" "${mountdir}" --read-only >/dev/null; then # -o sync
if [[ -d "${mountdir}/etc" && -f "${mountdir}/etc/lsb-release" ]]; then
if [[ $(grep -c -i 'Manjaro' ${mountdir}/etc/lsb-release) > 0 ]]; then
echo -e "false ${partition}\t${label}"
fi
fi
umount "${mountdir}" >/dev/null
fi
done < <(lsblk -lfn -o "FSTYPE,PATH,TYPE,PTTYPE,PARTTYPE,LABEL" | awk '/ 0x83 / {print $2" "$6}')
rmdir "${mountdir}"
}
Welcome()
{ mlh_yad --text-align=center --text="\n\n<b>Welcome to Manjaro Log Helper</b>\nA simple <b>GUI</b> for obtain usefull informations of your system and usefull logs errors.\n\nPress <b>OK</b> to continue or <b>Cancel</b> for exit."
......@@ -186,6 +217,20 @@ Main()
local FILE_OF_LOGS=$HOME/manjaro-log-helper.logs
local DIR_OF_CONFIG="$HOME/.config/manjaro-log-helper.conf"
local SUDO_CMDS=":"
EXPORT SYSTEMD_COLOR=false # no color codes in logs
#TODO id user == manjaro or if is in iso ?
if [[ "$USER" == "manjaro" ]]; then
#TODO change path /usr/bin for run after install
local partitions=$(pkexec "${PWD}/mlh" -getparts)
local result=$(
mlh_yad --list --radiolist --width=750 --height=655 --text="Select partition where is Manjaro" \
--no-click \
--column="Select" --column="Partition" --column="Label" \
$partitions
)
PARTITION=$(echo "$result" | awk -F'|' '{print $2}')
fi
mkdir -p "$DIR_OF_CONFIG"
......@@ -197,7 +242,7 @@ Main()
local rdtip="Rename personal names to generic names"
local sltip="Send gathered logs to the internet (personal info always removed)"
local journal0="journalctl -b -0"
local journal0="journalctl -b 0"
local journal1="journalctl -b -1"
local journal2="journalctl -b -2"
local install="Manjaro install log"
......@@ -211,8 +256,8 @@ Main()
local save="Save this log"
local cmds
local sendToInternet=no
local removePersonalInfo=no
local isSendToInternet=0
local removePersonalInfo="no"
local xx
local helptext=""
......@@ -272,7 +317,7 @@ Main()
esac
done
if [ "$sendToInternet" = "no" ] ; then
if [ "$isSendToInternet" > 0 ] ; then
if [ "$removePersonalInfo" = "yes" ] ; then
Msg "Log file <b>$FILE_OF_LOGS</b> created. Personal data was removed." "Info"
[[ $? -eq 1 ]] && xdg-open $FILE_OF_LOGS
......@@ -280,8 +325,14 @@ Main()
Msg "Log file <b>$FILE_OF_LOGS</b> created. Personal data was <b>not</b> removed." "Info"
[[ $? -eq 1 ]] && xdg-open $FILE_OF_LOGS
fi
else
echo "${FILE_OF_LOGS} Not send to internet"
fi
}
if [[ "$1" == "-getparts" ]]; then
get_Manjaro_Partitions
fi
Welcome
Main $@
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment