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

Merge pull request #3291 from holta/iiab_remote_url

Extract IIAB_REMOTE_URL from 1 of 2 places, for both Git repos {iiab, iiab-admin-console} and...
This commit is contained in:
A Holt 2022-07-06 07:03:16 -04:00 committed by GitHub
commit 7403200a2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 45 deletions

View file

@ -29,8 +29,8 @@
value: "{{ ansible_architecture }}" value: "{{ ansible_architecture }}"
- option: iiab_base_ver - option: iiab_base_ver
value: "{{ iiab_base_ver }}" value: "{{ iiab_base_ver }}"
- option: iiab_remote - option: iiab_remote_url
value: "{{ ansible_local.local_facts.iiab_remote }}" value: "{{ ansible_local.local_facts.iiab_remote_url }}"
- option: iiab_branch - option: iiab_branch
value: "{{ ansible_local.local_facts.iiab_branch }}" value: "{{ ansible_local.local_facts.iiab_branch }}"
- option: iiab_commit - option: iiab_commit

View file

@ -68,8 +68,8 @@
value: "{{ iiab_base_ver }}" value: "{{ iiab_base_ver }}"
- option: iiab_revision - option: iiab_revision
value: "{{ iiab_revision }}" value: "{{ iiab_revision }}"
- option: iiab_remote - option: iiab_remote_url
value: "{{ ansible_local.local_facts.iiab_remote }}" value: "{{ ansible_local.local_facts.iiab_remote_url }}"
- option: runtime_branch - option: runtime_branch
value: "{{ ansible_local.local_facts.iiab_branch }}" value: "{{ ansible_local.local_facts.iiab_branch }}"
- option: runtime_commit - option: runtime_commit

View file

@ -8,6 +8,11 @@ iiab_var_value() {
[[ $v2 != "" ]] && echo $v2 || echo $v1 # [ "$v2" ] ALSO WORKS [[ $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) # 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 #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 # 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 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 while read app; do
if [[ $app == "calibre-web" ]]; then if [[ $app == "calibre-web" ]]; then
app=calibreweb app=calibreweb
@ -27,8 +39,6 @@ while read app; do
# echo ${app}_install: $(iiab_var_value ${app}_install) # 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 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 fi
done < /tmp/iiab-apps-list 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! # START BUILDING UP THE FILE THAT'LL CONTAIN THE DIAGNOSTICS!
echo -e "\nCompiling 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 "This is: $outfile" >> $outfile
echo >> $outfile echo >> $outfile
echo -e "\n\n\n\n0. GIT INFO + RASPBERRY PI MODEL + OS" >> $outfile echo -e "\n\n\n\n0. HW + SW Quick Summary" >> $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 >> $outfile echo >> $outfile
/opt/iiab/iiab/scripts/iiab-summary >> $outfile
if [ -f /etc/rpi-issue ]; then if [ -f /etc/rpi-issue ]; then
echo "stage2 = Raspberry Pi OS Lite" >> $outfile echo "stage2 = Raspberry Pi OS Lite" >> $outfile
echo "stage4 = Raspberry Pi OS with desktop" >> $outfile echo "stage4 = Raspberry Pi OS with desktop" >> $outfile
echo "stage5 = Raspberry Pi OS with desktop + recommended software" >> $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 echo "SEE https://github.com/RPi-Distro/pi-gen#stage-anatomy" >> $outfile
else echo >> $outfile
echo "(This is NOT Raspberry Pi OS!)" >> $outfile 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 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'
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 echo -e '\n\n\n\n1. FILES SPECIALLY REQUESTED (FROM "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' >> $outfile
for f in "$@"; do for f in "$@"; do
cat_file $f cat_file $f
@ -277,7 +258,7 @@ echo
echo -e "\e[1m" echo -e "\e[1m"
#if [ "$ans" == "" ] || [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then #if [ "$ans" == "" ] || [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
if ! [[ $ans =~ ^[nN]$ ]]; then if ! [[ $ans =~ ^[nNqQ]$ ]]; then
echo -ne "PUBLISHING TO URL... " echo -ne "PUBLISHING TO URL... "
#pastebinit -b dpaste.com < $outfile #pastebinit -b dpaste.com < $outfile
pastebinit -b sprunge.us < $outfile # Run 'pastebinit -l' to list other possible pastebin site URLs 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 ## 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

@ -12,7 +12,14 @@ COMMITS1=$(git log "$TAG1..HEAD" --oneline | wc -l)
PR_COUNT1=$(git log "$TAG1..HEAD" --oneline --grep='Merge pull request' | wc -l) PR_COUNT1=$(git log "$TAG1..HEAD" --oneline --grep='Merge pull request' | wc -l)
COMMIT_MSG1=$(git log --format=%B -1 | head -1) COMMIT_MSG1=$(git log --format=%B -1 | head -1)
BRANCH1=$(git branch --show-current) BRANCH1=$(git branch --show-current)
REMOTE_URL1=$(git config remote.$(git config branch.$BRANCH1.remote).url) REMOTE_URL1="none"
tmp=$(git config branch.$BRANCH1.remote) && {
if [[ $tmp =~ ^"https://" ]]; then
REMOTE_URL1=$tmp
else
REMOTE_URL1=$(git config remote.$tmp.url)
fi
}
git config --global --add safe.directory /opt/iiab/iiab-admin-console # Nec below, if non-root git config --global --add safe.directory /opt/iiab/iiab-admin-console # Nec below, if non-root
cd /opt/iiab/iiab-admin-console cd /opt/iiab/iiab-admin-console
@ -22,7 +29,14 @@ COMMITS2=$(git log "$TAG2..HEAD" --oneline | wc -l)
PR_COUNT2=$(git log "$TAG2..HEAD" --oneline --grep='Merge pull request' | wc -l) PR_COUNT2=$(git log "$TAG2..HEAD" --oneline --grep='Merge pull request' | wc -l)
COMMIT_MSG2=$(git log --format=%B -1 | head -1) COMMIT_MSG2=$(git log --format=%B -1 | head -1)
BRANCH2=$(git branch --show-current) BRANCH2=$(git branch --show-current)
REMOTE_URL2=$(git config remote.$(git config branch.$BRANCH2.remote).url) REMOTE_URL2="none"
tmp=$(git config branch.$BRANCH2.remote) && {
if [[ $tmp =~ ^"https://" ]]; then
REMOTE_URL2=$tmp
else
REMOTE_URL2=$(git config remote.$tmp.url)
fi
}
echo "$(grep install_date /etc/iiab/iiab.ini) Current TZ: $(date +%Z)" echo "$(grep install_date /etc/iiab/iiab.ini) Current TZ: $(date +%Z)"
echo echo
@ -62,7 +76,8 @@ fi
# landscape-sysinfo --sysinfo-plugins=Disk,Temperature,Load # Like: uptime -p # landscape-sysinfo --sysinfo-plugins=Disk,Temperature,Load # Like: uptime -p
#fi #fi
echo 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
echo $(ip -o link show | awk -F': ' '{print $2}') # Better order than: ls -rt /sys/class/net 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 grep "^openvpn_enabled:" /etc/iiab/local_vars.yml

View file

@ -12,7 +12,7 @@
STAGE=0 STAGE=0
OS="none" OS="none"
VERSION_ID="none" # This var's combined with the above, before being output VERSION_ID="none" # This var's combined with the above, before being output
IIAB_REMOTE="none" IIAB_REMOTE_URL="none"
IIAB_BRANCH="none" IIAB_BRANCH="none"
IIAB_COMMIT="none" IIAB_COMMIT="none"
IIAB_RECENT_TAG="none" IIAB_RECENT_TAG="none"
@ -91,8 +91,13 @@ esac
tmp=$(git rev-parse --abbrev-ref HEAD) && tmp=$(git rev-parse --abbrev-ref HEAD) &&
IIAB_BRANCH=$tmp IIAB_BRANCH=$tmp
tmp=$(git config remote.$(git config branch.$IIAB_BRANCH.remote).url) && tmp=$(git config branch.$IIAB_BRANCH.remote) && {
IIAB_REMOTE=$tmp if [[ $tmp =~ ^"https://" ]]; then
IIAB_REMOTE_URL=$tmp
else
IIAB_REMOTE_URL=$(git config remote.$tmp.url)
fi
}
tmp=$(git rev-parse --verify HEAD) && tmp=$(git rev-parse --verify HEAD) &&
IIAB_COMMIT=$tmp IIAB_COMMIT=$tmp
@ -145,7 +150,7 @@ cat <<EOF
"dhcpcd" : "$DHCPCD", "dhcpcd" : "$DHCPCD",
"network_manager" : "$NETWORK_MANAGER", "network_manager" : "$NETWORK_MANAGER",
"systemd_networkd" : "$SYSTEMD_NETWORKD", "systemd_networkd" : "$SYSTEMD_NETWORKD",
"iiab_remote" : "$IIAB_REMOTE", "iiab_remote_url" : "$IIAB_REMOTE_URL",
"iiab_branch" : "$IIAB_BRANCH", "iiab_branch" : "$IIAB_BRANCH",
"iiab_commit" : "$IIAB_COMMIT", "iiab_commit" : "$IIAB_COMMIT",
"iiab_recent_tag" : "$IIAB_RECENT_TAG", "iiab_recent_tag" : "$IIAB_RECENT_TAG",