This commit is contained in:
pvincent
2026-08-06 23:06:47 +04:00
parent d2a2343987
commit e863bd0c6e
2 changed files with 35 additions and 22 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ Any feedback would be appreciated.
## install ## install
```bash ```bash
curl https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install.sh | sudo bash -s` curl -s https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install.sh | sudo bash -s`
``` ```
## upgrade ## upgrade
+34 -21
View File
@@ -3,8 +3,7 @@
# CONSTANTS # CONSTANTS
readonly REQUIRED_PKGS=(file jq vim) readonly REQUIRED_PKGS=(file jq vim)
readonly ORIGINAL="ORIGINAL" readonly BACKUP='ORIGINAL'
readonly PREDEFINED_CONFIG_FILES=(/etc/bash.bashrc /etc/inputrc)
# FUNCTIONS # FUNCTIONS
@@ -13,33 +12,47 @@ function required_packages {
} }
function no_more_skeleton { function no_more_skeleton {
[[ -e /etc/skel/.bashrc ]] && rm /etc/skel/.bashrc && echo "skeleton .bashrc removed!" if [[ -e /etc/skel/.bashrc ]]; then
true rm /etc/skel/.bashrc
echo "skeleton .bashrc removed!"
fi
}
function link_etc {
local filename="$1" subfolder="${2:-}"
local source="$MIAOU_BASH_DIR/etc"
local destination="/etc"
[[ -n "$subfolder" ]] && source+="/${subfolder}" && destination+="/${subfolder}"
if [[ -L "$destination/$filename" ]]; then
if [[ "$(readlink "$destination/$filename")" != "$source/$filename" ]]; then
ln -sf "$source/$filename" "$destination"
echo "link $source/$filename updated"
else
echo "link $source/$filename already enabled!"
fi
else
if [[ -f "$destination/$filename" ]]; then
mv "$destination/$filename" "$destination/$filename.$BACKUP"
echo "$destination/$filename.$BACKUP saved!"
fi
ln -s "$source/$filename" "$destination"
echo "link $source/$filename created"
fi
} }
function predefine_config_files { function predefine_config_files {
for i in "${PREDEFINED_CONFIG_FILES[@]}"; do link_etc bash.bashrc
local miaou_file link_etc inputrc
miaou_file="${MIAOU_BASH_DIR}/etc/$(basename "$i")" link_etc vimrc.azerty vim
if [[ -L "$i" ]]; then link_etc vimrc.core vim
if [[ "$(readlink "$i")" == "${miaou_file}" ]]; then link_etc vimrc.local vim
echo "$i => MIAOU_BASH_DIR already set!" link_etc vimrc.miaou vim
else link_etc vimrc.rookie vim
ln -sf "${miaou_file}" "$i"
echo "$i => MIAOU_BASH_DIR freshly defined."
fi
else
mv "$i" "$i.$ORIGINAL"
ln -s "${miaou_file}" "$i"
echo "$i => MIAOU_BASH_DIR freshly defined + .ORIGINAL backuped"
fi
done
} }
# MAIN # MAIN
[ "$UID" -ne 0 ] && echo 'root privilege required' && exit 1 [ "$UID" -ne 0 ] && echo 'root privilege required' && exit 1
source "$MIAOU_BASH_DIR/lib/functions.bash" source "$MIAOU_BASH_DIR/lib/functions.bash"
required_packages required_packages
no_more_skeleton no_more_skeleton