added a prompt in installer to ask what to install

This commit is contained in:
asus
2023-10-16 21:11:18 +02:00
parent 5ce52ef900
commit cfa04e6ed5
3 changed files with 120 additions and 26 deletions

View File

@@ -2,7 +2,7 @@
#PS1="%(?:%{%}➜ :%{%}➜ ) %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)"
PS1='%(?:%{%}➜ :%{%}➜ ) %{$fg[cyan]%}%test%{$reset_color%} $(git_prompt_info)'
#PS1='%(?:%{%}➜ :%{%}➜ ) %{$fg[cyan]%}%test%{$reset_color%} $(git_prompt_info)'

View File

@@ -7,25 +7,12 @@ source ./asides/color.sh
KEY_PHRASE="#hugogogo#"
HERE=$(pwd)
D_CONFIG_FILES="config_files"
ASK_INSTALL="y"
# create those folders if necessary :
mkdir -p ~/.vim/templates
mkdir -p ~/.vim/swapfiles
# tells git to use vim as default editor
echo -e $MAGENTA"declared vim as default editor for git"$ENDCO
git config --global core.editor "vim"
# install those package :
# vim
# wget
# vlc
# signal-desktop
# element-desktop
# nextcloud-desktop
# transmission
# htop
# build-essential (gcc g++ make etc...)
# receive 1 argument : absolute path to config file
function save_bak
@@ -48,7 +35,7 @@ function save_bak
mv $file_to $file_to.hubak$number
}
# receive 1 argument : absolute path to config file
# receives 1 argument : "absolute path to config file"
function install
{
local file_to="$1"
@@ -85,14 +72,108 @@ function install
fi
}
# argument : directory where the config file should go
# receives 1 argument : a chain of acceptables uniques characters (ex: yn)
function user_choice
{
while true; do
read -n 1 -s choice
if [[ $choice == [$1] ]]; then
# the function need to run in a command substitution, and this line gives the result
echo $choice
return
fi
done
}
# Ask what to install
echo "
(a) Do you want to config all programs: git, screen, zsh, and vim ?
(c) Or do you want to choose for each of them ?
validate by typing the character in parenthesis (-) :
"
ASK_INSTALL=$(user_choice "ac")
CONFIG_GIT=n
CONFIG_SCREEN=n
CONFIG_ZSH=n
CONFIG_VIM=n
if [ "$ASK_INSTALL" = "a" ]; then
CONFIG_GIT=y
CONFIG_SCREEN=y
CONFIG_ZSH=y
CONFIG_VIM=y
fi
# config each program :
if [ "$ASK_INSTALL" = "c" ]; then
echo "
do you want to config git ?
(y) Yes
(n) No
"
CONFIG_GIT=$(user_choice "yn")
fi
if [ "$CONFIG_GIT" = "y" ]; then
echo "config git"
echo -e $MAGENTA"make vim default editor for git"$ENDCO
git config --global core.editor "vim"
else
echo "skip git"
fi
if [ "$ASK_INSTALL" = "c" ]; then
echo "
do you want to config screen ?
(y) Yes
(n) No
"
CONFIG_SCREEN=$(user_choice "yn")
fi
if [ "$CONFIG_SCREEN" = "y" ]; then
echo "config screen"
install "$HOME/.screenrc"
install "$HOME/.vimrc"
else
echo "skip screen"
fi
if [ "$ASK_INSTALL" = "c" ]; then
echo "
do you want to config zsh ?
(y) Yes
(n) No
"
CONFIG_ZSH=$(user_choice "yn")
fi
if [ "$CONFIG_ZSH" = "y" ]; then
echo "config zsh"
install "$HOME/.zshrc"
else
echo "skip zsh"
fi
if [ "$ASK_INSTALL" = "c" ]; then
echo "
do you want to config vim ?
(y) Yes
(n) No
"
CONFIG_VIM=$(user_choice "yn")
fi
if [ "$CONFIG_VIM" = "y" ]; then
echo "config vim"
install "$HOME/.vimrc"
install "$HOME/.vim/templates/skeleton_colors.h"
install "$HOME/.vim/templates/skeleton_tests.hpp"
install "$HOME/.vim/templates/skeleton.cpp"
install "$HOME/.vim/templates/skeleton.hpp"
install "$HOME/.vim/templates/skeleton_main.cpp"
install "$HOME/.vim/templates/skeleton_makefile"
else
echo "skip vim"
fi

View File

@@ -269,3 +269,16 @@ find | sort | grep -ve "node_modules/" -e ".git/" | sed 's#[^/]*/#|__ #g;s#__ |#
**todo !**
- re-add code to move cursor on wrap text in vimrc
- add vimrc, zshrc, and screenrc in default screen windows
**ecowan server :**
- changed user "root" and "ecowan" password
- sudo passwd username
- created "huho" user (with same passwd)
- added it to the sudo group so it can use sudo (`sudo usermod -aG sudo huho`)
- did not add it to the sudoers file (`visudo` then add line `huho ALL=(ALL) ALL`)
- disabling user "ecowan" shell access with `sudo usermod --shell /sbin/nologin ecowan`
- https://unix.stackexchange.com/questions/10852/whats-the-difference-between-sbin-nologin-and-bin-false#10867
- its possible to re-enable it with `sudo usermod --shell /bin/bash ecowan`
- added ssh pub key by running this command in local :
- ssh-copy-id username@server_ip