ok. improve the install notes

This commit is contained in:
Dict Xiong 2022-11-08 22:49:01 +08:00
parent b3c12bc395
commit 0f75578800
2 changed files with 11 additions and 6 deletions

View File

@ -105,7 +105,7 @@ jobs:
steps: steps:
- name: remove dependencies - name: remove dependencies
run: | run: |
sudo apt-get remove curl vim sudo apt-get -y remove curl vim
- name: checkout repo - name: checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v3

View File

@ -28,7 +28,7 @@ HOME_SYMLINKS_DST[0]=".ssh/authorized_keys2"
install_dependencies() install_dependencies()
{ {
fmt_info "installing dependencies ..." fmt_note "installing dependencies ..."
case $(get_os_type) in case $(get_os_type) in
"linux" ) "linux" )
case $(get_linux_dist) in case $(get_linux_dist) in
@ -66,6 +66,7 @@ install_dependencies()
preinstall_check() preinstall_check()
{ {
fmt_note "checking requirements ..."
mandatory_commands=( "git" "zsh" "curl" "ping" ) mandatory_commands=( "git" "zsh" "curl" "ping" )
optional_commands=( "python3" "vim" "tmux" ) optional_commands=( "python3" "vim" "tmux" )
for i in "${mandatory_commands[@]}"; do for i in "${mandatory_commands[@]}"; do
@ -90,10 +91,11 @@ preinstall_check()
install_file_content() install_file_content()
{ {
fmt_note "installing file content ..."
for ((i=0; i<${#HOME_FILES_PATH[@]}; i++)); do for ((i=0; i<${#HOME_FILES_PATH[@]}; i++)); do
local filename="$HOME/${HOME_FILES_PATH[$i]}" local filename="$HOME/${HOME_FILES_PATH[$i]}"
local content=${HOME_FILES_CONTENT[$i]} local content=${HOME_FILES_CONTENT[$i]}
fmt_note "installing \"$content\" into \"$filename\" ..." fmt_info "installing \"$content\" into \"$filename\" ..."
mkdir -p $(dirname "$filename") mkdir -p $(dirname "$filename")
if [ ! -f "$filename" ]; then if [ ! -f "$filename" ]; then
touch $filename touch $filename
@ -104,10 +106,11 @@ install_file_content()
uninstall_file_content() uninstall_file_content()
{ {
fmt_note "uninstalling file content ..."
for ((i=0; i<${#HOME_FILES_PATH[@]}; i++)); do for ((i=0; i<${#HOME_FILES_PATH[@]}; i++)); do
local filename="$HOME/${HOME_FILES_PATH[$i]}" local filename="$HOME/${HOME_FILES_PATH[$i]}"
local content=${HOME_FILES_CONTENT[$i]} local content=${HOME_FILES_CONTENT[$i]}
fmt_note "removing \"$content\" from \"$filename\" ..." fmt_info "removing \"$content\" from \"$filename\" ..."
if [ -f "$filename" ]; then if [ -f "$filename" ]; then
grep -vxF -- "$content" "$filename" | tee "$filename" grep -vxF -- "$content" "$filename" | tee "$filename"
fi fi
@ -116,10 +119,11 @@ uninstall_file_content()
install_symlink() install_symlink()
{ {
fmt_note "installing symlinks ..."
for ((i=0; i<${#HOME_SYMLINKS_SRC[@]}; i++)); do for ((i=0; i<${#HOME_SYMLINKS_SRC[@]}; i++)); do
local src="$DOTFILES/${HOME_SYMLINKS_SRC[$i]}" local src="$DOTFILES/${HOME_SYMLINKS_SRC[$i]}"
local dst="$HOME/${HOME_SYMLINKS_DST[$i]}" local dst="$HOME/${HOME_SYMLINKS_DST[$i]}"
fmt_note "creating symlink \"$dst\" --> \"$src\" ..." fmt_info "creating symlink \"$dst\" --> \"$src\" ..."
if [ ! -f "$src" ]; then if [ ! -f "$src" ]; then
fmt_error "\"$src\" does not exist! aborting this job ..." fmt_error "\"$src\" does not exist! aborting this job ..."
continue continue
@ -147,13 +151,14 @@ install_symlink()
uninstall_symlink() uninstall_symlink()
{ {
fmt_note "uninstalling symlinks ..."
local src local src
for src in "${!HOME_SYMLINKS[@]}"; do for src in "${!HOME_SYMLINKS[@]}"; do
local dst=${HOME_SYMLINKS[$src]} local dst=${HOME_SYMLINKS[$src]}
src="$DOTFILES/$src" src="$DOTFILES/$src"
dst="$HOME/$dst" dst="$HOME/$dst"
if [ "$(readlink $dst)" -ef "$src" ]; then if [ "$(readlink $dst)" -ef "$src" ]; then
fmt_note "removing symlink \"$dst\" ..." fmt_info "removing symlink \"$dst\" ..."
echo ---------- echo ----------
stat $dst stat $dst
echo ---------- echo ----------