You are not logged in.

#1 2022-12-14 17:01:50

seth
Member
Registered: 2012-09-03
Posts: 58,717

Helper to help others to help you

Hi-Diddly-Ho, new archlinux™ user.


Whether it's a common issue or something super-strange that you want to present, the more experienced users will typically ask you for some information, generic or specific to the topic.
And maybe you'd also like to take a look yourself.

But you where to look and how?
And how do you share such information?

Fear not, the abbs™* script abstracts some common inquiries into simpler commands, so instead of eg. knowing

sudo journalctl -b | curl -F 'file=@-' 0x0.st

you can just

abbs journal | abbs paste

or instead of transcribing

find /etc/systemd -type l -exec test -f {} \; -print | awk -F'/' '{ printf ("%-40s | %s\n", $(NF-0), $(NF-1)) }' | sort -f

you can just

abbs services # yes, "systemctl list-unit-files --state=enabled" should *reliably* do that…

·

How to get it

You can either copypaste if from the box below into a texteditor or:

Download

curl http://ix.io/4Lqz > abbs

Verify
Compare either checksum

md5sum abbs #  fb76fa9220dc4eef30e36f188e6f3595 abbs
sha256sum abbs #  54a37994e864034e84ca38c8eafa91ce0c00900a8f72378a2df173caf8566128 abbs

Look at it

less abbs # no, seriously. Don't just run random stuff from the internet without inspecting it

Make executable

chmod +x  abbs

Run

./abbs help # nb. the "./" - this is a relative path

·

abbs™ - Arch BBS Brightening Stuff
#!/bin/bash
abbs() {
    if ! grep -q "ID=arch" /etc/os-release; then
        grep -E 'NAME|ID' /etc/os-release
        echo 'https://bbs.archlinux.org/misc.php?action=rules'
        return 1
    fi
    case $1 in
    "journal")
        local ABBS_LEVER
        local ABBS_LEVER_TAIL
        (( $UID == 0 )) || groups | grep -E '\b(adm|wheel)\b' >/dev/null || ABBS_LEVER=1
        if [ -n "$ABBS_LEVER" ]; then
            echo "You're neither root nor in the 'adm' or 'wheel' group - authorization required"
            unset ABBS_LEVER
            sudo -l journalctl >/dev/null 2>&1 && ABBS_LEVER="sudo"
            [ -z "$ABBS_LEVER" ] && doas -C /etc/doas.conf journalctl 2>&1 | grep permit > /dev/null && ABBS_LEVER="doas"
            [ -z "$ABBS_LEVER" ] &&  type su >/dev/null && ABBS_LEVER="su -c '" && ABBS_LEVER_TAIL="'"
        fi
        shift
        eval "$ABBS_LEVER journalctl -b "$@" $ABBS_LEVER_TAIL"
        ;;
    "paste"|"pastebin"|"0x0.st")
        curl -F 'file=@-' 0x0.st
        ;;
    "ix.io")
        curl -F 'f:1=<-' ix.io
        ;;
    "cpubench")
        time echo "scale=5000; a(1)*4" | bc -l
        ;;
    "fonts")
        case $2 in
        "debug")
            FC_DEBUG=4 pango-view --font="$3" -t "$4" | grep family:
            ;;
        "with")
            fc-list :charset="$3"
            ;;
        "monospace")
            (fc-list :mono; fc-list :spacing=100) | sort -u
            printf ":mono : "; fc-list :mono | wc -l
            printf ":spacing=100 : "; fc-list :spacing=100 | wc -l
            ;;
        esac
        ;;
    "imgur"|"pasteimg")
        echo "Do NOT post images of text. Post the text!"
        echo "Do NOT embed huge images! Just link anything > 250x250 px"
        if type jq >/dev/null 2>&1; then
            curl -X POST "https://api.imgur.com/3/upload" -F "image=@\"$2\"" | jq ".data.link" -r
        elif type sed>/dev/null 2>&1; then
            curl -X POST "https://api.imgur.com/3/upload" -F "image=@\"$2\"" | sed 's%.*,"link":"https://i.imgur.com/\([^\"]*\)",.*%https://i.imgur.com/\1%'
        else
            curl -X POST "https://api.imgur.com/3/upload" -F "image=@\"$2\""
        fi
        ;;
    "integrity")
        printf "Ideally this won't print anything for quite a while.\nGet yourself a cup of coffee...\n"
        sudo LC_ALL=C pacman -Qkk | grep -v ', 0 altered files'
        ;;
    "locale")
        localectl; echo "   ---"
        locale; echo "   ---"
        locale -a
        ;;
    "services")
        find /etc/systemd -type l -exec test -f {} \; -print | awk -F'/' '{ printf ("%-40s | %s\n", $(NF-0), $(NF-1)) }' | sort -f
        ;;
    "session")
        echo $DBUS_SESSION_BUS_ADDRESS
        loginctl session-status | head -n16
        ;;
    "should"*)
        mpv --ytdl-raw-options='format="mp4,best[height<=480]"' 'https://www.youtube.com/watch?v=5RyYrs5tu60' || echo 'Watch https://www.youtube.com/watch?v=5RyYrs5tu60'
        ;;
    "utf8")
        if (( 0x${2} )) > /dev/null 2>&1; then
            printf "\U${2}\n"
        else
            printf "${2}" | iconv -futf8 -tutf16 | od -x | head -1 | cut -d" " -f3
        fi
        ;;
    "net")
        case $2 in
        "speed")
            servers=("newark" "singapore" "london" "frankfurt" "dallas" "toronto1" "syd1" "atlanta" "tokyo2" "mumbai1" "fremont")
            locations=( "Newark, USA" "Singapore" "London, UK" "Frankfurt, Deutschland" "Dallas, USA"
                        "Toronto, Canada" "Sidney, Australia" "Atlanta, USA" "東京都 (Tokyo), 日本国 (Japan)"
                        "मुंबई (Bombay), Bhārat (India)" "Fremont, USA")
            sizes=("100MB" "1GB")

            echo
            PS3=$'\n'"Enter location: "
            select t in "${locations[@]}"; do
                if [ "${SHELL##*/}" = "zsh" ]; then
                    server="${servers[$REPLY]}"
                else # ass_u_me bash logic
                    server="${servers[(($REPLY-1))]}"
                fi
                [[ $REPLY -ge 1 && $REPLY -le ${#servers[@]} ]] && break
            done
            unset REPLY

            echo
            PS3=$'\n'"Select size: "
            select size in "${sizes[@]}"; do
                [[ $REPLY -ge 1 && $REPLY -le ${#sizes[@]} ]] && break
            done

            echo
            [[ -n "${server}" && -n "${size}" ]] && wget -nv --show-progress -O /dev/null "http://speedtest.${server}.linode.com/${size}-${server}.bin"
            ;;
        "show")
            case $3 in
            "dhcp")
                type sudo; type nmap
                sudo nmap --script broadcast-dhcp-discover
                ;;
            "resolv"*)
                resolvectl status; echo "   ---"
                ls -l /etc/resolv.conf; echo "   ---"
                cat /etc/resolv.conf
                ;;
            *)
                ip a; echo "   ---"
                ip r; echo "   ---"
                getent ahostsv4 archlinux.org; echo "   ---"
                getent ahostsv6 archlinux.org; echo "   ---"
                nslookup archlinux.org; echo "   ---" # hopefully
            ;;
            esac
            ;;
        esac
        ;;
    "help")
        echo -e "minimalistic CPU bench by caclulating Pi with bc · cpubench\n"\
                "· locale\n"\
                "pango resolution of a glyph for a preferred font · fonts debug <font name> <glyph>\n"\
                "list all fonts that provide 'ü' · fonts with <00fc>\n"\
                "list all monospace fonts by different metrics · fonts monospace\n"\
                "you're looking at it · help\n"\
                "list all monospace fonts by different metrics · journal\n"\
                "scan for broken packages · integrity\n"\
                "network status · net show\n"\
                "DNS resovler config · net show resolv\n"\
                "scan for dhcp servers (requires nmap) · net show dhcp\n"\
                "run speedtest · net speed\n"\
                "feed into a pastebin service · pastebin|0x0.st|ix.io\n"\
                "upload an image · pasteimg|imgur <file.jpg>\n"\
                "list *all* enabled systemd services · services\n"\
                "show session status · session\n"\
                "yeah, \"should\" · should\n"\
                "convert between UTF8 codepoint and glyph · utf8 ü|00fc" | column -ts '·' -o'·' -R1
        ;;
    *)
        echo "Ummm... what??"
        ;;
    esac
}

[ "$0" = "${BASH_SOURCE[0]}" ] && abbs "$@"

Last edited by seth (2023-11-17 15:35:24)

Offline

#2 2022-12-14 17:07:24

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Helper to help others to help you

Brilliant.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2023-11-11 18:20:51

xerxes_
Member
Registered: 2018-04-29
Posts: 787

Re: Helper to help others to help you

Not working here - returns nothing.
I added #!/bin/sh at the beginning, but still nothing.

Offline

#4 2023-11-11 19:20:58

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Helper to help others to help you

It's a function  to be sourced into your interactive shell.
If you want it as script in /usr/local/bin/abbs or so, you'd remove the function deocoration ("abbs() {" and the closing "}")

Offline

#5 2023-11-12 00:22:32

icar
Member
From: Catalunya
Registered: 2020-07-31
Posts: 505

Re: Helper to help others to help you

Now include this with base and ask for any of the outputs when someone comes here asking for help.

Offline

#6 2023-11-12 08:37:11

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Helper to help others to help you

This has no business being in a base installation since it's really not relevant to archlinux but just this forum. And in particular beginners.
I was thinking about maybe a sticky, but nobody reads those anyway and for many cases (when no GUI is available) you'd have to suggest to download a file from the internet and source that into your shell, what teaches the wrong people a horrible lesson.

I put it here mostly to reference to it, but honestly could not come up with a way to distribute it that I'd not immediately object to. *shrug*

Offline

#7 2023-11-12 10:50:26

icar
Member
From: Catalunya
Registered: 2020-07-31
Posts: 505

Re: Helper to help others to help you

I was half joking, really.
This could potentially be something of interest as a broader troubleshooting helper project, that could be in the repository or in the AUR. Then you could suggest installing it.
I've seen many of you be against that, though.

Offline

#8 2023-11-12 14:31:14

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Helper to help others to help you

The AUR is harly more vetted than a github gist - but when users may need this, they might struggle to boot the installed system, with internet access or a broken pacman database.

I've seen many of you be against that, though.

I beg your pardon?
The above abstracts some commands to extract data from the system to be shared on liekly requirement.
I do not remember anyone objecting that, nor am I aware of stunted efforts of a "broader troubleshooting project", nor what that'd actually look like.
Mind to share a link?

Offline

#9 2023-11-12 21:37:32

icar
Member
From: Catalunya
Registered: 2020-07-31
Posts: 505

Re: Helper to help others to help you

I had https://bbs.archlinux.org/viewtopic.php … 3#p2117503 in mind. Maybe "I've seen many of you be against that, though" was a bit exaggerated.

Offline

#10 2023-11-12 22:38:10

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Helper to help others to help you

Ok, but even if "all data that would be useful to any type of help post" was a thing and not be a truckload of data and concerned to be exposing telemetry:
that entire subthread was in response to what's most likely been a shitpost (or an imbecile) and Awebb was pointing out that some cooperation (and effort) can (and should) be expected to demonstrate the readiness to at least learn how to maintain your system and not expect the forum to maintain it for you.
Also, in reality, the likely shitposter would not have provided that telemetry either.

Offline

#11 2023-11-13 08:00:15

icar
Member
From: Catalunya
Registered: 2020-07-31
Posts: 505

Re: Helper to help others to help you

Well then, would you consider creating a PKGBUILD for this?

Offline

#12 2023-11-13 10:05:43

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Helper to help others to help you

I don't mind but b/c of

The AUR is hardly more vetted than a github gist - but when users may need this, they might struggle to boot the installed system, with internet access or a broken pacman database.

that'd probably only be interesting if you're packaging it w/ some derivate.

A sticky explaining how to curl the file, a checksum and a big fat warning to otherwise not source random stuff from the internet might add some benefit.
I'll draft one and report it for sticky consideration.

Offline

Board footer

Powered by FluxBB