Skip to content

Commit

Permalink
🔀 MERGE: Features and Fixes for version 0.0.4 (#70)
Browse files Browse the repository at this point in the history
* 📖 DOC: #58 Readme: Revamp and add TOC

* 🐛 FIX: #45

* 🤖 TEST: phpmyadmin

* 🐛 FIX: #45

* 🐛 FIX: path

* 🐛 FIX: typo in path

* 🐛 FIX: #45

* 🐛 FIX: remove quotes in sed for phpmyadmin

* 🤖 TEST: special chars

* 🤖 TEST: restore test back to dynamic state

* 🐛 FIX: phpmyadmin config

* 🐛 FIX: @ breaks things when generated string starts with one

* 🐛 FIX: create phpmyadmin db

* 🐛 FIX: spinner

* 🐛 FIX: #45

* 🐛 FIX: credentials

* 🐛 FIX: go back to cp of config.sample.inc.php

* 🤖 TEST: rsync progress

* 👌 IMPROVE: #62

* 🐛 FIX: tweak rsync progress

* 🐛 FIX: tweak rsync progress

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: rsync stats, restored spinner for speed

* 🐛 FIX: use native rsync progress option

* 🐛 FIX: colorized rsync stats

* 🐛 FIX: log messages

* 👌 IMPROVE: remove auth, edit comments

* 👌 IMPROVE: Installtion information API for #61

* 📖 DOC: comments

* 🤖 TEST: call yarn installs less

* 🤖 TEST: call yarn installs less

* 🐛 FIX: refactor to save calls to yarn install

* 🐛 FIX: refactor to save calls to yarn install

* 🤖 TEST: refactor to save calls to yarn install

* 🐛 FIX: load spinner

* 🐛 FIX: error mix not found

* 🐛 FIX: tweak order

* 🐛 FIX: line 130: printf: --: invalid option

* 🐛 FIX: line 130: printf: --: invalid option

* 🐛 FIX: tweaks

* 🤖 TEST: fix npm error

* 🤖 TEST: error in npm when install react scaffolding

* 🤖 TEST: with no yarn run dev after node modules are installed

* 🤖 TEST: installs

* 🐛 FIX: tweaks for less npm installs can rless running of laravel mix

* 🤖 TEST: tweaks for installs

* 🐛 FIX: install info API, bad regexp

* 🐛 FIX: new logic for installs

* 🐛 FIX: run_laraval_mix_twice

* 🐛 FIX: run_laravel_mix twice in the wrong spot

* 🤖 TEST: run larvel mix twice

* 🤖 TEST: run larvel mix twice

* 🐛 FIX: fresh start on getting out of this hole

* 🤖 TEST: vue install

* 🤖 TEST: adding in laravel mix run when installing laravel/ui

* 🤖 TEST: adding in laravel mix run when installing laravel/ui, remove extraneous condition

* 🤖 TEST: no npm install after install of larvel/ui

* 🤖 TEST: remove inistal npm install

* 🤖 TEST: remove inistal npm install

* 🤖 TEST: remove inistal npm install

* 🤖 TEST: react install

* 🤖 TEST: no front end scaffolding installs, still install node modules

* 🐛 FIX: typo

* 🤖 TEST: no front end scaffolding installs

* 🐛 FIX: conditional

* 📖 DOC: comments

* 🐛 FIX: make successes a silent log

* 🐛 FIX: install conditions, ready to test

* 📖 DOC: fixed and tested one-liners for project creation

* 🐛 FIX: typo in condition

* 🐛 FIX: install node modules blindly to avoid frontend scaffolding overwrite

* 🐛 FIX: remove uneccessary  function

* 🐛 FIX: phpmyadmin install

* 🐛 FIX: path to public/phpmyadmin/config.inc.php

* 👌 IMPROVE: enhanced phpmyadmin setup logic

* 👌 IMPROVE: #64 Support .starter.env for sensitive data like phpmyadmin credentials

* 🐛 FIX: refactor #64, works good

* 🐛 FIX: rename and fix

* 🐛 FIX: path

* 🐛 FIX: file name

* 📖 DOC: #66 Add phpMyAdmin section to README.md

* 👌 IMPROVE: no trailing newline for .txt files

* 👌 IMPROVE: #65 Add log message to summary

* 📖 DOC: improve message

* 📖 DOC: improve message

* 🐛 FIX: #67 'before' tasks should be logged to file but not to the console

* 👌 IMPROVE: log messages

* 👌 IMPROVE: #68 Add help alias

* 👌 IMPROVE: success messages are logged silently

* 👌 IMPROVE: add silent log

* 🐛 FIX: log messages

* 🐛 FIX: logs and comments

* 🐛 FIX: #63

* 🐛 FIX: #41 Rename test-app to laravel8-starter

* 🤖 TEST: force workspace image build

* 🐛 FIX: rsync path

* 🐛 FIX: log message

* 🐛 FIX: message

* 🐛 FIX: message

* 🐛 FIX: message

* 👌 IMPROVE: #39 Expand Gitlog with additional emoji and git aliases

* 🐛 FIX: #39 change add to ad, add noadd aliases

* 📖 DOC: update as per #39

* 🐛 FIX: summary message

* 🐛 FIX: messaging

* 🐛 FIX: #69

* 🐛 FIX: fine tune, logic and logs

* 🐛 FIX: wording

* 🐛 FIX: edit log message

* 🐛 FIX: alias: add changed to ad

* 🐛 FIX: log silent on env injection success

* 🐛 FIX: log msg

* 🤖 TEST: fix broken web preview spinner

* 🤖 TEST: fix for hung preview

* 👌 IMPROVE: hung preview fix

* 🤖 TEST: preview browser fix

* 🤖 TEST: phpmyadmin install=0

* ♻️ REFACTOR: preview browser

* 👌 IMPROVE: preview browser message

* 🐛 FIX: removed preview browser open msg since #19 is a gitpod internal bug

* 🤖 TEST: barebones install

* 🤖 TEST: changelog generator

* 🤖 TEST: force workspace image build

* 🤖 TEST: changelog generator

* ⚰️ REMOVE: workaround code for #46

* 🤖 TEST: force workspace image build

* 🐛 FIX: init scripts should not depend on eachothers success

* 🤖 TEST: force workspace image build

* 📖 DOC: edit and enhance README

* 🐛 FIX: removed ... from log messages
  • Loading branch information
apolopena authored Mar 24, 2021
1 parent d7d54b2 commit 0290664
Show file tree
Hide file tree
Showing 21 changed files with 936 additions and 262 deletions.
3 changes: 0 additions & 3 deletions .example.starter.env

This file was deleted.

18 changes: 4 additions & 14 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,11 @@ RUN sudo touch /var/log/workspace-init.log \

RUN sudo touch /var/log/xdebug.log \
&& sudo chmod 666 /var/log/xdebug.log

RUN sudo mkdir /var/log/apache2 \
&& sudo chmod 755 /var/log/apache2

RUN sudo touch /var/log/apache2/access.log \
&& sudo chmod 666 /var/log/apache2/access.log

RUN sudo touch /var/log/apache2/error.log \
&& sudo chmod 666 /var/log/apache2/error.log

RUN sudo touch /var/log/apache2/other_vhosts_access.log \
&& sudo chmod 666 /var/log/apache2/other_vhosts_access.log

RUN sudo apt-get update -q \
&& sudo apt-get install -y rsync \
&& sudo apt-get install -y grc
&& sudo apt-get install -y grc \
&& sudo apt-get install -y progress

RUN wget http://xdebug.org/files/xdebug-3.0.2.tgz \
&& tar -xvzf xdebug-3.0.2.tgz \
Expand All @@ -42,8 +31,9 @@ RUN sudo bash -c ". /tmp/update-composer.sh" && rm /tmp/update-composer.sh

# gitpod trick to bypass the docker caching mechanism for all lines below this one
# just increment the value each time you want to bypass the cache system
ENV INVALIDATE_CACHE=125
ENV INVALIDATE_CACHE=130

COPY --chown=gitpod:gitpod bash/.bash_aliases /home/gitpod
COPY --chown=gitpod:gitpod bash/utils.sh /tmp
COPY --chown=gitpod:gitpod starter.ini /tmp
COPY --chown=gitpod:gitpod bash/scaffold-project.sh /tmp
Expand Down
14 changes: 8 additions & 6 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ ports:
tasks:
- before: bash bash/before-tasks.sh
init: |
bash bash/init-gitpod.sh &&
bash bash/init-optional-scaffolding.sh &&
bash bash/init-project.sh &&
bash bash/init-gitpod.sh
bash bash/init-optional-scaffolding.sh
bash bash/init-phpmyadmin.sh
bash bash/init-project.sh
bash bash/init-complete.sh
name: Startup
- openMode: split-left
Expand All @@ -43,9 +44,10 @@ tasks:
. bash/third-party/spinner.sh &&
start_spinner "Opening preview when system is ready..."
gp sync-await gitpod-inited &&
default_server=$(bash bash/utils.sh parse_ini_value starter.ini development default_server); \
open_preview $default_server &&
stop_spinner $?
stop_spinner 0 &&
__port=$(bash bash/helpers.sh get_default_server_port); \
gp await-port $__port &&
gp preview $(gp url $__port)
name: Main Terminal

vscode:
Expand Down
5 changes: 5 additions & 0 deletions .starter.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These values will be used by the script bash/change-passwords.sh
# All varaiable mus be present in .starter.env
# All varaibles must have a value set
PHPMYADMIN_SUPERUSER_PW=
PHPMYADMIN_CONTROLUSER_PW=
353 changes: 234 additions & 119 deletions README.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions bash/.bash_aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file is sourced into ~/.bashrc
# Add any alias you would like here

# Updates all passwords related to phpmyadmin from values set in .starter.env
# Requires .starter.env to have all phpmyadmin related keys set with values
# Empty string value will break the script
# See .starter.env.example for the required phpmyadmin keys
alias update_pma_pws="bash $GITPOD_REPO_ROOT/bash/change-passwords.sh phpmyadmin"
alias help_update_pma_pws="cat bash/snippets/messages/help-update-pma-pws.txt"
25 changes: 14 additions & 11 deletions bash/before-tasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,39 @@ log_silent () {
# Some rake tasks are dynamic and depend on the configuration in starter.ini
if [ "$(bash bash/utils.sh parse_ini_value starter.ini github-changelog-generator install)" ]; then
msg="Writing rake tasks"
log "$msg..." &&
log_silent "$msg..." &&
bash bash/init-rake-tasks.sh
if [ $? == 0 ]; then
log "SUCCESS: $msg"
log_silent "SUCCESS: $msg"
else
log "ERROR: $msg" -e
fi
fi


# Aliases for git
msg="\ngit aliases have been written"
msg="git aliases have been written"
bash bash/utils.sh add_file_to_file_after \\[alias\\] bash/snippets/emoji-log ~/.gitconfig &&
bash bash/utils.sh add_file_to_file_after \\[alias\\] bash/snippets/git-aliases ~/.gitconfig &&
log "$msg" &&
log "\ntry: git a or: git aliases\nto see what is available.\n"
log_silent "$msg" &&
log_silent "try: git a or: git aliases to see what is available."

# grc color configuration for apache logs
msg="Creating grc color configuration file for apache logs: ~/apache-log-colors.conf"
log "$msg..." &&
msg="Creating grc color configuration file for apache logs in ~/apache-log-colors.conf"
log_silent "$msg..." &&
cat bash/snippets/grc/apache-log-colors > ~/apache-log-colors.conf
if [ $? == 0 ]; then
log "SUCCESS: $msg"
log_silent "SUCCESS: $msg"
else
log "ERROR: $msg" -e
fi

# Keep this at the bottom of the file
# Restores files marked as persistant
# See persist_file in bash/helpers.sh
# Restore files marked as persistant such
# as workspace-init.log
# See persist_file in bash/helpers.sh for how to system works
# Keep this block at the bottom of the file so that any logging from this
# script is only written to file upon initialization! Otherwise workspace-init.log
# will get written to from this script upon every wrokspace restart.
if [ $(bash bash/helpers.sh is_inited) == 1 ]; then
bash bash/helpers.sh restore_persistent_files $GITPOD_REPO_ROOT
fi
105 changes: 105 additions & 0 deletions bash/change-passwords.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash
#
# change-passwords.sh
#
# Description:
# changes passwords for phpmyadmin from the defaults in version control to the values set in .starter.env
# Author: Apolo Pena
#
# NOTE:
# This script should be always run at least once by the user as an mandatory additional layer of security
# This script requires the file .starter.env to exist along will all the key value pairs as set
# in example.starter.ini

# Load spinner
. bash/third-party/spinner.sh

phpmyadmin() {
# Keep keys in sequence. Add new keys to the end of the array
local keys=(PHPMYADMIN_SUPERUSER_PW PHPMYADMIN_CONTROLUSER_PW)

local name="change-passwords.sh phpmyadmin"
local err="$name ERROR:"
local config_file="public/phpmyadmin/config.inc.php"
local all_zeros='^0$|^0*0$'
local exit_codes
local values

for key in ${keys[@]}; do
local value="$(bash bash/helpers.sh get_starter_env_val $key)"
values+=("$(bash bash/helpers.sh get_starter_env_val $key)")
local code="$?"
exit_codes+=$code
# show error message of called function
[ $code != 0 ] && echo "$value"
done

if [[ ! $(echo ${exit_codes[@]} | tr -d '[:space:]') =~ $all_zeros ]]; then
echo "$err retrieving values, no passwords were changed."
exit 1
fi

# Values have been set and there are no errors so far so change passwords
i=0
for key in ${keys[@]}; do
case $key in
"${keys[0]}")
msg="Changing password for phpmyadmin user 'pmasu' to the value found in .starter.env"
start_spinner "$msg"
mysql -e "ALTER USER 'pmasu'@'%' IDENTIFIED BY '${values[$i]}'; FLUSH PRIVILEGES;"
stop_spinner $?
;;
"${keys[1]}")
msg="Changing password for phpmyadmin user 'pma' to the value found in .starter.env"
start_spinner "$msg"
mysql -e "ALTER USER 'pma'@'localhost' IDENTIFIED BY '${values[$i]}'; FLUSH PRIVILEGES;"
err_code=$?
stop_spinner $err_code
if [ $err_code == 0 ]; then
msg="Updating control user password in $config_file"
line="\$cfg['Servers'][\$i]['controlpass'] ="
_edit="\$cfg['Servers'][\$i]['controlpass'] = '${values[$i]}';"
start_spinner "$msg"
# Match the line where the password for the controluser is set
line_num=$(awk '/^\$cfg.*'controlpass'.*=.*;$/ {print FNR}' $config_file)
if [ -z $line_num ]; then
stop_spinner 1
echo "ERROR: No line found beginning with: $line \n\tin the file: $config_file"
echo "You will need to manually update the control user password in $config_file"
else
sed -i "$line_num c\\$_edit" $config_file
err_code=$?
stop_spinner $err_code
unset _edit
[ $err_code == 0 ] &&
echo -e "\e[38;5;171mPROCESS COMPLETE\e[0m" &&
echo -e "\e[1;33mCheck the console output for any possible failures.\e[0m" &&
echo -en "\e[1;36m" &&
echo "If you are logged into phpmyadmin, log out and log back in." &&
echo "For additional security you can delete .starter.env" &&
echo "Just make sure you remember your passwords from that file." &&
echo "If you ever loose your passwords you may always set them again" &&
echo "using this script and new values set in .starter.env" &&
echo -e "\e[0m"
fi
fi
;;
*)
echo "$err unidentified key $value"
;;
esac
((i++))
done
}

# Call functions from this script gracefully
if declare -f "$1" > /dev/null
then
# call arguments verbatim
"$@"
else
echo "utils.sh: '$1' is not a known function name." >&2
exit 1
fi

#echo -e "$(change_phpmyadmin_passwords)"
Loading

0 comments on commit 0290664

Please sign in to comment.