mirror of
https://github.com/armbian/configng.git
synced 2026-01-06 10:37:41 -08:00
Add support for changing login shells between ZSH and BASH (#50)
* Add support for changing login shells between ZSH and BASH * Added system helper file move update_skel and qr_code from PR #49 --------- Co-authored-by: Tearran <tearran@gmail.com>
This commit is contained in:
50
README.md
50
README.md
@@ -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.
|
||||
|
||||
@@ -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**
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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 ;
|
||||
|
||||
|
||||
@@ -75,8 +75,41 @@
|
||||
"src_reference": "",
|
||||
"author": "https://github.com/igorpecovnik",
|
||||
"condition": "[[ -n $(ls /sbin/armbian-install) ]]"
|
||||
},
|
||||
{
|
||||
"id": "S30",
|
||||
"description": "Change shell system wide to BASH",
|
||||
"command": [
|
||||
"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)"
|
||||
],
|
||||
"status": "Pending Review",
|
||||
"doc_link": "",
|
||||
"src_reference": "",
|
||||
"author": "https://github.com/igorpecovnik",
|
||||
"condition": "[[ $(cat /etc/passwd | grep \"^root:\" | rev | cut -d\":\" -f1 | cut -d\"/\" -f1| rev) == \"zsh\" ]]"
|
||||
},
|
||||
{
|
||||
"id": "S31",
|
||||
"description": "Change shell system wide to ZSH",
|
||||
"command": [
|
||||
"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)"
|
||||
],
|
||||
"status": "Pending Review",
|
||||
"doc_link": "",
|
||||
"src_reference": "",
|
||||
"author": "https://github.com/igorpecovnik",
|
||||
"condition": "[[ $(cat /etc/passwd | grep \"^root:\" | rev | cut -d\":\" -f1 | cut -d\"/\" -f1| rev) == \"bash\" ]]"
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
54
lib/armbian-configng/config.ng.system.sh
Normal file
54
lib/armbian-configng/config.ng.system.sh
Normal file
@@ -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"
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user