diff --git a/.env b/.env deleted file mode 100644 index a1da1b1..0000000 --- a/.env +++ /dev/null @@ -1,26 +0,0 @@ -# Docker -NETWORKNAME=admin_web - -# MySQL -MYSQL_ROOT_PASSWORD=r00tp@ssw0rd -MYSQL_USER=dbuser -MYSQL_PASSWORD=dbp@ssw0rdzztop -MYSQL_DATABASE=nydb - -# GITEA -GITEA_API_URL=https://git.nickyeoman.com/api/v1 -ACCESS_TOKEN=974f3a5e0bdc1de7bb954cb202eba196e7bb513c - -# Joomla -EMAIL=noreply@nickyeoman.com -JOOMLA_USER="Nick Yeoman" -JOOMLA_USERNAME=nick -# Passwords must be 12 characters long (admin-password) -JOOMLA_PASSWORD=RswXWgP74VKrnick - -# SMTP -SMTP_USER=null -SMTP_PASS=null -SMTP_HOST='mailhog' -SMTP_SECURITY='None' -SMTP_PORT=1025 \ No newline at end of file diff --git a/.env.staging b/.env.staging deleted file mode 100644 index a1da1b1..0000000 --- a/.env.staging +++ /dev/null @@ -1,26 +0,0 @@ -# Docker -NETWORKNAME=admin_web - -# MySQL -MYSQL_ROOT_PASSWORD=r00tp@ssw0rd -MYSQL_USER=dbuser -MYSQL_PASSWORD=dbp@ssw0rdzztop -MYSQL_DATABASE=nydb - -# GITEA -GITEA_API_URL=https://git.nickyeoman.com/api/v1 -ACCESS_TOKEN=974f3a5e0bdc1de7bb954cb202eba196e7bb513c - -# Joomla -EMAIL=noreply@nickyeoman.com -JOOMLA_USER="Nick Yeoman" -JOOMLA_USERNAME=nick -# Passwords must be 12 characters long (admin-password) -JOOMLA_PASSWORD=RswXWgP74VKrnick - -# SMTP -SMTP_USER=null -SMTP_PASS=null -SMTP_HOST='mailhog' -SMTP_SECURITY='None' -SMTP_PORT=1025 \ No newline at end of file diff --git a/bin/inc_new_project/git_setup.sh b/bin/inc_new_project/git_setup.sh new file mode 100644 index 0000000..8e712cc --- /dev/null +++ b/bin/inc_new_project/git_setup.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +PROJECTNAME=$(basename "$(pwd)") + +# Remove existing Git repository information +rm -rf .git + +rm README.md +touch README.md +echo "# ${PROJECTNAME}" > README.md +echo "" > README.md +echo "Created a fresh repo for your ${PROJECTNAME} project." >> README.md + +# Initialize a new Git repository +echo -e "\n\e[32mSetup Git Locally\e[0m\n"; +git init +git add . +git commit -m "Initial commit of new project $PROJECTNAME" \ No newline at end of file diff --git a/bin/inc_new_project/remote_git_setup.sh b/bin/inc_new_project/remote_git_setup.sh new file mode 100644 index 0000000..4eaaecd --- /dev/null +++ b/bin/inc_new_project/remote_git_setup.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +PROJECTNAME=$(basename "$(pwd)") + +echo -e "\n\e[32mSetup Git Remotely\e[0m\n"; + +DESC="Repo auto created by Joomla remote git script creator for $PROJECTNAME" + +# Create the repository using Gitea API +RESPONSE=$(curl -s -X POST \ + -H "Authorization: token $ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"name\":\"$PROJECTNAME\",\"private\": true,\"description\": \"$DESC\"}" \ + $GITEA_API_URL/user/repos) + +if [ -z "$RESPONSE" ] || [ "$(echo "$RESPONSE" | jq -r '.id')" = "null" ]; then + echo "Error: Failed to create $PROJECTNAME repository." + exit 1 +fi + +SSH_URL=$(echo "$RESPONSE" | jq -r '.ssh_url') +if [ "$SSH_URL" = "null" ]; then + echo "Error: Failed to retrieve SSH URL for $PROJECTNAME repository." + exit 1 +fi + +# Add new remote repository +git remote add origin "$SSH_URL" +git remote -v + +# Commit existing changes +git push -u origin master \ No newline at end of file diff --git a/bin/joomla_install.sh b/bin/joomla_install.sh new file mode 100644 index 0000000..a0b49e9 --- /dev/null +++ b/bin/joomla_install.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +PROJECTNAME=$(basename "$(pwd)") + +# Are you root? +if [ "$EUID" -ne 0 ]; then + echo -e "\033[0;31mThis script must be run as root.\033[0m" + exit 1 +fi + +################################################################## +# ENV file +################################################################## +# Verify the .env file exists +if [ ! -f ".env" ]; then + echo "Error: The .env file does not exist." + exit 1 +fi + +# Load environment variables from .env file +set -o allexport +source .env +set +o allexport + +################################################################## +# non interactive install +# +# https://docs.joomla.org/J4.x:Joomla_CLI_Installation +################################################################## + +DB_PREFIX=$(LC_CTYPE=C tr -dc '[:alpha:]' < /dev/urandom | head -c 3)_ + +docker-compose exec -u www-data joomla php installation/joomla.php install \ + --site-name=$PROJECTNAME \ + --admin-email=$EMAIL \ + --admin-user="$JOOMLA_USER" \ + --admin-username=$JOOMLA_USERNAME \ + --admin-password=$JOOMLA_PASSWORD \ + --db-type=mysqli \ + --db-host=mariadb-joomla \ + --db-user=$MYSQL_USER \ + --db-pass=$MYSQL_PASSWORD \ + --db-name=$MYSQL_DATABASE \ + --db-prefix=$DB_PREFIX \ + --db-encryption=0 \ No newline at end of file diff --git a/bin/joomla_new_project.sh b/bin/joomla_new_project.sh new file mode 100644 index 0000000..8ec346a --- /dev/null +++ b/bin/joomla_new_project.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +PROJECTNAME=$(basename "$(pwd)") +SETGITEA=true + +# Verify the .env file exists +if [ ! -f ".env" ]; then + echo "Error: The .env file does not exist." + exit 1 +fi + +# Load environment variables from .env file +set -o allexport +source .env +set +o allexport + +# Run Git setup +bash bin/inc_new_project/git_setup.sh + +if [ "$GITEA_API_URL" = "REPLACEME" ]; then + SETGITEA=false +fi + +# Run remote Git setup +if [ "$SETGITEA" = "true" ]; then + bash bin/inc_new_project/remote_git_setup.sh +fi +echo -e "\e[32mAll Done\e[0m"; \ No newline at end of file