New script: Monica LXC (#1813)

* New script: Monica LXC

* Update monica.json
This commit is contained in:
bvdberg01 2025-01-28 15:04:52 +01:00 committed by GitHub
parent 31473b2170
commit b70cd00764
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 219 additions and 0 deletions

81
ct/monica.sh Normal file
View File

@ -0,0 +1,81 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: bvdberg01
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.monicahq.com/
# App Default Values
APP="Monica"
var_tags="network"
var_cpu="2"
var_ram="2048"
var_disk="8"
var_os="debian"
var_version="12"
var_unprivileged="1"
# App Output & Base Settings
header_info "$APP"
base_settings
# Core
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/monica ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -s https://api.github.com/repos/monicahq/monica/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
msg_info "Stopping Service"
systemctl stop apache2
msg_ok "Stopped Service"
msg_info "Updating ${APP} to v${RELEASE}"
cd /opt
mv /opt/monica/ /opt/monica-backup
wget -q "https://github.com/monicahq/monica/releases/download/v${RELEASE}/monica-v${RELEASE}.tar.bz2"
tar -xjf "monica-v${RELEASE}.tar.bz2"
mv "/opt/monica-v${RELEASE}" /opt/monica
cd /opt/monica/
cp -r /opt/monica-backup/.env /opt/monica
cp -r /opt/monica-backup/storage/* /opt/monica/storage/
composer install --no-interaction --no-dev &>/dev/null
yarn install &>/dev/null
yarn run production &>/dev/null
php artisan monica:update --force &>/dev/null
chown -R www-data:www-data /opt/monica
chmod -R 775 /opt/monica/storage
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated $APP to v${RELEASE}"
msg_info "Starting Service"
systemctl start apache2
msg_ok "Started Service"
msg_info "Cleaning up"
rm -r "/opt/monica-v${RELEASE}.tar.bz2"
rm -r /opt/monica-backup
msg_ok "Cleaned"
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"

104
install/monica-install.sh Normal file
View File

@ -0,0 +1,104 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: bvdberg01
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
curl \
sudo \
mc \
gnupg2\
mariadb-server \
apache2 \
libapache2-mod-php \
php-{bcmath,curl,dom,gd,gmp,iconv,intl,json,mbstring,mysqli,opcache,pdo-mysql,redis,tokenizer,xml,zip} \
composer
msg_ok "Installed Dependencies"
msg_info "Setting up MariaDB"
DB_NAME=monica
DB_USER=monica
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 WITH mysql_native_password AS PASSWORD('$DB_PASS');"
$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
{
echo "monica-Credentials"
echo "monica Database User: $DB_USER"
echo "monica Database Password: $DB_PASS"
echo "monica Database Name: $DB_NAME"
} >> ~/monica.creds
msg_ok "Set up MariaDB"
msg_info "Setting up Node.js/Yarn"
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
$STD apt-get update
$STD apt-get install -y nodejs
$STD npm install -g npm@latest
$STD npm install -g yarn
msg_ok "Installed Node.js/Yarn"
msg_info "Installing monica"
RELEASE=$(curl -s https://api.github.com/repos/monicahq/monica/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
cd /opt
wget -q "https://github.com/monicahq/monica/releases/download/v${RELEASE}/monica-v${RELEASE}.tar.bz2"
tar -xjf "monica-v${RELEASE}.tar.bz2"
mv "/opt/monica-v${RELEASE}" /opt/monica
cd /opt/monica
cp /opt/monica/.env.example /opt/monica/.env
HASH_SALT=$(openssl rand -base64 32)
sed -i -e "s|^DB_USERNAME=.*|DB_USERNAME=${DB_USER}|" \
-e "s|^DB_PASSWORD=.*|DB_PASSWORD=${DB_PASS}|" \
-e "s|^HASH_SALT=.*|HASH_SALT=${HASH_SALT}|" \
/opt/monica/.env
$STD composer install --no-dev -o --no-interaction
$STD yarn install
$STD yarn run production
$STD php artisan key:generate
$STD php artisan setup:production --email=admin@helper-scripts.com --password=helper-scripts.com --force
chown -R www-data:www-data /opt/monica
chmod -R 775 /opt/monica/storage
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed monica"
msg_info "Creating Service"
cat <<EOF >/etc/apache2/sites-available/monica.conf
<VirtualHost *:80>
ServerName monica
DocumentRoot /opt/monica/public
<Directory /opt/monica/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/monica_error.log
CustomLog /var/log/apache2/monica_access.log combined
</VirtualHost>
EOF
$STD a2ensite monica
$STD a2enmod rewrite
$STD a2dissite 000-default.conf
$STD systemctl reload apache2
msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
rm -rf "/opt/monica-v${RELEASE}.tar.bz2"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"

34
json/monica.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "Monica",
"slug": "monica",
"categories": [
24
],
"date_created": "2025-01-26",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 80,
"documentation": "https://github.com/monicahq/monica/tree/4.x/docs",
"website": "https://www.monicahq.com/",
"logo": "https://www.monicahq.com/img/logo_vertical.png",
"description": "Monica is an open-source personal CRM designed to help you manage and strengthen your relationships. It allows you to store important details about your contacts, track interactions, set reminders for special dates, and log activities—all in one secure, private place. Perfect for busy individuals, Monica helps you stay organized, remember meaningful moments, and nurture your connections without ads or data mining. Install it on your own server for full control!",
"install_methods": [
{
"type": "default",
"script": "ct/monica.sh",
"resources": {
"cpu": 2,
"ram": 2048,
"hdd": 8,
"os": "debian",
"version": "12"
}
}
],
"default_credentials": {
"username": "admin@helper-scripts.com",
"password": "helper-scripts.com"
},
"notes": []
}