Skip to content

Commit b9404ef

Browse files
Kimai / Ghost / ManageMyDamnLife: Switch to MariaDB (#8712)
Co-authored-by: Tobias <[email protected]>
1 parent 304de66 commit b9404ef

File tree

5 files changed

+36
-82
lines changed

5 files changed

+36
-82
lines changed

ct/ghost.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ function update_script() {
2424
check_container_storage
2525
check_container_resources
2626

27-
if ! dpkg-query -W -f='${Status}' mariadb-server 2>/dev/null | grep -q "install ok installed"; then
28-
setup_mysql
29-
fi
3027
NODE_VERSION="22" setup_nodejs
3128

32-
msg_info "Updating ${APP} LXC"
29+
msg_info "Updating Ghost"
3330
if command -v ghost &>/dev/null; then
3431
current_version=$(ghost version | grep 'Ghost-CLI version' | awk '{print $3}')
3532
latest_version=$(npm show ghost-cli version)

ct/kimai.sh

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,21 @@ function update_script() {
2323
header_info
2424
check_container_storage
2525
check_container_resources
26-
if ! command -v lsb_release; then
27-
apt install -y lsb-release
28-
fi
2926
if [[ ! -d /opt/kimai ]]; then
3027
msg_error "No ${APP} Installation Found!"
3128
exit
3229
fi
30+
3331
CURRENT_PHP=$(php -v 2>/dev/null | awk '/^PHP/{print $2}' | cut -d. -f1,2)
3432
if [[ "$CURRENT_PHP" != "8.4" ]]; then
3533
msg_info "Migrating PHP $CURRENT_PHP to 8.4"
36-
$STD curl -fsSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
37-
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
38-
$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'
39-
$STD apt-get update
40-
$STD apt-get remove -y php"${CURRENT_PHP//./}"*
41-
$STD apt-get install -y \
42-
php8.4 composer \
43-
php8.4-{gd,mysql,mbstring,bcmath,xml,curl,zip,intl,fpm} \
44-
libapache2-mod-php8.4
34+
PHP_VERSION="8.4" PHP_MODULE="gd,mysql,mbstring,bcmath,xml,curl,zip,intl,fpm" PHP_APACHE="YES" setup_php
4535
msg_ok "Migrated PHP $CURRENT_PHP to 8.4"
4636
fi
4737

48-
RELEASE=$(curl -fsSL https://api.github.com/repos/kimai/kimai/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
49-
BACKUP_DIR="/opt/kimai_backup"
38+
if check_for_gh_release "Kimai" "kimai/kimai"; then
39+
BACKUP_DIR="/opt/kimai_backup"
5040

51-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
5241
msg_info "Stopping Apache2"
5342
systemctl stop apache2
5443
msg_ok "Stopped Apache2"
@@ -60,24 +49,17 @@ function update_script() {
6049
[ -f /opt/kimai/config/packages/local.yaml ] && cp /opt/kimai/config/packages/local.yaml "$BACKUP_DIR/"
6150
msg_ok "Backup completed"
6251

63-
msg_info "Updating ${APP} to ${RELEASE}"
64-
trap "echo Unable to download release file for version ${RELEASE}; try again later" ERR
65-
set -e
66-
curl -fsSL "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip" -o $(basename "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip")
67-
$STD unzip "${RELEASE}".zip
68-
set +e
69-
trap - ERR
70-
rm -rf /opt/kimai
71-
mv kimai-"${RELEASE}" /opt/kimai
52+
fetch_and_deploy_gh_release "Kimai" "kimai/kimai" "prebuild" "latest" "/opt/kimai" "kimai-release-*.zip"
53+
54+
msg_info "Updating Kimai"
7255
[ -d "$BACKUP_DIR/var" ] && cp -r "$BACKUP_DIR/var" /opt/kimai/
7356
[ -f "$BACKUP_DIR/.env" ] && cp "$BACKUP_DIR/.env" /opt/kimai/
7457
[ -f "$BACKUP_DIR/local.yaml" ] && cp "$BACKUP_DIR/local.yaml" /opt/kimai/config/packages/
7558
rm -rf "$BACKUP_DIR"
7659
cd /opt/kimai
7760
$STD composer install --no-dev --optimize-autoloader
7861
$STD bin/console kimai:update
79-
echo "${RELEASE}" >/opt/${APP}_version.txt
80-
msg_ok "Updated ${APP} to ${RELEASE}"
62+
msg_ok "Updated Kimai"
8163

8264
msg_info "Starting Apache2"
8365
systemctl start apache2
@@ -90,14 +72,7 @@ function update_script() {
9072
chown -R www-data:www-data /opt/*
9173
chmod -R 777 /opt/*
9274
msg_ok "Setup Permissions"
93-
94-
msg_info "Cleaning Up"
95-
rm -rf "${RELEASE}".zip
96-
rm -rf "$BACKUP_DIR"
97-
msg_ok "Cleaned"
98-
msg_ok "Updated Successfully"
99-
else
100-
msg_ok "No update required. ${APP} is already at ${RELEASE}"
75+
msg_ok "Updated Successfully!"
10176
fi
10277
exit
10378
}

install/ghost-install.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ $STD apt-get install -y \
2020
libjemalloc2
2121
msg_ok "Installed Dependencies"
2222

23-
setup_mysql
23+
setup_mariadb
2424

2525
msg_info "Configuring Database"
2626
DB_NAME=ghost
2727
DB_USER=ghostuser
2828
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
29-
$STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
30-
$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
31-
$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
29+
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
30+
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
31+
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
3232
{
3333
echo "Ghost-Credentials"
3434
echo "Ghost Database User: $DB_USER"
3535
echo "Ghost Database Password: $DB_PASS"
3636
echo "Ghost Database Name: $DB_NAME"
3737
} >>~/ghost.creds
38-
msg_ok "Configured MySQL"
38+
msg_ok "Configured MariaDB"
3939

4040
NODE_VERSION="22" setup_nodejs
4141

@@ -60,4 +60,5 @@ customize
6060
msg_info "Cleaning up"
6161
$STD apt-get -y autoremove
6262
$STD apt-get -y autoclean
63+
$STD apt-get -y clean
6364
msg_ok "Cleaned"

install/kimai-install.sh

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,21 @@ $STD apt-get install -y \
1818
apt-transport-https \
1919
apache2 \
2020
git \
21-
expect \
22-
composer \
23-
lsb-release
21+
expect
2422
msg_ok "Installed Dependencies"
2523

26-
setup_mysql
27-
28-
msg_info "Adding PHP8.4 Repository"
29-
$STD curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
30-
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
31-
$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'
32-
$STD apt-get update
33-
msg_ok "Added PHP8.4 Repository"
34-
35-
msg_info "Installing PHP"
36-
$STD apt-get remove -y php8.2*
37-
$STD apt-get install -y \
38-
php8.4 \
39-
php8.4-{gd,mysql,mbstring,bcmath,xml,curl,zip,intl} \
40-
libapache2-mod-php8.4
41-
msg_ok "Installed PHP"
24+
setup_mariadb
25+
PHP_VERSION="8.4" PHP_MODULE="gd,mysql,mbstring,bcmath,xml,curl,zip,intl" PHP_APACHE="YES" setup_php
26+
setup_composer
4227

4328
msg_info "Setting up database"
4429
DB_NAME=kimai_db
4530
DB_USER=kimai
4631
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
47-
MYSQL_VERSION=$(mysql --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
48-
$STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
49-
$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
50-
$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
32+
MYSQL_VERSION=$(mariadb --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
33+
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
34+
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
35+
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
5136
{
5237
echo "Kimai-Credentials"
5338
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
5641
} >>~/kimai.creds
5742
msg_ok "Set up database"
5843

59-
msg_info "Installing Kimai (Patience)"
60-
RELEASE=$(curl -fsSL https://api.github.com/repos/kimai/kimai/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
61-
curl -fsSL "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip" -o "${RELEASE}".zip
62-
$STD unzip "${RELEASE}".zip
63-
mv kimai-"${RELEASE}" /opt/kimai
44+
fetch_and_deploy_gh_release "Kimai" "kimai/kimai" "prebuild" "latest" "/opt/kimai" "kimai-release-*.zip"
45+
46+
msg_info "Installing Kimai"
6447
cd /opt/kimai
6548
echo "export COMPOSER_ALLOW_SUPERUSER=1" >>~/.bashrc
6649
source ~/.bashrc
@@ -92,8 +75,6 @@ admin_lte:
9275
options:
9376
default_avatar: build/apple-touch-icon.png
9477
EOF
95-
96-
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
9778
msg_ok "Installed Kimai"
9879

9980
msg_info "Creating Service"
@@ -130,7 +111,7 @@ motd_ssh
130111
customize
131112

132113
msg_info "Cleaning up"
133-
rm -rf "${RELEASE}".zip
134-
$STD apt-get -y autoremove
135-
$STD apt-get -y autoclean
114+
$STD apt -y autoremove
115+
$STD apt -y autoclean
116+
$STD apt -y clean
136117
msg_ok "Cleaned"

install/managemydamnlife-install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ network_check
1414
update_os
1515

1616
msg_info "Installing dependencies"
17-
$STD apt install --no-install-recommends -y build-essential
17+
$STD apt install -y build-essential
1818
msg_ok "Installed dependencies"
1919

2020
NODE_VERSION="22" setup_nodejs
21-
MYSQL_VERSION="8.0" setup_mysql
21+
setup_mariadb
2222

2323
msg_info "Setting up Database"
2424
DB_NAME="mmdl"
2525
DB_USER="mmdl"
2626
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
27-
$STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
28-
$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED by '$DB_PASS';"
29-
$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
27+
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
28+
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED by '$DB_PASS';"
29+
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
3030
{
3131
echo "Manage My Damn Life Credentials"
3232
echo "Database User: $DB_USER"
@@ -59,7 +59,7 @@ msg_info "Creating Service"
5959
cat <<EOF >/etc/systemd/system/mmdl.service
6060
[Unit]
6161
Description=${APPLICATION} Service
62-
After=network.target mysql.service
62+
After=network.target mariadb.service
6363
6464
[Service]
6565
WorkingDirectory=/opt/mmdl

0 commit comments

Comments
 (0)