HEX
Server: nginx/1.18.0
System: Linux proba.drlaca.appboxes.co 6.1.0-28-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.119-1 (2024-11-22) x86_64
User: appbox (1000)
PHP: 7.4.3-4ubuntu2.29
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //etc/my_init.d/30_wordpress.sh
#!/bin/bash
set -x
chmod 777 /var/run/mysqld/
if [ ! -f /etc/wp_installed ]; then
    if [ ! -f /home/appbox/public_html/wp-config.php ]; then
        rm -fr /home/appbox/public_html/index.php

        /usr/sbin/mysqld --defaults-file=/home/appbox/config/mysql/mysqld.cnf --verbose=0 --socket=/run/mysqld/mysqld.sock &
        while !(mysqladmin ping)
        do
           sleep 3
           echo "waiting for mysql ..."
        done

        echo "Installing dependencies"
        apt update
        apt install -y sendmail php-dom php-gd

        # Download WordPress
        curl -L "https://wordpress.org/wordpress-${WP_VERSION}.tar.gz" > /wordpress-${WP_VERSION}.tar.gz && \
        rm -fr /home/appbox/public_html/index.html && \
        tar -xzf /wordpress-${WP_VERSION}.tar.gz -C /home/appbox/public_html --strip-components=1 && \
        rm /wordpress-${WP_VERSION}.tar.gz

        # Download WordPress CLI
        curl -L "https://github.com/wp-cli/wp-cli/releases/download/v${WP_CLI_VERSION}/wp-cli-${WP_CLI_VERSION}.phar" > /usr/bin/wp && \
        chmod +x /usr/bin/wp

        if ! $(wp core is-installed  --allow-root --path='/home/appbox/public_html'); then
           echo "=> WordPress is not configured yet, configuring WordPress ..."

           mv /wp-config.php /home/appbox/public_html/wp-config.php
           chown -R appbox:appbox /home/appbox/public_html

           echo "=> Installing WordPress to ${WP_URL}"
           sed -i "s#WP_URL#${WP_URL}#g" /home/appbox/public_html/wp-config.php
           sed -i "s/MYSQL_USERNAME/root/g" /home/appbox/public_html/wp-config.php
           sed -i "s/MYSQL_PASSWORD/${MYSQL_ROOT_PASSWORD}/g" /home/appbox/public_html/wp-config.php
           wp --allow-root core install --path='/home/appbox/public_html' --url="$WP_URL" --title="$WP_TITLE" --admin_user="$WP_ADMIN_USER" --admin_password="$WP_ADMIN_PASSWORD" --admin_email="$WP_ADMIN_EMAIL"

           rm -fr /home/appbox/config/nginx/sites-enabled/default-site.conf
           mv /wordpress.conf /home/appbox/config/nginx/sites-enabled/wordpress.conf

           chmod -R 777 /home/appbox/public_html/wp-content/uploads
           chmod -R 777 /home/appbox/public_html/wp-content/themes
           chmod -R 777 /home/appbox/public_html/wp-content/plugins

           echo "Finishing Install"
           # Finish Install
           until [[ $(curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST "https://api.cylo.io/v1/apps/installed/${INSTANCE_ID}" | grep '200') ]]
               do
               sleep 5
           done

           touch /etc/wp_installed

           pkill -9 mysqld

        else
           echo "=> WordPress is already configured."
        fi
    else
        echo "This is an update, Wordpress updates should be done from within the app.".
        mv /wordpress.conf /home/appbox/config/nginx/sites-enabled/wordpress.conf
        rm -fr /home/appbox/config/nginx/sites-enabled/default-site.conf
        until [[ $(curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST "https://api.cylo.io/v1/apps/installed/${INSTANCE_ID}" | grep '200') ]]
           do
           sleep 5
        done
    fi
else
    echo "WP is already installed, just start up."
    if [ -f /home/appbox/mysql/run/mysqld.pid ]; then
        rm -f /home/appbox/mysql/run/mysqld.pid
    fi
    if [ -f /var/run/mysqld/mysqld.sock.lock ]; then
        rm -f /var/run/mysqld/mysqld.sock.lock
    fi
fi