Skip to content
Snippets Groups Projects
Verified Commit 7478d749 authored by David Beniamine's avatar David Beniamine
Browse files

Automatically upgrade Dolibarr minor version

+ Automatic upgrade for Dolibarr minor versions
+ Possibility to force upgrade to next Dolibarr major version
+ Retrieve versions from sourceforge
parent 8232c2be
Branches
No related tags found
No related merge requests found
#!/bin/bash
# echo "Fixing Dolibarr bug #7420"
# sed -i.bak "178s@'\(__[^_]*__\)'@'/\1/'@g" /usr/share/dolibarr/htdocs/includes/odtphp/Segment.php
echo "Fixing issue with barcode generation"
sed -i.bak "s/\$result=\$productstatic->setValueFrom('barcode', \$nextvalue, '', '', 'date', '', \$user, 'PRODUCT_MODIFY');/\$result=\$productstatic->setValueFrom('barcode', \$nextvalue, '', '', 'text', '', \$user, 'PRODUCT_MODIFY');/" /usr/share/dolibarr/htdocs/barcode/codeinit.php
File deleted
...@@ -24,31 +24,92 @@ then ...@@ -24,31 +24,92 @@ then
echo "Dolibarr not installed, aborting" echo "Dolibarr not installed, aborting"
exit 1 exit 1
fi fi
if [ "$MAINTENANCE_LEVEL" == "security" ] && [ "$1" != "force" ]
current_version=`apt-cache policy dolibarr | grep Installed \
| awk '{print $2}' | sed 's/-[^-*]$//'`
echo "Current version of Dolibarr: $current_version"
# Get Dolideb version list
echo "Retrieving list of Dolibarr versions"
curl \
https://sourceforge.net/projects/dolibarr/files/Dolibarr%20installer%20for%20Debian-Ubuntu%20%28DoliDeb%29/ \
2> /dev/null | sed 's/,/\n/g'| grep '^ "download_url"' > $$-list
# Get next version number
current_major=`echo $current_version | cut -d . -f 1`
if [ "$1" == "force" ]
then then
echo "Dolibar upgrade is disabled for security mode, to force upgrade, run:" update_type="major"
echo -e "\t$0 force" num='[0-9][0-9]*'
exit 1 else
update_type="minor"
num=$current_major
fi fi
git pull
current_version=`apt-cache policy dolibarr | grep Installed | awk '{print $2}'` url=`grep "[^\d\.]$num\..*" $$-list | sort -r | head -n 1 \
echo "Current version of Dolibarr: $current_version" | sed 's/.*"\(https.*\)"/\1/'`
package=`/bin/ls DOLIBARR_PACKAGES/*.deb` rm $$-list
last_repo_version=`echo $package | sed 's/.*dolibarr_\([^_]*\)_.*/\1/'`
echo "Version of Dolibarr on our repo: $last_repo_version" last_ver=`echo $url | sed 's@.*/\([0-9\.]*\)/download.*@\1@'`
if [ "$current_version" == "$last_repo_version" ] if [ "$current_major" != "`echo $last_ver | cut -d . -f 1`" ]
then
# Force interaction on major version upgrade
read -p "Are you sure you want to upgrade from $current_version to $last_ver [y/N]" answer
if [ "$answer" != "y" ]
then then
echo "Current version of Dolibarr is the last version in our repo, nothing to do" echo "Aborting"
exit exit
fi fi
fi
# Fix bad download URL
url=`echo $url | sed "s@/download@/dolibarr_$last_ver-4_all.deb/download@"`
echo "Last $update_type version is $last_ver"
if [ "$current_version" == "$last_ver" ]
then
echo "This server is running $update_type version of Dolibarr, nothing to do"
exit
fi
# Get sources
OLDDIR=$PWD
if [ ! -e "/opt/dolibarr" ]
then
cd /opt
git clone https://github.com/Dolibarr/dolibarr/
fi
cd /opt/dolibarr
git reset --hard HEAD
git checkout -b $current_version $current_version
git branch -v
# Get local changes
cp -r /usr/share/dolibarr/htdocs/* htdocs/
cd $OLDDIR
echo "Backing up database" echo "Backing up database"
mysqldump --databases $DOLIBARR_DB > /root/$DOLIBARR_DB.sql mysqldump --databases $DOLIBARR_DB > /root/$DOLIBARR_DB.sql
mysqldump --all-databases > /root/dbs.sql mysqldump --all-databases > /root/dbs.sql
echo "Downloading Dolibarr $last_ver"
package=dolibarr-$last_ver.deb
wget -O $package $url
echo "Installing $package" echo "Installing $package"
dpkg -i $package dpkg -i $package
rm $package
echo "Fixing dependencies" echo "Fixing dependencies"
apt-get -f install apt-get -f install
rm /usr/share/dolibarr/documents/install.lock rm /usr/share/dolibarr/documents/install.lock
[ -f "DOLIBARR_PACKAGES/apply_patch.sh" ] && /bin/bash DOLIBARR_PACKAGES/apply_patch.sh echo "One final step is required to upgrade to Dolibarr $last_ver:"
echo "One final step is required to upgrade to Dolibarr $last_repo_version:"
echo "Please go to your Dolibarr page and run the manual upgrade step" echo "Please go to your Dolibarr page and run the manual upgrade step"
echo "There might be local changes to Dolibarr previous to upgrade, see below:"
cd /opt/dolibarr
git diff > patch
cat patch
git status
cd $OLDDIR
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment