1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-12 11:12:06 +00:00

Toughen up iiab-apps-to-be-installed, iiab-summary, iiab-diagnostics

This commit is contained in:
root 2022-07-06 05:53:19 -04:00
parent 8f0bb17990
commit faa73a3088
4 changed files with 27 additions and 35 deletions

View file

@ -8,6 +8,11 @@ iiab_var_value() {
[[ $v2 != "" ]] && echo $v2 || echo $v1 # [ "$v2" ] ALSO WORKS
}
# https://askubuntu.com/questions/1250974/user-root-cant-write-to-file-in-tmp-owned-by-someone-else-in-20-04-but-can-in
# https://unix.stackexchange.com/questions/503111/group-permissions-for-root-not-working-in-tmp
[[ $(id -un) == "root" ]] &&
rm -f /tmp/iiab-apps-list /tmp/iiab-apps-to-be-installed
# 2022-06-18: 40 apps (list not quite complete)
#grep -l _installed: /opt/iiab/iiab/roles/*/tasks/install.yml | cut -d/ -f6 > /tmp/iiab-apps-list
@ -17,6 +22,13 @@ iiab_var_value() {
# 2022-06-18: 50 apps (list long but ok!) -- adds these 10: dansguardian, dhcpd, iiab_admin, minetest, named, pylibs, squid, wondershaper, www_base, www_options
grep -hro '[A-Za-z_][A-Za-z_]*_installed: True' --exclude-dir=0-DEPRECATED-ROLES /opt/iiab/iiab/roles | sed 's/_installed: True$//' | sort | uniq > /tmp/iiab-apps-list
# Non-root CANNOT rm files from /tmp, but CAN write to them (unlike root!!)
# This ALSO creates the file (useful when "Apps2B" == 0, for iiab-summary etc)
truncate -s 0 /tmp/iiab-apps-to-be-installed
# So other (non-root) users CAN later write to these, even if they CAN'T chmod!
chmod 777 /tmp/iiab-apps-list /tmp/iiab-apps-to-be-installed 2>/dev/null
while read app; do
if [[ $app == "calibre-web" ]]; then
app=calibreweb
@ -27,8 +39,6 @@ while read app; do
# echo ${app}_install: $(iiab_var_value ${app}_install)
if [[ $(iiab_var_value ${app}_install) =~ ^[Tt]rue$ ]] && ! grep -q "${app}_installed: True" /etc/iiab/iiab_state.yml; then
echo $app
echo $app | tee -a /tmp/iiab-apps-to-be-installed
fi
done < /tmp/iiab-apps-list
rm /tmp/iiab-apps-list # So a non-root user can later run this cleanly!

View file

@ -127,45 +127,26 @@ function cat_tail() { # $1 = path/filename; $2 = # of lines, for tail
# START BUILDING UP THE FILE THAT'LL CONTAIN THE DIAGNOSTICS!
echo -e "\nCompiling diagnostics..."
echo -e "\n 0. Filename Header + Git Hashes + Raspberry Pi Model + OS"
echo -e "\n 0. HW + SW Quick Summary"
echo "This is: $outfile" >> $outfile
echo >> $outfile
echo -e "\n\n\n\n0. GIT INFO + RASPBERRY PI MODEL + OS" >> $outfile
echo >> $outfile
echo "iiab commit: $HASH1" >> $outfile
echo " remote: $REMOTE_URL1" >> $outfile
echo " branch: $BRANCH1" >> $outfile
printf "%4s merged PR's since recent tag: $TAG_COMMITS1\n" $PR_COUNT1 >> $outfile
echo >> $outfile
echo "iiab-admin-console commit: $HASH2" >> $outfile
echo " remote: $REMOTE_URL2" >> $outfile
echo " branch: $BRANCH2" >> $outfile
printf "%4s merged PR's since recent tag: $TAG_COMMITS2\n" $PR_COUNT2 >> $outfile
echo >> $outfile
cat_file /etc/iiab/pr-list-pulled
cat_file /proc/device-tree/model # Should be identical to /sys/firmware/devicetree/base/model
cat_file /etc/rpi-issue
echo "-IIAB-EXPLANATION-OF-THE-ABOVE-------------------------------------------------" >> $outfile
echo -e "\n\n\n\n0. HW + SW Quick Summary" >> $outfile
echo >> $outfile
/opt/iiab/iiab/scripts/iiab-summary >> $outfile
if [ -f /etc/rpi-issue ]; then
echo "stage2 = Raspberry Pi OS Lite" >> $outfile
echo "stage4 = Raspberry Pi OS with desktop" >> $outfile
echo "stage5 = Raspberry Pi OS with desktop + recommended software" >> $outfile
echo >> $outfile
echo "SEE https://github.com/RPi-Distro/pi-gen#stage-anatomy" >> $outfile
else
echo "(This is NOT Raspberry Pi OS!)" >> $outfile
fi
echo >> $outfile
cat_file /etc/issue.net
cat_file /etc/debian_version
cat_cmd 'dpkg --print-architecture' 'RaspiOS-on-PC shows: i386'
cat_cmd 'dpkg --print-foreign-architectures' 'RaspiOS-on-PC shows: amd64'
cat_cmd 'systemctl is-active display-manager.service' 'Graphical Desktop?'
cat_cmd 'grep "^openvpn_" /etc/iiab/local_vars.yml'
cat_cmd 'iiab-apps-to-be-installed' 'IIAB Apps to be installed'
fi
if [ -s /tmp/iiab-apps-to-be-installed ]; then
echo "iiab-apps-to-be-installed :" >> $outfile
cat /tmp/iiab-apps-to-be-installed >> $outfile
echo >> $outfile
fi
echo -e '\n\n 1. Files Specially Requested: (from "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n'
echo -e '\n 1. Files Specially Requested: (from "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n'
echo -e '\n\n\n\n1. FILES SPECIALLY REQUESTED (FROM "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' >> $outfile
for f in "$@"; do
cat_file $f
@ -277,7 +258,7 @@ echo
echo -e "\e[1m"
#if [ "$ans" == "" ] || [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
if ! [[ $ans =~ ^[nN]$ ]]; then
if ! [[ $ans =~ ^[nNqQ]$ ]]; then
echo -ne "PUBLISHING TO URL... "
#pastebinit -b dpaste.com < $outfile
pastebinit -b sprunge.us < $outfile # Run 'pastebinit -l' to list other possible pastebin site URLs

View file

@ -68,4 +68,4 @@ But first off, the file is compiled by harvesting 1 + 6 kinds of things:
## Source Code
Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 127-261 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible.
Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 127-242 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible.

View file

@ -76,7 +76,8 @@ fi
# landscape-sysinfo --sysinfo-plugins=Disk,Temperature,Load # Like: uptime -p
#fi
echo
echo "$(df -h /) ZIMs: $(ls /library/zims/content/ | wc -l) OER2Go: $(ls /library/www/html/modules/ | wc -l) Apps2B: $(/opt/iiab/iiab/scripts/iiab-apps-to-be-installed | wc -l)"
/opt/iiab/iiab/scripts/iiab-apps-to-be-installed > /dev/null
echo "$(df -h /) ZIMs: $(ls /library/zims/content/ | wc -l) OER2Go: $(ls /library/www/html/modules/ | wc -l) Apps2B: $(cat /tmp/iiab-apps-to-be-installed | wc -l)"
echo
echo $(ip -o link show | awk -F': ' '{print $2}') # Better order than: ls -rt /sys/class/net
grep "^openvpn_enabled:" /etc/iiab/local_vars.yml