Editting locally /o...
 
Notifications
Clear all

Editting locally /opt/qbo/scripts/QBO_Installer.sh causes endless loop

1 Posts
1 Users
3 Reactions
1,020 Views
chrisbuy
(@chrisbuy)
Member
Joined: 6 years ago
Posts: 71
Topic starter  

When performing an update ('sudo /opt/qbo/scripts/QBO_instqller.sh update' ) when you have editted the file locally on your Q.bo causes the script to go in an endless loop.

The UPDATE function has the following code...

function UPDATE {

# Get current branch
CURRENT_BRANCH=`git -C /opt/qbo rev-parse --abbrev-ref HEAD`

# Obtain changes from origin
printf "Downloading updates...\n"
sudo -u qbo /usr/bin/git -C /opt/qbo fetch origin

# Obtain if QBO_Installer file changed
QBO_INSTALLER_CHANGED=`sudo -u qbo /usr/bin/git -C /opt/qbo diff origin/${CURRENT_BRANCH} --name-only | grep QBO_Installer.sh | wc -l`

# Applying changes
printf "Applying updates...\n"
sudo -u qbo /usr/bin/git -C /opt/qbo merge FETCH_HEAD

# Check if QBO_Installer file changed, process of update is restarted
if [ ${QBO_INSTALLER_CHANGED} == "1" ]
then
printf "New installer detected. Restarting update process ...\n"
/opt/qbo/scripts/QBO_Installer.sh update
exit 1
fi

The git merge will never update the local editted version of QBO_Installer.sh but it will continue to report it is different. This set QBO_INSTALLER_CHANGED always to be true which then will always causes the script to restart on and on... you need to detect if code has actually changed before just like that restarting the update...

function UPDATE {

# Get current branch
CURRENT_BRANCH=`git -C /opt/qbo rev-parse --abbrev-ref HEAD`

# Obtain changes from origin
printf "Downloading updates...\n"
sudo -u qbo /usr/bin/git -C /opt/qbo fetch origin

# Obtain if QBO_Installer file changed
QBO_INSTALLER_CHANGED=`sudo -u qbo /usr/bin/git -C /opt/qbo diff origin/${CURRENT_BRANCH} --name-only | grep QBO_Installer.sh | wc -l`

# Applying changes
printf "Applying updates...\n"
QBO_CODE_CHANGED=`sudo -u qbo /usr/bin/git -C /opt/qbo merge FETCH_HEAD | grep -v -c "Already up-to-date."`

# Check if QBO_Installer file changed, process of update is restarted
if [ ${QBO_INSTALLER_CHANGED} == "1" ] && [ ${QBO_CODE_CHANGED} -gt "0" ]
then
printf "New installer detected. Restarting update process ...\n"
/opt/qbo/scripts/QBO_Installer.sh update
exit 1
fi

This will allow you to continue trying out your changes to the QBO_Installer.sh script with 'update'.

A merge request will follow for this.

This topic was modified 6 years ago 4 times by chrisbuy

--
Christian Buysschaert
Leuven - Belgium
Email christian.buysschaert@gmail.com


   
Quote
Share: