diff --git a/apps/cloudron-latest-offirepo b/apps/cloudron-latest-offirepo
index c85c6505..11bc5598 100755
--- a/apps/cloudron-latest-offirepo
+++ b/apps/cloudron-latest-offirepo
@@ -1,30 +1,129 @@
#!/bin/bash
+
if [ -f "include/startup.sh" ]; then
. include/startup.sh
elif [ -f "../include/startup.sh" ]; then
. ../include/startup.sh
fi
-rootDir=$(rootDir)
+updateAndFinalize() {
+ local rootDir="$1"
+ local CWM_DOMAIN="$2"
+
+ # Target directories and files
+ local html_target="/home/yellowtent/box/dashboard/dist/setupdns.html"
+ local js_target_dir="/home/yellowtent/box/dashboard/dist/js"
+ local js_target="${js_target_dir}/setupdns.js"
+
+ # Check every if the directories and files exist
+ while [[ ! -d "/home/yellowtent/box/dashboard/dist" || ! -d "$js_target_dir" ]]; do
+ #echo "Waiting for Cloud-Ron's app directory..."
+ sleep 3
+ done
+
+ # Perform operations once the directories exist
+ echo "Cloud-Ron Directories found. Performing operations..." | log
+
+ # Ensure target files do not exist before copying new ones
+ rm -rf "$html_target"
+ rm -rf "$js_target"
+
+ # Copy new files from source to target locations
+ cp "${rootDir}/tweaks/extras/cloudron/setupdns.html" "$html_target"
+ cp "${rootDir}/tweaks/extras/cloudron/setupdns.js" "$js_target"
+
+ # Replace placeholders in HTML and JS files
+ sed -i "s/CWMDOMAIN/${CWM_DOMAIN}/g" "$html_target"
+ sed -i "s/CWMDOMAIN/${CWM_DOMAIN}/g" "$js_target"
+
+ echo "Setup DNS files have been updated." | log
+
+ # Touchups
+ bash tweaks/motd-description-append
+ bash tweaks/cwm-description-autoconfig
+
+ echo "Adding descriptions" | log
+ descriptionAppend "CloudRon Web UI: https://${CWM_DOMAIN}"
+ descriptionAppend "SSL will be configured after the first step."
+
+ # Cleanup
+ echo "Cleaning up..." | log
+ sleep 5
+ systemctl stop apache2
+ apt-get purge apache2 apache2-utils apache2-bin apache2.2-common
+ rm -rf /etc/apache2
+ apt-get autoremove -y
+ apt-get autoclean -y
+
+ end_time=$(date +%s)
+ duration=$((end_time - start_time))
+ echo "Installation completed in $duration seconds." | log
+
+ tagScript success
+ exit 0
+}
+
+# Define variables
+rootDir="$(rootDir)"
+updateStatus="$rootDir/include/updateInstallStatus.sh"
+LOG_PATH="/var/log/cloudron-setup.log"
+WEB_PATH="/var/www/html"
+HTML_PATH="/var/www/html/index.html"
+
+clear
echo "Downloading and installing CloudRon" | log
curlDownload https://cloudron.io/cloudron-setup
chmod +x cloudron-setup
-bash cloudron-setup
-sleep 5
-rm -rf /home/yellowtent/box/dashboard/dist/setupdns.html
-rm -rf /home/yellowtent/box/dashboard/dist/js/setupdns.html
-cp $rootDir/tweaks/extras/cloudron/setupdns.html /home/yellowtent/box/dashboard/dist/setupdns.html
-cp $rootDir/tweaks/extras/cloudron/setupdns.js /home/yellowtent/box/dashboard/dist/js/setupdns.js
-sed -i "s/CWMDOMAIN/${CWM_DOMAIN}/g" /home/yellowtent/box/dashboard/dist/setupdns.html
-sed -i "s/CWMDOMAIN/${CWM_DOMAIN}/g" /home/yellowtent/box/dashboard/dist/js/setupdns.js
+# Run the Cloudron setup and tee the output to both stdout and the log file
+if [ ! -f "$LOG_PATH" ]; then
+ touch "$LOG_PATH"
+fi
+
+# Wait for App dir and replace files
+echo "Starting listener for Cloud-Ron app dirs & DNS update..." | log
+updateAndFinalize "$rootDir" "${CWM_DOMAIN}" &
+
+echo "Running CloudRon setup..." | log
+start_time=$(date +%s)
+echo Y | bash cloudron-setup | tee "$LOG_PATH" &
+
+# Define lists to hold log messages
+declare -a pre_display_list=()
+declare -A seen # associative array to track seen lines
+
+# Start tailing the log file and process lines as they come
+while read line; do
+ # Locate the line to display
+ if [[ "$line" == *"==> "* ]]; then
+ if [[ "$line" == *"Pulling docker images"* ]]; then
+ line="Pulling docker images (Takes some time)..."
+ else
+ line="${line#*==> }"
+ fi
+
+ # Clean the line from extras
+ line=$(echo "$line" | sed -e 's/installer://g' -e 's/start://g' -e 's/"$//' -e 's/ \+.*//')
-echo "Adding descriptions" | log
-descriptionAppend "CloudRon Web UI: https://${CWM_DOMAIN}"
-descriptionAppend "SSL will be configured after the first step."
+ # Check if the line has been seen already
+ if [[ -z "${seen[$line]}" ]]; then
+ seen[$line]=1
+ pre_display_list+=("$line")
-tagScript success
+ "$updateStatus" "$HTML_PATH" -cp
+ for stage in "${pre_display_list[@]}"; do
+ # Remove all trailing dots first
+ cleaned_stage=$(echo "$stage" | sed 's/\.*$//')
+
+ # Append exactly three dots
+ final_stage="${cleaned_stage}..."
+
+ # Update the installation landing page
+ "$updateStatus" "$HTML_PATH" -ap "${final_stage}"
+ done
+ fi
+ fi
+done < <(tail -f "$LOG_PATH")
-exit 0
diff --git a/apps/redmine-4.2-offisrc-nginx b/apps/redmine-4.2-offisrc-nginx
index e05c15e4..820ec4c4 100755
--- a/apps/redmine-4.2-offisrc-nginx
+++ b/apps/redmine-4.2-offisrc-nginx
@@ -46,7 +46,11 @@ EOF
echo "Installing Bundle" | log
cd $appPath
-gem install bundler --no-document
+gem install nokogiri -v 1.15.6
+gem install net-imap -v 0.3.7
+gem install rails -v 6.1.7.7
+gem install bundler -v 2.4.22
+
bundle install --without development test postgresql sqlite
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
diff --git a/apps/redmine-5.0-offisrc-nginx b/apps/redmine-5.0-offisrc-nginx
index fa26892b..05680e70 100755
--- a/apps/redmine-5.0-offisrc-nginx
+++ b/apps/redmine-5.0-offisrc-nginx
@@ -46,7 +46,12 @@ EOF
echo "Installing Bundle" | log
cd $appPath
-gem install bundler --no-document
+# Components have been updated with time, for the bundler to work, these specific versions are required.
+gem install nokogiri -v 1.15.6
+gem install net-imap -v 0.3.7
+gem install rails -v 6.1.7.7
+gem install bundler -v 2.4.22
+
bundle install --without development test postgresql sqlite
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
diff --git a/apps/redmine-5.1.1-offisrc-apache-rails-mysql-8.0 b/apps/redmine-5.1.1-offisrc-apache-rails-mysql-8.0
new file mode 100644
index 00000000..6b90f9cb
--- /dev/null
+++ b/apps/redmine-5.1.1-offisrc-apache-rails-mysql-8.0
@@ -0,0 +1,142 @@
+#!/bin/bash
+
+# Add this at the begining of all scripts.
+if [ -f "include/startup.sh" ]; then
+ . include/startup.sh
+elif [ -f "../include/startup.sh" ]; then
+ . ../include/startup.sh
+fi
+
+replaceAdPass() {
+ changePassScript="$REPO_DIR/change_admin_password.rb"
+ echo "Writing password change script to $changePassScript..."
+ touch $changePassScript
+ cat <<_EOF_ > $changePassScript
+#!/usr/bin/env ruby
+
+require_relative 'config/environment'
+admin_user = User.where(admin: true).first
+
+if admin_user.nil?
+ puts "Admin user not found!"
+ exit 1
+
+else
+ admin_user.password = ENV['NEW_ADMIN_PASSWORD']
+ admin_user.password_confirmation = ENV['NEW_ADMIN_PASSWORD']
+ admin_user.must_change_passwd = false
+
+ if admin_user.save
+ puts "Password updated successfully."
+
+ else
+ puts "Failed to update password: #{admin_user.errors.full_messages.join(", ")}"
+ exit 1
+ end
+end
+_EOF_
+
+ # Replace default admin password
+ echo "Replacing default admin password..."
+ RAILS_ENV=production NEW_ADMIN_PASSWORD='${ADMINPASSWORD}' rails runner $changePassScript
+
+ echo "Removing $changePassScript..."
+ rm -f $changePassScript
+
+}
+
+# Variables
+DB_REDMINE_PASS="redmine"
+REPO_URL="https://www.redmine.org/releases/redmine-5.1.1.tar.gz"
+REPO_DIR="/opt/redmine"
+WEBAPP_CONF="/etc/apache2/sites-available"
+
+# Update system and install required packages
+apt-get update && apt-get upgrade -y
+apt-get install -y libmysqlclient-dev apt-transport-https
+
+# Secure MySQL and set up Redmine database
+mysql --user=root <<_EOF_
+DELETE FROM mysql.user WHERE User='';
+CREATE DATABASE redmine CHARACTER SET utf8mb4;
+CREATE USER 'redmine'@'localhost' IDENTIFIED BY '${DB_REDMINE_PASS}';
+GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
+FLUSH PRIVILEGES;
+_EOF_
+
+# Install Redmine
+mkdir -p ${REPO_DIR}
+curl -s ${REPO_URL} | sudo tar xz -C ${REPO_DIR} --strip-components=1
+
+# Configuring permissions
+echo "Configuring permissions..."
+chown -R www-data:www-data /opt/redmine/
+
+cd ${REPO_DIR}
+# Configure database connection
+cat <<_EOF_ > ${REPO_DIR}/config/database.yml
+production:
+ adapter: mysql2
+ database: redmine
+ host: localhost
+ username: redmine
+ password: "${DB_REDMINE_PASS}"
+ encoding: utf8mb4
+_EOF_
+
+# Install gems
+gem install bundler
+bundle config set --local without 'development test'
+bundle install
+
+# Prepare the database
+bundle exec rake generate_secret_token
+RAILS_ENV=production bundle exec rake db:migrate
+RAILS_ENV=production REDMINE_LANG=en bundle exec rake redmine:load_default_data
+
+# Install ImageMagic for Redmine
+echo "Installing ImageMagic & ghostscript..."
+apt update
+apt install -y imagemagick libmagickwand-dev
+convert -version
+apt install -y ghostscript
+
+#replaceAdPass
+echo "Writing apache configuration file..."
+cat <<_EOF_ > $WEBAPP_CONF/redmine.conf
+
" > "$appPath/index.html" +$figletApp "Install in Progress" >> "$appPath/index.html" +echo "Please Wait. Application and services installation is in progress, the process will take a couple of minutes to complete. Thank you for your patience." >> "$appPath/index.html" +echo "Installing dependencies..." >> "$appPath/index.html" +echo "" >> "$appPath/index.html" +echo "" >> "$appPath/index.html" + +tagScript success +exit 0 diff --git a/include/updateInstallStatus.sh b/include/updateInstallStatus.sh new file mode 100644 index 00000000..027b2850 --- /dev/null +++ b/include/updateInstallStatus.sh @@ -0,0 +1,189 @@ +#!/bin/bash + +show_help() { + echo "Usage: $0 [html_file] [action] [content]" + echo "Actions:" + echo " -uh, update_heading - Updates the content of the
$line
" "$HTML_FILE" + fi + done <<< "$(echo -e "$CONTENT")" +} + +# Function to replace all paragraphs with new ones +replace_paragraphs() { + sed -i "/.*<\/p>/d; }" "$HTML_FILE" + while IFS= read -r line; do + if [ -n "$line" ]; then + sed -i "/
$line
" "$HTML_FILE" + fi + done <<< "$(echo -e "$CONTENT")" +} + +# Function to clear all paragraphs +clear_paragraphs() { + sed -i "/.*<\/p>/d; }" "$HTML_FILE" +} + +# Function to update the logo image source +update_logo_img() { + sed -i "/
.*<\/p>/d; }" "$HTML_FILE" + # Reverse the order of lines before adding them + while IFS= read -r line; do + lines="$line"$'\n'"$lines" + done <<< "$(echo -e "$CONTENT")" + while IFS= read -r line; do + if [ -n "$line" ]; then + sed -i "/
$line
" "$HTML_FILE" + fi + done <<< "$lines" +} + +# Function to hide the credentials container +hide_credentials() { + sed -i 's|