From 99a0923998875aaae5b61dbea105aafdbadea3c9 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 14 Jan 2025 18:20:04 +0100 Subject: [PATCH] Create New LXC: Proxmox --- ct/wordpress.sh | 45 +++++++++++++++++++ install/wordpress-install.sh | 85 ++++++++++++++++++++++++++++++++++++ json/wordpress.json | 34 +++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 ct/wordpress.sh create mode 100644 install/wordpress-install.sh create mode 100644 json/wordpress.json diff --git a/ct/wordpress.sh b/ct/wordpress.sh new file mode 100644 index 00000000..8ff69de1 --- /dev/null +++ b/ct/wordpress.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 communtiy-scripts ORG +# Author: MickLesk (Canbiz) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://wordpress.org/ + +## App Default Values +APP="Wordpress" +var_tags="blog;cms" +var_disk="5" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" + +# 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 /var/www/html/wordpress ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_error "Wordpress should be updated via the user interface." + 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}" \ No newline at end of file diff --git a/install/wordpress-install.sh b/install/wordpress-install.sh new file mode 100644 index 00000000..665b105a --- /dev/null +++ b/install/wordpress-install.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 communtiy-scripts ORG +# Author: MickLesk (Canbiz) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://wordpress.org/ + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies (Patience)" +$STD apt-get install -y \ + curl \ + unzip \ + sudo \ + mc \ + apache2 \ + php8.2-{bcmath,common,cli,curl,fpm,gd,snmp,imap,mbstring,mysql,xml,zip} \ + libapache2-mod-php \ + mariadb-server + msg_ok "Installed Dependencies" + +msg_info "Setting up Database" +DB_NAME=wordpress_db +DB_USER=wordpress +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 PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" +{ + echo "WordPress Credentials" + echo "Database User: $DB_USER" + echo "Database Password: $DB_PASS" + echo "Database Name: $DB_NAME" +} >> ~/wordpress.creds +msg_ok "Set up Database" + +msg_info "Installing Wordpress (Patience)" +cd /var/www/html +wget -q https://wordpress.org/latest.zip +unzip -q latest.zip +chown -R www-data:www-data wordpress/ +cd /var/www/html/wordpress +find . -type d -exec chmod 755 {} \; +find . -type f -exec chmod 644 {} \; +mv wp-config-sample.php wp-config.php +sed -i -e "s|^define( 'DB_NAME', '.*' );|define( 'DB_NAME', '$DB_NAME' );|" \ + -e "s|^define( 'DB_USER', '.*' );|define( 'DB_USER', '$DB_USER' );|" \ + -e "s|^define( 'DB_PASSWORD', '.*' );|define( 'DB_PASSWORD', '$DB_PASS' );|" \ + /var/www/html/wordpress/wp-config.php +msg_ok "Installed Wordpress" + +msg_info "Setup Services" +cat < /etc/apache2/sites-available/wordpress.conf + + ServerName yourdomain.com + DocumentRoot /var/www/html/wordpress + + + AllowOverride All + + + ErrorLog \${APACHE_LOG_DIR}/error.log + CustomLog \${APACHE_LOG_DIR}/access.log combined + + +EOF +$STD a2ensite wordpress.conf +$STD a2dissite 000-default.conf +systemctl reload apache2 +msg_ok "Created Services" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf /var/www/html/latest.zip +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" \ No newline at end of file diff --git a/json/wordpress.json b/json/wordpress.json new file mode 100644 index 00000000..b82f0c56 --- /dev/null +++ b/json/wordpress.json @@ -0,0 +1,34 @@ +{ + "name": "Wordpress", + "slug": "wordpress", + "categories": [ + 14 + ], + "date_created": "2025-01-14", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 80, + "documentation": "https://wordpress.org/documentation/", + "website": "https://wordpress.org/", + "logo": "https://s.w.org/style/images/about/WordPress-logotype-simplified.png", + "description": "WordPress is the simplest, most popular way to create your own website or blog. In fact, WordPress powers over 43.6% of all the websites on the Internet. Yes – more than one in four websites that you visit are likely powered by WordPress.\n\nOn a slightly more technical level, WordPress is an open-source content management system licensed under GPLv2, which means that anyone can use or modify the WordPress software for free.", + "install_methods": [ + { + "type": "default", + "script": "ct/wordpress.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 5, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} \ No newline at end of file