Skip to content

Commit

Permalink
Add self-updater, 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ronilaukkarinen committed Apr 16, 2024
1 parent 85a7400 commit bdee686
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2.4.0: 2024-04-16

* Add self-updater

### 2.3.9: 2024-04-15

Please note: This version contains breaking change, if you are using older macos-lemp-setup and still have PHP 7.4 installed.
Expand Down
5 changes: 4 additions & 1 deletion bin/macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Script specific vars
SCRIPT_LABEL='for macOS'
SCRIPT_VERSION='1.1.3 (2024-04-15)'
SCRIPT_VERSION='1.1.4 (2024-04-16)'

# Vars needed for this file to function globally
CURRENTFILE=`basename $0`
Expand All @@ -31,6 +31,9 @@ echo "${WHITE}Using this start script requires you have dev server installed and
https://github.com/digitoimistodude/macos-lemp-setup
${TXTRESET}"

# First, let's check updates to self
source ${SCRIPTS_LOCATION}/tasks/self-update.sh

# Import required tasks
source ${SCRIPTS_LOCATION}/tasks/imports.sh

Expand Down
51 changes: 51 additions & 0 deletions bin/tasks/self-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Temp colors
export YELLOW=$(tput setaf 3)
export GREEN=$(tput setaf 2)
export RED=$(tput setaf 1)
export TXTRESET=$(tput sgr0)

# Check for symlink
echo "${YELLOW}Running self-updater...${TXTRESET}"

if [ $0 != '/usr/local/bin/createproject' ]; then
echo "${TXTRESET}${WHITE}Please do NOT run this script with ${RED}sh $CURRENTFILE${WHITE} or ${RED}bash $CURRENTFILE${WHITE} or ${RED}./$CURRENTFILE${WHITE}.
Run this script globally instead by simply typing: ${GREEN}createproject{TXTRESET}. If this doesn't work, please run first setup from the bin folder first."
echo ""
exit
fi

# Check for updates
# Get symlink path from /usr/local/bin/newtheme
SYMLINKPATH=$(sudo readlink /usr/local/bin/createproject)

# Get project bin folder directory from symlink path
PROJECTBINFOLDER=$(sudo dirname $SYMLINKPATH)

# Go one step back from bin to get theme root folder
PROJECTROOTFOLDER=$(sudo dirname $PROJECTBINFOLDER)

# Go to the theme root folder
cd $PROJECTROOTFOLDER

# Make sure no file mods are being committed
git config core.fileMode false --replace-all

# Check for updates
git pull origin master

# Ensure permissions are intact
sudo chmod +x /usr/local/bin/createproject

# If there is something preventing the update, show error message
if [ $? -ne 0 ]; then
echo ""
echo "${TXTRESET}${RED}There was an error updating the start script. You have probably made changes to the dudestack files? Please commit those changes, send a PR or stash them. Please check the error message above and try again.${TXTRESET}"
echo ""

# Stop script
exit 1

# If there are no errors, add line break
else
echo ""
fi

0 comments on commit bdee686

Please sign in to comment.