lxc-forgejo: Replace 'whiptail' for database selection with 'select'

This commit is contained in:
barremian 2024-05-28 23:54:55 +02:00
parent 310cc3ebe6
commit 6b222b9ab8
No known key found for this signature in database
GPG key ID: 96E431287CDD3E4A

View file

@ -41,20 +41,19 @@ echo -e "Forgejo data directory: \e[32m/var/lib/forgejo\e[0m" >>~/forgejo.creds
msg_info "Setup Forgejo"
msg_info "Setting up database"
DB_NAME=forgejodb
DB_USER=forgejo
DB_PASS="$(openssl rand -base64 18 | cut -c1-13)"
DB_CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DATABASE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \
"1" "SQLite" ON \
"2" "PostgreSQL " OFF \
"3" "MySQL" OFF \
"4" "MariaDB" OFF \
--separate-output \
3>&1 1>&2 2>&3)
if [ "$DB_CHOICE" == "1" ]; then
msg_info "SQLite will be setup automatically by Forgejo."
fi
if [ "$DB_CHOICE" == "2" ]; then
read -r -p "Forgejo uses SQLite by default. Would you like to use another database? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
PS3="Please enter your choice: "
files="$(ls -A .)"
select DB_CHOICE in "PostgreSQL" "MySQL" "MariaDB"; do
msg_ok "You selected ${BL}${DB_CHOICE}${CL}"
break
done
DB_NAME=forgejodb
DB_USER=forgejo
DB_PASS="$(openssl rand -base64 18 | cut -c1-13)"
if [ "$DB_CHOICE" == "PostgreSQL" ]; then
msg_info "Setting up PostgreSQL"
$STD apt-get install -y postgresql
echo "" >>~/forgejo.creds
@ -79,8 +78,8 @@ EOL
$STD systemctl restart postgresql
msg_info "Restarted PostgreSQL"
msg_info "Setup PostgreSQL"
fi
if [ "$DB_CHOICE" == "3" ]; then
fi
if [ "$DB_CHOICE" == "MySQL" ]; then
msg_info "Setting up MySQL"
$STD apt-get install -y mysql-server
ADMIN_PASS="$(openssl rand -base64 18 | cut -c1-13)"
@ -96,8 +95,8 @@ if [ "$DB_CHOICE" == "3" ]; then
$STD systemctl restart mysql
msg_info "Restarted MySQL"
msg_info "Setup MySQL"
fi
if [ "$DB_CHOICE" == "4" ]; then
fi
if [ "$DB_CHOICE" == "MariaDB" ]; then
msg_info "Setting up MariaDB"
$STD apt-get install -y mariadb-server
ADMIN_PASS="$(openssl rand -base64 18 | cut -c1-13)"
@ -113,6 +112,9 @@ if [ "$DB_CHOICE" == "4" ]; then
$STD systemctl restart mariadb
msg_info "Restarted MariaDB"
msg_info "Setup MariaDB"
fi
else
msg_ok "${BL}SQLite${CL} will be used"
fi
read -r -p "Would you like to add Adminer? <y/N> " prompt