-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZSH: move functions from JSON to separate modules
- Loading branch information
1 parent
f058282
commit 7ea3744
Showing
2 changed files
with
49 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module_options+=( | ||
["manage_zsh,author"]="@igorpecovnik" | ||
["manage_zsh,ref_link"]="" | ||
["manage_zsh,feature"]="manage_zsh" | ||
["manage_zsh,desc"]="Set system shell to BASH" | ||
["manage_zsh,example"]="manage_zsh enable|disable" | ||
["manage_zsh,status"]="Active" | ||
) | ||
# | ||
# @description Set system shell to ZSH | ||
# | ||
function manage_zsh() { | ||
|
||
local bash_location=$(grep /bash$ /etc/shells | tail -1) | ||
local zsh_location=$(grep /zsh$ /etc/shells | tail -1) | ||
|
||
if [[ "$1" == "enable" ]]; then | ||
|
||
sed -i "s|^SHELL=.*|SHELL=/bin/zsh|" /etc/default/useradd | ||
sed -i -E "s|(^\|#)DSHELL=.*|DSHELL=/bin/zsh|" /etc/adduser.conf | ||
|
||
# install | ||
apt_install_wrapper apt-get -y install armbian-zsh zsh-common zsh tmux | ||
|
||
update_skel | ||
|
||
# change shell for root | ||
usermod --shell "/bin/zsh" root | ||
# change shell for others | ||
sed -i 's/bash$/zsh/g' /etc/passwd | ||
|
||
else | ||
|
||
sed -i "s|^SHELL=.*|SHELL=/bin/bash|" /etc/default/useradd | ||
sed -i -E "s|(^\|#)DSHELL=.*|DSHELL=/bin/bash|" /etc/adduser.conf | ||
|
||
# remove | ||
apt_install_wrapper apt-get -y remove armbian-zsh zsh-common zsh tmux | ||
|
||
# change shell for root | ||
usermod --shell "/bin/bash" root | ||
# change shell for others | ||
sed -i 's/zsh$/bash/g' /etc/passwd | ||
|
||
fi | ||
|
||
} |