mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-11-03 18:02:50 +00:00
Kimai / Ghost / ManageMyDamnLife: Switch to MariaDB
This commit is contained in:
@@ -24,12 +24,9 @@ function update_script() {
|
||||
check_container_storage
|
||||
check_container_resources
|
||||
|
||||
if ! dpkg-query -W -f='${Status}' mariadb-server 2>/dev/null | grep -q "install ok installed"; then
|
||||
setup_mysql
|
||||
fi
|
||||
NODE_VERSION="22" setup_nodejs
|
||||
|
||||
msg_info "Updating ${APP} LXC"
|
||||
msg_info "Updating Ghost"
|
||||
if command -v ghost &>/dev/null; then
|
||||
current_version=$(ghost version | grep 'Ghost-CLI version' | awk '{print $3}')
|
||||
latest_version=$(npm show ghost-cli version)
|
||||
|
||||
43
ct/kimai.sh
43
ct/kimai.sh
@@ -23,32 +23,21 @@ function update_script() {
|
||||
header_info
|
||||
check_container_storage
|
||||
check_container_resources
|
||||
if ! command -v lsb_release; then
|
||||
apt install -y lsb-release
|
||||
fi
|
||||
if [[ ! -d /opt/kimai ]]; then
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
|
||||
CURRENT_PHP=$(php -v 2>/dev/null | awk '/^PHP/{print $2}' | cut -d. -f1,2)
|
||||
if [[ "$CURRENT_PHP" != "8.4" ]]; then
|
||||
msg_info "Migrating PHP $CURRENT_PHP to 8.4"
|
||||
$STD curl -fsSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
|
||||
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
|
||||
$STD sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
|
||||
$STD apt-get update
|
||||
$STD apt-get remove -y php"${CURRENT_PHP//./}"*
|
||||
$STD apt-get install -y \
|
||||
php8.4 composer \
|
||||
php8.4-{gd,mysql,mbstring,bcmath,xml,curl,zip,intl,fpm} \
|
||||
libapache2-mod-php8.4
|
||||
PHP_VERSION="8.4" PHP_MODULE="gd,mysql,mbstring,bcmath,xml,curl,zip,intl,fpm" PHP_APACHE="YES" setup_php
|
||||
msg_ok "Migrated PHP $CURRENT_PHP to 8.4"
|
||||
fi
|
||||
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/kimai/kimai/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||
BACKUP_DIR="/opt/kimai_backup"
|
||||
if check_for_gh_release "Kimai" "kimai/kimai"; then
|
||||
BACKUP_DIR="/opt/kimai_backup"
|
||||
|
||||
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
||||
msg_info "Stopping Apache2"
|
||||
systemctl stop apache2
|
||||
msg_ok "Stopped Apache2"
|
||||
@@ -60,15 +49,9 @@ function update_script() {
|
||||
[ -f /opt/kimai/config/packages/local.yaml ] && cp /opt/kimai/config/packages/local.yaml "$BACKUP_DIR/"
|
||||
msg_ok "Backup completed"
|
||||
|
||||
msg_info "Updating ${APP} to ${RELEASE}"
|
||||
trap "echo Unable to download release file for version ${RELEASE}; try again later" ERR
|
||||
set -e
|
||||
curl -fsSL "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip" -o $(basename "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip")
|
||||
$STD unzip "${RELEASE}".zip
|
||||
set +e
|
||||
trap - ERR
|
||||
rm -rf /opt/kimai
|
||||
mv kimai-"${RELEASE}" /opt/kimai
|
||||
fetch_and_deploy_gh_release "Kimai" "kimai/kimai" "prebuild" "latest" "/opt/kimai" "kimai-release-*.zip"
|
||||
|
||||
msg_info "Updating Kimai"
|
||||
[ -d "$BACKUP_DIR/var" ] && cp -r "$BACKUP_DIR/var" /opt/kimai/
|
||||
[ -f "$BACKUP_DIR/.env" ] && cp "$BACKUP_DIR/.env" /opt/kimai/
|
||||
[ -f "$BACKUP_DIR/local.yaml" ] && cp "$BACKUP_DIR/local.yaml" /opt/kimai/config/packages/
|
||||
@@ -76,8 +59,7 @@ function update_script() {
|
||||
cd /opt/kimai
|
||||
$STD composer install --no-dev --optimize-autoloader
|
||||
$STD bin/console kimai:update
|
||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||
msg_ok "Updated ${APP} to ${RELEASE}"
|
||||
msg_ok "Updated Kimai"
|
||||
|
||||
msg_info "Starting Apache2"
|
||||
systemctl start apache2
|
||||
@@ -90,14 +72,7 @@ function update_script() {
|
||||
chown -R www-data:www-data /opt/*
|
||||
chmod -R 777 /opt/*
|
||||
msg_ok "Setup Permissions"
|
||||
|
||||
msg_info "Cleaning Up"
|
||||
rm -rf "${RELEASE}".zip
|
||||
rm -rf "$BACKUP_DIR"
|
||||
msg_ok "Cleaned"
|
||||
msg_ok "Updated Successfully"
|
||||
else
|
||||
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||
msg_ok "Updated Successfully!"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
@@ -20,22 +20,22 @@ $STD apt-get install -y \
|
||||
libjemalloc2
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
setup_mysql
|
||||
setup_mariadb
|
||||
|
||||
msg_info "Configuring Database"
|
||||
DB_NAME=ghost
|
||||
DB_USER=ghostuser
|
||||
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
||||
$STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
|
||||
$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
|
||||
$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
|
||||
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
|
||||
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
|
||||
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
|
||||
{
|
||||
echo "Ghost-Credentials"
|
||||
echo "Ghost Database User: $DB_USER"
|
||||
echo "Ghost Database Password: $DB_PASS"
|
||||
echo "Ghost Database Name: $DB_NAME"
|
||||
} >>~/ghost.creds
|
||||
msg_ok "Configured MySQL"
|
||||
msg_ok "Configured MariaDB"
|
||||
|
||||
NODE_VERSION="22" setup_nodejs
|
||||
|
||||
|
||||
@@ -18,36 +18,21 @@ $STD apt-get install -y \
|
||||
apt-transport-https \
|
||||
apache2 \
|
||||
git \
|
||||
expect \
|
||||
composer \
|
||||
lsb-release
|
||||
expect
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
setup_mysql
|
||||
|
||||
msg_info "Adding PHP8.4 Repository"
|
||||
$STD curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
|
||||
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
|
||||
$STD sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
|
||||
$STD apt-get update
|
||||
msg_ok "Added PHP8.4 Repository"
|
||||
|
||||
msg_info "Installing PHP"
|
||||
$STD apt-get remove -y php8.2*
|
||||
$STD apt-get install -y \
|
||||
php8.4 \
|
||||
php8.4-{gd,mysql,mbstring,bcmath,xml,curl,zip,intl} \
|
||||
libapache2-mod-php8.4
|
||||
msg_ok "Installed PHP"
|
||||
setup_mariadb
|
||||
PHP_VERSION="8.4" PHP_MODULE="gd,mysql,mbstring,bcmath,xml,curl,zip,intl" PHP_APACHE="YES" setup_php
|
||||
setup_composer
|
||||
|
||||
msg_info "Setting up database"
|
||||
DB_NAME=kimai_db
|
||||
DB_USER=kimai
|
||||
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
||||
MYSQL_VERSION=$(mysql --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
$STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
|
||||
$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
|
||||
$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
|
||||
MYSQL_VERSION=$(mariadb --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
|
||||
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
|
||||
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
|
||||
{
|
||||
echo "Kimai-Credentials"
|
||||
echo "Kimai Database User: $DB_USER"
|
||||
@@ -56,11 +41,9 @@ $STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH
|
||||
} >>~/kimai.creds
|
||||
msg_ok "Set up database"
|
||||
|
||||
msg_info "Installing Kimai (Patience)"
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/kimai/kimai/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||
curl -fsSL "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip" -o "${RELEASE}".zip
|
||||
$STD unzip "${RELEASE}".zip
|
||||
mv kimai-"${RELEASE}" /opt/kimai
|
||||
fetch_and_deploy_gh_release "Kimai" "kimai/kimai" "prebuild" "latest" "/opt/kimai" "kimai-release-*.zip"
|
||||
|
||||
msg_info "Installing Kimai"
|
||||
cd /opt/kimai
|
||||
echo "export COMPOSER_ALLOW_SUPERUSER=1" >>~/.bashrc
|
||||
source ~/.bashrc
|
||||
@@ -92,8 +75,6 @@ admin_lte:
|
||||
options:
|
||||
default_avatar: build/apple-touch-icon.png
|
||||
EOF
|
||||
|
||||
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
|
||||
msg_ok "Installed Kimai"
|
||||
|
||||
msg_info "Creating Service"
|
||||
@@ -130,7 +111,6 @@ motd_ssh
|
||||
customize
|
||||
|
||||
msg_info "Cleaning up"
|
||||
rm -rf "${RELEASE}".zip
|
||||
$STD apt-get -y autoremove
|
||||
$STD apt-get -y autoclean
|
||||
$STD apt -y autoremove
|
||||
$STD apt -y autoclean
|
||||
msg_ok "Cleaned"
|
||||
|
||||
@@ -14,19 +14,19 @@ network_check
|
||||
update_os
|
||||
|
||||
msg_info "Installing dependencies"
|
||||
$STD apt install --no-install-recommends -y build-essential
|
||||
$STD apt install -y build-essential
|
||||
msg_ok "Installed dependencies"
|
||||
|
||||
NODE_VERSION="22" setup_nodejs
|
||||
MYSQL_VERSION="8.0" setup_mysql
|
||||
setup_mariadb
|
||||
|
||||
msg_info "Setting up Database"
|
||||
DB_NAME="mmdl"
|
||||
DB_USER="mmdl"
|
||||
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
||||
$STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
|
||||
$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED by '$DB_PASS';"
|
||||
$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
|
||||
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
|
||||
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED by '$DB_PASS';"
|
||||
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
|
||||
{
|
||||
echo "Manage My Damn Life Credentials"
|
||||
echo "Database User: $DB_USER"
|
||||
@@ -59,7 +59,7 @@ msg_info "Creating Service"
|
||||
cat <<EOF >/etc/systemd/system/mmdl.service
|
||||
[Unit]
|
||||
Description=${APPLICATION} Service
|
||||
After=network.target mysql.service
|
||||
After=network.target mariadb.service
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/opt/mmdl
|
||||
|
||||
Reference in New Issue
Block a user