2022-08-17 00:42:57 +00:00
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
SETUP__OS() {
|
2022-08-19 02:34:10 +00:00
|
|
|
OS__MAKE_REQUIRED_RESOURCES || return 1
|
2023-06-28 00:30:02 +00:00
|
|
|
[ $CI ] && { STATUS 'detected CI; skipping os setup'; return 0; }
|
|
|
|
GETSUDO
|
2022-08-17 00:42:57 +00:00
|
|
|
|
|
|
|
local OS_NAME=$(OS__GET_OS)
|
2023-06-28 00:30:02 +00:00
|
|
|
[ ! $OS_NAME ] && ABORT
|
2022-08-17 00:42:57 +00:00
|
|
|
|
2022-08-19 02:34:10 +00:00
|
|
|
OS__INSTALL_SOURCE_DEPENDENCIES || return 2
|
|
|
|
OS__INSTALL_MANAGED_DEPENDENCIES || return 3
|
2022-08-17 00:42:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OS__GET_OS() {
|
|
|
|
local OS_NAME=$(lsb_release -is 2>/dev/null | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
|
|
|
[ ! $OS_NAME ] \
|
|
|
|
&& OS_NAME=$(cat /etc/os-release 2>/dev/null | grep '^ID=' | sed 's/^ID=//')
|
|
|
|
|
|
|
|
[ ! $OS_NAME ] \
|
2023-06-28 00:30:02 +00:00
|
|
|
&& WARNING 'failed to detect operating system' \
|
|
|
|
&& OS_NAME=$(echo -e "arch\ndebian\nother" | FZF 'select an operating system') \
|
2022-08-17 00:42:57 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
[[ $OS_NAME =~ ^ubuntu$ ]] && OS_NAME=debian
|
|
|
|
|
2023-11-11 16:34:21 +00:00
|
|
|
[[ $OS_NAME =~ ^[Ee]ndeavour[Oo][Ss]$ ]] && OS_NAME=arch
|
|
|
|
|
|
|
|
echo $OS_NAME
|
2022-08-17 00:42:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
OS__INSTALL_SOURCE_DEPENDENCIES() {
|
|
|
|
case $OS_NAME in
|
2023-11-11 16:34:21 +00:00
|
|
|
arch )
|
2023-11-11 14:40:10 +00:00
|
|
|
command -v yay >/dev/null 2>&1 \
|
2023-11-11 22:22:27 +00:00
|
|
|
|| SCWRYPTS packages/install -- 'https://aur.archlinux.org/yay.git' --local-name 'yay' \
|
2022-08-17 00:42:57 +00:00
|
|
|
;
|
|
|
|
;;
|
|
|
|
debian ) ;;
|
|
|
|
* ) ;;
|
|
|
|
esac
|
|
|
|
|
2023-11-11 14:40:10 +00:00
|
|
|
[ $COMPILE_DMENU ] && [[ $COMPILE_DMENU -eq 1 ]] \
|
2023-11-11 22:22:27 +00:00
|
|
|
&& SCWRYPTS packages/install -- 'https://github.com/tiyn/dmenu' --local-name 'patched-dmenu'
|
2023-11-11 14:41:20 +00:00
|
|
|
|
|
|
|
return 0
|
2022-08-17 00:42:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
OS__INSTALL_MANAGED_DEPENDENCIES() {
|
|
|
|
local ERRORS=0
|
|
|
|
|
2023-06-28 00:30:02 +00:00
|
|
|
STATUS 'checking os dependencies'
|
2022-08-17 00:42:57 +00:00
|
|
|
case $OS_NAME in
|
|
|
|
arch )
|
|
|
|
;;
|
|
|
|
debian ) ;;
|
|
|
|
* )
|
|
|
|
OS_NAME='generic'
|
2023-06-28 00:30:02 +00:00
|
|
|
WARNING "no automated installer available for '$OS_NAME'"
|
2022-08-17 00:42:57 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-11-15 05:48:13 +00:00
|
|
|
[ $MIN ] && [[ $MIN -eq 1 ]] && [ -f "$DOTWRYN_PATH/setup/os-dependencies/$OS_NAME.min.txt" ] \
|
|
|
|
&& DEPENDENCIES="$DOTWRYN_PATH/setup/os-dependencies/$OS_NAME.min.txt" \
|
|
|
|
|| DEPENDENCIES="$DOTWRYN_PATH/setup/os-dependencies/$OS_NAME.txt" \
|
|
|
|
;
|
|
|
|
|
|
|
|
for DEPENDENCY in $(cat "$DEPENDENCIES")
|
2022-08-17 00:42:57 +00:00
|
|
|
do
|
|
|
|
INSTALL_MANAGED__$OS_NAME $DEPENDENCY
|
|
|
|
done
|
|
|
|
|
|
|
|
[[ $ERRORS -ne 0 ]] && {
|
2023-06-28 00:30:02 +00:00
|
|
|
WARNING "detected $ERRORS errors; double check warnings before proceeding!"
|
|
|
|
yN 'continue with install?' && return 0 || ABORT
|
2022-08-17 00:42:57 +00:00
|
|
|
}
|
|
|
|
|
2023-06-28 00:30:02 +00:00
|
|
|
SUCCESS 'all dependencies satisfied'
|
2022-08-17 00:42:57 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
INSTALL_MANAGED__arch() {
|
|
|
|
local TARGET="$1"
|
|
|
|
|
2023-06-28 00:30:02 +00:00
|
|
|
STATUS "checking for $TARGET"
|
2022-08-17 00:42:57 +00:00
|
|
|
|
|
|
|
pacman -Qq | grep -q "^$TARGET$\|^$TARGET-git$" && {
|
2023-06-28 00:30:02 +00:00
|
|
|
SUCCESS "found installation of '$TARGET'"
|
2022-08-17 00:42:57 +00:00
|
|
|
} || {
|
2023-06-28 00:30:02 +00:00
|
|
|
WARNING "'$TARGET' not found"
|
2022-08-17 00:42:57 +00:00
|
|
|
|
2023-06-28 00:30:02 +00:00
|
|
|
STATUS "installing '$TARGET'"
|
2022-08-17 00:42:57 +00:00
|
|
|
sudo pacman -Syu --noconfirm $TARGET \
|
2023-06-28 00:30:02 +00:00
|
|
|
&& SUCCESS "successfully installed '$TARGET'" \
|
|
|
|
|| ERROR "failed to install '$TARGET'"
|
2022-08-17 00:42:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
INSTALL_MANAGED__debian() {
|
2023-06-28 00:30:02 +00:00
|
|
|
STATUS "checking / installing '$1'"
|
2022-08-17 00:42:57 +00:00
|
|
|
sudo apt-get install --yes $1 \
|
2023-06-28 00:30:02 +00:00
|
|
|
&& SUCCESS "'$1' installed" \
|
|
|
|
|| ERROR "failed to install $TARGET" \
|
2022-08-17 00:42:57 +00:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
INSTALL_MANAGED__generic() {
|
|
|
|
command -v $1 >/dev/null 2>&1 \
|
2023-06-28 00:30:02 +00:00
|
|
|
|| ERROR "could not find '$1'; it's up to you to install this one!"
|
2022-08-17 00:42:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
OS__MAKE_REQUIRED_RESOURCES() {
|
|
|
|
local ERRORS=0
|
|
|
|
local DIRECTORIES=(
|
|
|
|
"$HOME/.config/wryn"
|
|
|
|
"$HOME/.local/bin"
|
|
|
|
"$HOME/.vim/bundle"
|
|
|
|
"$HOME/.vim/colors"
|
|
|
|
)
|
|
|
|
|
|
|
|
local FILES=(
|
|
|
|
"$HOME/.vimrc"
|
|
|
|
"$HOME/.zshrc"
|
|
|
|
)
|
|
|
|
|
2023-06-28 00:30:02 +00:00
|
|
|
STATUS 'making required system resources'
|
2022-08-17 00:42:57 +00:00
|
|
|
for D in $DIRECTORIES
|
|
|
|
do
|
2023-06-28 00:30:02 +00:00
|
|
|
[ ! -d $D ] && { mkdir -p $D || ERROR "failed to create directory '$D'"; }
|
2022-08-17 00:42:57 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
for F in $FILES
|
|
|
|
do
|
2023-06-28 00:30:02 +00:00
|
|
|
[ ! -f $F ] && { touch $F || ERROR "failed to create file '$F'"; }
|
2022-08-17 00:42:57 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
[[ $ERRORS -eq 0 ]] \
|
2023-06-28 00:30:02 +00:00
|
|
|
&& SUCCESS 'finished creating system resources' \
|
|
|
|
|| ERROR 'failed to create system resources' \
|
2022-08-17 00:42:57 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
return $ERRORS
|
|
|
|
}
|