Skip to content

Commit

Permalink
Added system helper file move update_skel and qr_code from PR #49
Browse files Browse the repository at this point in the history
  • Loading branch information
Tearran committed Sep 1, 2024
1 parent 0556d39 commit 9b9bc05
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 2 deletions.
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# Armbian Configuration Utility
Updated: Thu Aug 29 11:45:21 AM UTC 2024
Updated: Sun Sep 1 03:03:48 PM EDT 2024

Utility for configuring your board, adjusting services, and installing applications. It comes with Armbian by default.

Expand All @@ -15,6 +15,9 @@ sudo armbian-config
- **S03** - Edit the boot environment
- **S04** - Install Linux headers
- **S05** - Remove Linux headers
- **S06** - Install to internal storage
- **S30** - Change shell system wide to BASH
- **S31** - Change shell system wide to ZSH


- ## **Network**
Expand Down Expand Up @@ -88,6 +91,9 @@ Usage: armbian-configng [option] [arguments]
--cli S03 - Edit the boot environment
--cli S04 - Install Linux headers
--cli S05 - Remove Linux headers
--cli S06 - Install to internal storage
--cli S30 - Change shell system wide to BASH
--cli S31 - Change shell system wide to ZSH
--cli N00 - Install Bluetooth support
--cli N01 - Remove Bluetooth support
--cli N02 - Bluetooth Discover
Expand Down Expand Up @@ -194,6 +200,46 @@ Jobs:
Headers_remove
~~~

### S06

Install to internal storage

Jobs:

~~~
armbian-install
~~~

### S30

Change shell system wide to BASH

Jobs:

~~~
export BASHLOCATION=$(grep /bash$ /etc/shells | tail -1)
sed -i "s|^SHELL=.*|SHELL=${BASHLOCATION}|" /etc/default/useradd
sed -i "s|^DSHELL=.*|DSHELL=${BASHLOCATION}|" /etc/adduser.conf
debconf-apt-progress -- apt-get -y purge armbian-zsh
update_skel
awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534 || $3 == 0) print $1}' /etc/passwd | xargs -L1 chsh -s $(grep /bash$ /etc/shells | tail -1)
~~~

### S31

Change shell system wide to ZSH

Jobs:

~~~
export ZSHLOCATION=$(grep /zsh$ /etc/shells | tail -1)
sed -i "s|^SHELL=.*|SHELL=${ZSHLOCATION}|" /etc/default/useradd
sed -i "s|^DSHELL=.*|DSHELL=${ZSHLOCATION}|" /etc/adduser.conf
debconf-apt-progress -- apt-get -y install armbian-zsh
update_skel
awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534 || $3 == 0) print $1}' /etc/passwd | xargs -L1 chsh -s $(grep /zsh$ /etc/shells | tail -1)
~~~

### N00

Install Bluetooth support
Expand Down Expand Up @@ -447,6 +493,7 @@ These helper functions facilitate various operations related to job management,
| Display a Yes/No dialog box and process continue/exit | get_user_continue 'Do you wish to continue?' process_input | Joey Turner
| Display a message box | show_message <<< 'hello world' | Joey Turner
| Migrated procedures from Armbian config. | connect_bt_interface | Igor Pecovnik
| Show or generate QR code for Google OTP | qr_code generate | Igor Pecovnik
| Freeze/unhold Migrated procedures from Armbian config. | set_safe_boot unhold or set_safe_boot freeze | Igor Pecovnik
| Check if kernel headers are installed | are_headers_installed | Gunjan Gupta
| Check when apt list was last updated | see_current_apt | Joey Turner
Expand All @@ -472,6 +519,7 @@ These helper functions facilitate various operations related to job management,
| Parse json to get list of desired menu or submenu items | parse_menu_items 'menu_options_array' | Gunjan Gupta
| Show the usage of the functions. | see_use | Joey Turner
| Check the internet connection with fallback DNS | see_ping | Joey Turner
| Update the /etc/skel files in users directories | update_skel | Igor Pecovnik
| Secure version of get_user_continue | get_user_continue_secure 'Do you wish to continue?' process_input | Joey Turner


Expand Down
4 changes: 3 additions & 1 deletion bin/armbian-configng
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ declare -A module_options
#
# Load configng core functions and module options array

source "$lib_dir/config.ng.functions.sh"
source "$lib_dir/config.ng.functions.sh"
set_runtime_variables
echo "Loaded Runtime variables..." #| show_infobox ;
#set_newt_colors 2
echo "Loaded Dialog..." #| show_infobox ;
source "$lib_dir/config.ng.docs.sh"
echo "Loaded Docs..." #| show_infobox ;
source "$lib_dir/config.ng.system.sh"
echo "Loaded System helpers..." #| show_infobox ;
source "$lib_dir/config.ng.network.sh"
echo "Loaded Network helpers..." #| show_infobox ;

Expand Down
54 changes: 54 additions & 0 deletions lib/armbian-configng/config.ng.system.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash


module_options+=(
["update_skel,author"]="Igor Pecovnik"
["update_skel,ref_link"]=""
["update_skel,feature"]="update_skel"
["update_skel,desc"]="Update the /etc/skel files in users directories"
["update_skel,example"]="update_skel"
["update_skel,status"]="Active"
)
#
# check dpkg status of $1 -- currently only 'not installed at all' case caught
#
function update_skel (){

getent passwd |
while IFS=: read -r username x uid gid gecos home shell
do
if [ ! -d "$home" ] || [ "$username" == 'root' ] || [ "$uid" -lt 1000 ]
then
continue
fi
tar -C /etc/skel/ -cf - . | su - "$username" -c "tar --skip-old-files -xf -"
done

}


module_options+=(
["qr_code,author"]="Igor Pecovnik"
["qr_code,ref_link"]=""
["qr_code,feature"]="qr_code"
["qr_code,desc"]="Show or generate QR code for Google OTP"
["qr_code,example"]="qr_code generate"
["qr_code,status"]="Active"
)
#
# check dpkg status of $1 -- currently only 'not installed at all' case caught
#
function qr_code (){

clear
if [[ "$1" == "generate" ]]; then
google-authenticator -t -d -f -r 3 -R 30 -W -q
cp /root/.google_authenticator /etc/skel
update_skel
fi
export TOP_SECRET=$(head -1 /root/.google_authenticator)
qrencode -m 2 -d 9 -8 -t ANSI256 "otpauth://totp/test?secret=$TOP_SECRET"
echo -e '\nScan QR code with your OTP application on mobile phone\n'
read -n 1 -s -r -p "Press any key to continue"

}

0 comments on commit 9b9bc05

Please sign in to comment.