Add install script for dbeaver
This commit is contained in:
parent
851742c132
commit
1b645da067
74
devleops/dbeaver/dbeaver-install.sh
Executable file
74
devleops/dbeaver/dbeaver-install.sh
Executable file
@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
#### Variables
|
||||
APT_UPDATE="apt -y update"
|
||||
APT_INST="apt -y install"
|
||||
APT_PURGE="apt -y purge"
|
||||
APT_REMOVE="apt -y autoremove"
|
||||
|
||||
PKG_NAME="dbeaver-ce"
|
||||
|
||||
PKG_DEPS=(default-jdk)
|
||||
|
||||
#### Functions
|
||||
check_root() {
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Must be root to run $0"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
choice() {
|
||||
echo -ne "[y/n]"
|
||||
while true
|
||||
do
|
||||
read -rN1 input
|
||||
case $input in
|
||||
[yY][eE][sS]|[yY])
|
||||
return 0
|
||||
|
||||
break
|
||||
;;
|
||||
[nN][oO]|[nN])
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
check_deps() {
|
||||
for NAME in "${PKG_DEPS[@]}"
|
||||
do
|
||||
dpkg -l $NAME > /dev/null
|
||||
CODE=$?
|
||||
if ! [ "$CODE" -ne 1 ]; then
|
||||
echo -ne "\nInstall $NAME ? "
|
||||
if choice 2>/dev/null; then
|
||||
echo -ne "\n$APT_INST $NAME\n"
|
||||
$APT_INST $NAME
|
||||
else
|
||||
echo -ne "\n\nAbort install script, package $NAME is required for work $PKG_NAME.\n"
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#### Main
|
||||
|
||||
check_root
|
||||
check_deps
|
||||
|
||||
echo -ne "\nYou want to install dbeaver-ce ($PKG_NAME)? "
|
||||
if choice 2>/dev/null; then
|
||||
echo -ne "\nAdd repository for dbeaver-ce\n"
|
||||
$APT_INST apt-transport-https wget
|
||||
wget -O /usr/share/keyrings/dbeaver.gpg.key https://dbeaver.io/debs/dbeaver.gpg.key
|
||||
echo "deb [signed-by=/usr/share/keyrings/dbeaver.gpg.key] https://dbeaver.io/debs/dbeaver-ce /" | tee /etc/apt/sources.list.d/dbeaver.list
|
||||
|
||||
echo -e "\nUpdate apt"
|
||||
$APT_UPDATE
|
||||
echo -ne "\n$APT_INST $PKG_NAME\n"
|
||||
$APT_INST $PKG_NAME
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user