From 6d38dd63176a33fc7f2a353c17fd968100b2720c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 6 Jul 2022 02:50:05 -0500 Subject: [PATCH 1/5] iiab-diagnostics - use full path to repo location for iiab-apps-to-be-installed Reason: Shared helper file, recent changes will appear with just a 'git pull' not requiring an ansible run to install the file first. --- scripts/iiab-diagnostics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index 957111ad1..9beb929f9 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -163,7 +163,7 @@ 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' +cat_cmd '/opt/iiab/iiab/scripts/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\n\n\n1. FILES SPECIALLY REQUESTED (FROM "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' >> $outfile From afa45d3f5552ced5e96b210628c67bda3efa4b28 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 6 Jul 2022 02:57:10 -0500 Subject: [PATCH 2/5] iiab-summary - update on the fly --- roles/0-init/tasks/main.yml | 7 +++++-- roles/1-prep/tasks/main.yml | 9 --------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml index b7d128124..7831663a0 100644 --- a/roles/0-init/tasks/main.yml +++ b/roles/0-init/tasks/main.yml @@ -32,11 +32,14 @@ # Copies the latest/known version of iiab-diagnostics into /usr/bin (so it can # be run even if local source tree /opt/iiab/iiab is deleted to conserve disk). -- name: Copy /opt/iiab/iiab/scripts/iiab-diagnostics to /usr/bin/ +- name: Copy iiab-summary & iiab-diagnostics from /opt/iiab/iiab/scripts/ to /usr/bin/ copy: - src: "{{ iiab_dir }}/scripts/iiab-diagnostics" + src: "{{ iiab_dir }}/scripts/{{ item }}" dest: /usr/bin/ mode: '0755' + with_items: + - iiab-summary + - iiab-diagnostics - name: Create globally-writable directory /etc/iiab/diag (0777) so non-root users can run 'iiab-diagnostics' file: diff --git a/roles/1-prep/tasks/main.yml b/roles/1-prep/tasks/main.yml index 0dfd32ee0..e4132ad4c 100644 --- a/roles/1-prep/tasks/main.yml +++ b/roles/1-prep/tasks/main.yml @@ -23,15 +23,6 @@ name: iiab-admin #when: iiab_admin_install # Flag might be created in future? -- name: Copy iiab-summary & iiab-apps-to-be-installed from /opt/iiab/iiab/scripts/ to /usr/bin/ - copy: - src: "{{ iiab_dir }}/scripts/{{ item }}" - dest: /usr/bin/ - mode: '0755' - with_items: - - iiab-summary - - iiab-apps-to-be-installed - - name: Install dnsmasq -- configure LATER in 'network', after Stage 9 include_tasks: roles/network/tasks/dnsmasq.yml #when: dnsmasq_install # Flag might be used in future? From 16c1bf8e126b1614d80a3374bc2b771907bc554c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 6 Jul 2022 11:35:00 -0500 Subject: [PATCH 3/5] Update iiab-diagnostics --- scripts/iiab-diagnostics | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index 3b4b37de0..f447fb3d1 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -146,7 +146,6 @@ if [ -s /tmp/iiab-apps-to-be-installed ]; then echo >> $outfile fi - 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 From 99d5debbf4652b25381b3c8658cf4687111f9cda Mon Sep 17 00:00:00 2001 From: root Date: Wed, 6 Jul 2022 15:25:14 -0400 Subject: [PATCH 4/5] iiab-summary: Remove bold font for pastebin. Restore /usr/bin/iiab-apps-to-be-installed --- roles/1-prep/tasks/main.yml | 6 ++++++ scripts/iiab-summary | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/1-prep/tasks/main.yml b/roles/1-prep/tasks/main.yml index e4132ad4c..d7af981bd 100644 --- a/roles/1-prep/tasks/main.yml +++ b/roles/1-prep/tasks/main.yml @@ -23,6 +23,12 @@ name: iiab-admin #when: iiab_admin_install # Flag might be created in future? +- name: Copy iiab-apps-to-be-installed from {{ iiab_dir }} to /usr/bin/ + copy: + src: "{{ iiab_dir }}/scripts/iiab-apps-to-be-installed" # /opt/iiab/iiab/scripts + dest: /usr/bin/ + mode: '0755' + - name: Install dnsmasq -- configure LATER in 'network', after Stage 9 include_tasks: roles/network/tasks/dnsmasq.yml #when: dnsmasq_install # Flag might be used in future? diff --git a/scripts/iiab-summary b/scripts/iiab-summary index ffd9ac45c..2e1da90a7 100755 --- a/scripts/iiab-summary +++ b/scripts/iiab-summary @@ -41,7 +41,7 @@ tmp=$(git config branch.$BRANCH2.remote) && { echo "$(grep install_date /etc/iiab/iiab.ini) Current TZ: $(date +%Z)" echo echo -e "iiab: $SHORT_HASH1, $PR_COUNT1 PR's / $COMMITS1 commits since tag $TAG1" -echo -e " \e[1m\"$COMMIT_MSG1\"\e[0m" +echo -e " \"$COMMIT_MSG1\"" echo " $REMOTE_URL1 branch: $BRANCH1" if [ -f /etc/iiab/pr-list-pulled ]; then echo @@ -51,7 +51,7 @@ fi echo if [ -d /opt/iiab/iiab-admin-console ]; then echo -e "iiab-admin-console: $SHORT_HASH2, $PR_COUNT2 PR's / $COMMITS2 commits since tag $TAG2" - echo -e " \e[1m\"$COMMIT_MSG2\"\e[0m" + echo -e " \"$COMMIT_MSG2\"" echo " $REMOTE_URL2 branch: $BRANCH2" else echo " WARNING: Directory /opt/iiab/iiab-admin-console does not exist!" From e8ee4400ead70048800c36e4579a7eaecedd71ce Mon Sep 17 00:00:00 2001 From: root Date: Wed, 6 Jul 2022 15:38:45 -0400 Subject: [PATCH 5/5] iiab-diagnostics output: Less spacing betw 6 sections --- scripts/iiab-diagnostics | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index f447fb3d1..2de2e1c76 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -130,7 +130,7 @@ echo -e "\nCompiling diagnostics..." echo -e "\n 0. HW + SW Quick Summary" echo "This is: $outfile" >> $outfile echo >> $outfile -echo -e "\n\n\n\n0. HW + SW Quick Summary" >> $outfile +echo -e "\n\n\n0. HW + SW Quick Summary" >> $outfile echo >> $outfile /opt/iiab/iiab/scripts/iiab-summary >> $outfile if [ -f /etc/rpi-issue ]; then @@ -147,7 +147,7 @@ if [ -s /tmp/iiab-apps-to-be-installed ]; then fi 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\n1. FILES SPECIALLY REQUESTED (FROM "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' >> $outfile for f in "$@"; do cat_file $f done @@ -157,7 +157,7 @@ if [ $# -eq 0 ]; then else echo -e "\n 2. Regular Files:\n" fi -echo -e "\n\n\n\n2. REGULAR FILES\n" >> $outfile +echo -e "\n\n\n2. REGULAR FILES\n" >> $outfile #cat_file /dev/sda # Device "file" test #cat_file /nonsense # Non-existence test #cat_file /opt/iiab/iiab # Directory test @@ -181,7 +181,7 @@ cat_file /library/www/html/home/menu.json #cat_file /tmp/all-ansible-vars echo -e "\n 3. Content of Directories: (1-level deep)\n" -echo -e "\n\n\n\n3. CONTENT OF DIRECTORIES (1-LEVEL DEEP)\n" >> $outfile +echo -e "\n\n\n3. CONTENT OF DIRECTORIES (1-LEVEL DEEP)\n" >> $outfile cat_dir /etc/network/interfaces.d cat_dir /etc/systemd/network cat_dir /etc/NetworkManager/system-connections # Redacts most passwords above @@ -190,7 +190,7 @@ cat_dir /etc/netplan # Redacts most passwords above #cat_dir /etc/network # Above file /etc/network/interfaces suffices echo -e "\n 4. Output of Commands:\n" -echo -e "\n\n\n\n\n4. OUTPUT OF COMMANDS\n" >> $outfile +echo -e "\n\n\n\n4. OUTPUT OF COMMANDS\n" >> $outfile cat_cmd 'uname -a' 'Linux kernel' cat_cmd 'free' 'RAM memory' cat_cmd 'lscpu' 'CPU details' @@ -226,12 +226,12 @@ cat_cmd 'journalctl -t IIAB-CMDSRV' 'Admin Console CMDSRV log' #cat_cmd 'ansible localhost -m setup 2>/dev/null' 'All Ansible facts' # For cleaner scraping of Ansible vars, consider "./runrole all-vars /tmp/all-ansible-vars" 27-31 lines above? echo -e "\n 5. Firewall Rules:\n" -echo -e "\n\n\n\n5. FIREWALL RULES\n" >> $outfile +echo -e "\n\n\n5. FIREWALL RULES\n" >> $outfile #cat_file /usr/bin/iiab-gen-iptables cat_cmd 'sudo iptables-save' 'Firewall rules' echo -e "\n 6. Log Files: (e.g. last 100 lines of each)\n" -echo -e "\n\n\n\n6. LOG FILES (e.g. LAST 100 LINES OF EACH)\n" >> $outfile +echo -e "\n\n\n6. LOG FILES (e.g. LAST 100 LINES OF EACH)\n" >> $outfile cat_cmd 'grep -B2 "SEE ERROR ABOVE" /opt/iiab/iiab/*.log' 'for skip_role_on_error' cat_tail /opt/iiab/iiab/iiab-install.log 100 cat_tail /opt/iiab/iiab/iiab-configure.log 100