mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-13 18:44:29 +05:00
Better dependency check
This commit is contained in:
7
kiauh.sh
7
kiauh.sh
@@ -27,9 +27,6 @@ get_date(){
|
|||||||
current_date=`date +"%Y-%m-%d_%H%M%S"`
|
current_date=`date +"%Y-%m-%d_%H%M%S"`
|
||||||
}
|
}
|
||||||
|
|
||||||
### sourcing all additional scripts
|
|
||||||
for script in ${HOME}/kiauh/scripts/*; do . $script; done
|
|
||||||
|
|
||||||
### set important directories
|
### set important directories
|
||||||
#klipper
|
#klipper
|
||||||
KLIPPER_DIR=${HOME}/klipper
|
KLIPPER_DIR=${HOME}/klipper
|
||||||
@@ -432,5 +429,9 @@ backup_menu(){
|
|||||||
backup_menu
|
backup_menu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### sourcing all additional scripts
|
||||||
|
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
|
||||||
|
for script in ${SRCDIR}/kiauh/scripts/*; do . $script; done
|
||||||
|
|
||||||
check_euid
|
check_euid
|
||||||
main_menu
|
main_menu
|
||||||
@@ -3,9 +3,9 @@ check_euid(){
|
|||||||
if [ "$EUID" -eq 0 ]
|
if [ "$EUID" -eq 0 ]
|
||||||
then
|
then
|
||||||
echo -e "${red}"
|
echo -e "${red}"
|
||||||
echo -e "/=================================================\ "
|
top_border
|
||||||
echo -e "| !!! THIS SCRIPT MUST NOT RAN AS ROOT !!! |"
|
echo -e "| !!! THIS SCRIPT MUST NOT RAN AS ROOT !!! |"
|
||||||
echo -e "\=================================================/ "
|
bottom_border
|
||||||
echo -e "${default}"
|
echo -e "${default}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -85,24 +85,29 @@ restart_nginx(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
dep_check(){
|
dependency_check(){
|
||||||
for package in "${dep[@]}"
|
status_msg "Checking for dependencies ..."
|
||||||
|
#check if package is installed, if not write name into array
|
||||||
|
for pkg in "${dep[@]}"
|
||||||
do
|
do
|
||||||
! command -v $package >&/dev/null 2>&1 && install+=($package)
|
if [[ ! $(dpkg-query -f'${Status}' --show $pkg 2>/dev/null) = *\ installed ]]; then
|
||||||
done
|
inst+=($pkg)
|
||||||
if ! [ ${#install[@]} -eq 0 ]; then
|
fi
|
||||||
warn_msg "The following packages are missing but necessary:"
|
|
||||||
echo ${install[@]}
|
|
||||||
while true; do
|
|
||||||
read -p "Do you want to install them now? (Y/n): " yn
|
|
||||||
case "$yn" in
|
|
||||||
Y|y|Yes|yes|"")
|
|
||||||
status_msg "Installing dependencies ..."
|
|
||||||
sudo apt-get install ${install[@]} -y && ok_msg "Dependencies installed!"
|
|
||||||
break;;
|
|
||||||
N|n|No|no) break;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
#if array is not empty, install packages from array elements
|
||||||
|
if [ "${#inst[@]}" != "0" ]; then
|
||||||
|
status_msg "Installing the following dependencies:"
|
||||||
|
for element in ${inst[@]}
|
||||||
|
do
|
||||||
|
echo -e "${cyan}● $element ${default}"
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
sudo apt-get install ${inst[@]} -y
|
||||||
|
ok_msg "Dependencies installed!"
|
||||||
|
#clearing the array
|
||||||
|
unset inst
|
||||||
|
else
|
||||||
|
ok_msg "Dependencies already met! Continue..."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
octoprint_install_routine(){
|
octoprint_install_routine(){
|
||||||
#experimental new dependency check
|
octoprint_dependencies
|
||||||
octoprint_dependencies
|
|
||||||
#execute operations
|
|
||||||
install_octoprint
|
install_octoprint
|
||||||
add_groups
|
add_groups
|
||||||
configure_autostart
|
configure_autostart
|
||||||
@@ -11,29 +9,17 @@ octoprint_install_routine(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
octoprint_dependencies(){
|
octoprint_dependencies(){
|
||||||
octo_dep=(
|
dep=(
|
||||||
|
git
|
||||||
|
wget
|
||||||
python-pip
|
python-pip
|
||||||
python-dev
|
python-dev
|
||||||
python-setuptools
|
|
||||||
python-virtualenv
|
|
||||||
git
|
|
||||||
libyaml-dev
|
libyaml-dev
|
||||||
build-essential
|
build-essential
|
||||||
wget
|
python-setuptools
|
||||||
)
|
python-virtualenv
|
||||||
status_msg "Checking for dependencies ..."
|
)
|
||||||
for octo_dep_pgk in "${octo_dep[@]}"
|
dependency_check
|
||||||
do
|
|
||||||
if [[ ! $(dpkg-query -f'${Status}' --show $octo_dep_pgk 2>/dev/null) = *\ installed ]]; then
|
|
||||||
install+=($octo_dep_pgk)
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if ! [ ${#install[@]} -eq 0 ]; then
|
|
||||||
status_msg "Installing dependencies ..."
|
|
||||||
sudo apt-get install ${install[@]} -y && ok_msg "Dependencies installed!"
|
|
||||||
else
|
|
||||||
ok_msg "All dependencies already met!"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_octoprint(){
|
install_octoprint(){
|
||||||
@@ -56,14 +42,13 @@ install_octoprint(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
add_groups(){
|
add_groups(){
|
||||||
USER=$(whoami)
|
if [ ! "$(groups | grep tty)" ]; then
|
||||||
if [[ ! $(groups | grep tty) ]]; then
|
status_msg "Adding user '${USER}' to group 'tty' ..."
|
||||||
status_msg "Adding user '$USER' to group 'tty' ..."
|
sudo usermod -a -G tty ${USER} && ok_msg "Done!"
|
||||||
sudo usermod -a -G tty $USER && ok_msg "Done!"
|
|
||||||
fi
|
fi
|
||||||
if [[ ! $(groups | grep tty) ]]; then
|
if [ ! "$(groups | grep dialout)" ]; then
|
||||||
status_msg "Adding user '$USER' to group 'dialout' ..."
|
status_msg "Adding user '${USER}' to group 'dialout' ..."
|
||||||
sudo usermod -a -G dialout $USER && ok_msg "Done!"
|
sudo usermod -a -G dialout ${USER} && ok_msg "Done!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user