diff --git a/build/debian/dolibarr.config b/build/debian/dolibarr.config index 553e5ffd7f6..931c5d502df 100644 --- a/build/debian/dolibarr.config +++ b/build/debian/dolibarr.config @@ -48,7 +48,7 @@ echo "Ask for web server to setup" db_input critical dolibarr/reconfigure-webserver || true if db_go ; then - okcancel="1" + okcancel="1" else okcancel="0" fi diff --git a/build/debian/dolibarr.postinst b/build/debian/dolibarr.postinst index 6ba9123ede4..1ae26c74025 100644 --- a/build/debian/dolibarr.postinst +++ b/build/debian/dolibarr.postinst @@ -19,25 +19,25 @@ if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then fi setup_empty_conf() { - echo Create empty file $config - mkdir -p /etc/dolibarr - touch /etc/dolibarr/conf.php - chown root:www-data /etc/dolibarr/conf.php - chmod 660 /etc/dolibarr/conf.php + echo Create empty file $config + mkdir -p /etc/dolibarr + touch /etc/dolibarr/conf.php + chown root:www-data /etc/dolibarr/conf.php + chmod 660 /etc/dolibarr/conf.php } is_new_upstream_version() { - # $1 can be empty (not installed) and will result in a true value - # for the check - old_version=$(echo "$1" | sed -e 's/-[^-]*$//' -e 's/^[0-9]*://') - new_version=$(dpkg-query -f '${Version}' -W dolibarr | \ - sed -e 's/-[^-]*$//' -e 's/^[0-9]*://') - test "$old_version" != "$new_version" + # $1 can be empty (not installed) and will result in a true value + # for the check + old_version=$(echo "$1" | sed -e 's/-[^-]*$//' -e 's/^[0-9]*://') + new_version=$(dpkg-query -f '${Version}' -W dolibarr | \ + sed -e 's/-[^-]*$//' -e 's/^[0-9]*://') + test "$old_version" != "$new_version" } enable_install_upgrade_wizard() { echo Enable install wizard by removing install.lock file if present - rm -f /var/lib/dolibarr/documents/install.lock + rm -f /var/lib/dolibarr/documents/install.lock } @@ -46,24 +46,24 @@ php_install() { # php5endmod exists for ubuntu only echo "Enable php module mysqli with php5enmod" php5enmod mysqli - fi + fi } apache_install() { webserver=$1 - + # Enable Apache 2 alias module if which a2enmod >/dev/null 2>&1 ;then echo "Enable apache module alias with a2enmod" a2enmod alias fi - + # Enable dolibarr conf if which a2enconf >/dev/null 2>&1 ;then # a2enconf exists for ubuntu only echo "Enable link for Apache config file with a2enconf" a2enconf dolibarr - else + else if [ -d /etc/$webserver/conf.d ] && [ ! -e /etc/$webserver/conf.d/dolibarr.conf ]; then echo "Add link for Apache config file" ln -s /etc/$webserver/conf-available/dolibarr.conf /etc/$webserver/conf.d/dolibarr.conf @@ -101,7 +101,7 @@ case "$1" in configure) if [ -z "$2" ]; then echo First install - #setup_empty_conf + #setup_empty_conf else echo This is not a first install fi @@ -109,17 +109,17 @@ case "$1" in php_install apache_install lighttpd_install - + # Remove lock file if is_new_upstream_version "$2"; then - enable_install_upgrade_wizard + enable_install_upgrade_wizard fi - - # Create document directory for uploaded data files - mkdir -p $docdir - chown -R www-data:www-data $docdir - chmod -R 775 $docdir - chmod -R g+s $docdir + + # Create document directory for uploaded data files + mkdir -p $docdir + chown -R www-data:www-data $docdir + chmod -R 775 $docdir + chmod -R g+s $docdir # Copy install config file (with matching Debian values) into target directory superuserlogin='' @@ -136,14 +136,14 @@ case "$1" in cat $installfileorig | sed -e 's/__SUPERUSERLOGIN__/'$superuserlogin'/g' | sed -e 's/__SUPERUSERPASSWORD__/'$superuserpassword'/g' > $installconfig fi chown -R root:www-data $installconfig - chmod -R 660 $installconfig + chmod -R 660 $installconfig # If a conf already exists and its content was already completed by installer if [ ! -s $config ] || ! grep -q "File generated by" $config then # Create an empty conf.php with permission to web server setup_empty_conf - #else + #else # File already exist. We add params not found. #echo Add new params to overwrite path to use shared libraries/fonts ##grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config @@ -154,18 +154,18 @@ case "$1" in #grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "" >> $config #grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "" >> $config #grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "" >> $config - #grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config + #grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config fi - + db_get dolibarr/reconfigure-webserver - + webservers="$RET" - + # Set up web server. for webserver in $webservers ; do webserver=${webserver%,} echo Complete config of server $webserver - + # Detect webuser and webgroup webuser= webgroup= @@ -181,7 +181,7 @@ case "$1" in # Set permissions to web server chown -R $webuser:$webgroup /usr/share/dolibarr - chown -R root:$webgroup $config + chown -R root:$webgroup $config done # Restart web server. @@ -193,33 +193,33 @@ case "$1" in apache_install $webserver fi # Reload webserver in any case, configuration might have changed - # Redirection of 3 is needed because Debconf uses it and it might + # Redirection of 3 is needed because Debconf uses it and it might # be inherited by webserver. See bug #446324. - if [ -f /etc/init.d/$webserver ] ; then - if [ -x /usr/sbin/invoke-rc.d ]; then - echo Restart web server $server using invoke-rc.d - # This works with Debian (5.05,...) and Ubuntu (9.10,10.04,...) - invoke-rc.d $webserver reload 3>/dev/null || true - else - echo Restart web server $server using $server reload - /etc/init.d/$webserver reload 3>/dev/null || true - fi - fi + if [ -f /etc/init.d/$webserver ] ; then + if [ -x /usr/sbin/invoke-rc.d ]; then + echo Restart web server $server using invoke-rc.d + # This works with Debian (5.05,...) and Ubuntu (9.10,10.04,...) + invoke-rc.d $webserver reload 3>/dev/null || true + else + echo Restart web server $server using $server reload + /etc/init.d/$webserver reload 3>/dev/null || true + fi + fi done - + echo ---------- echo "Call Dolibarr page http://localhost/dolibarr/ to complete the setup and use Dolibarr." echo ---------- - ;; + ;; abort-upgrade|abort-remove|abort-deconfigure) - ;; + ;; *) echo "postinst called with unknown argument $1" >&2 exit 0 - ;; + ;; esac #DEBHELPER# diff --git a/build/debian/dolibarr.postrm b/build/debian/dolibarr.postrm index fa16ed582f0..d10f81c0c3e 100644 --- a/build/debian/dolibarr.postrm +++ b/build/debian/dolibarr.postrm @@ -30,8 +30,8 @@ lighttpd_remove() { fi # See bug #448682 if [ -h /etc/lighttpd/conf-enabled/50-dolibarr.conf ] ; then - echo "postrm Manually deleting lighttpd/dolibarr configuration link" - rm /etc/lighttpd/conf-enabled/50-dolibarr.conf + echo "postrm Manually deleting lighttpd/dolibarr configuration link" + rm /etc/lighttpd/conf-enabled/50-dolibarr.conf fi fi } @@ -46,7 +46,7 @@ apache_remove() { if [ -f /usr/share/debconf/confmodule ]; then - . /usr/share/debconf/confmodule + . /usr/share/debconf/confmodule fi db_version 2.0 @@ -62,12 +62,12 @@ lockfile="$docdir/install.lock" case "$1" in - # Call when we upgrade + # Call when we upgrade upgrade) echo "postrm upgrade" - ;; + ;; - # Call when we uninstall + # Call when we uninstall remove) echo "postrm remove" rm -f $lockfile @@ -85,7 +85,7 @@ case "$1" in else apache_remove $webserver fi - # Redirection of 3 is needed because Debconf uses it and it might + # Redirection of 3 is needed because Debconf uses it and it might # be inherited by webserver. See bug #446324. if [ -f /etc/init.d/$webserver ] ; then if [ -x /usr/sbin/invoke-rc.d ]; then @@ -95,9 +95,9 @@ case "$1" in fi fi done - ;; + ;; - # Call when we uninstall and purge + # Call when we uninstall and purge purge) echo "postrm purge" @@ -111,7 +111,7 @@ case "$1" in set +e db_get dolibarr/postrm set -e - + if [ "$RET" = "true" ] ; then echo postrm Mysql database deletion # Get database configuration @@ -131,7 +131,7 @@ case "$1" in dbadmin="$superuserlogin" dbadmpass="$superuserpassword" dbtype="mysql" - + # To delete a mysql user (disabled) # Needs: $dbuser - the user name to create (or replace). # $dballow - what hosts to allow (defaults to %). @@ -144,7 +144,7 @@ case "$1" in # mysql # /usr/share/wwwconfig-coomon/mysql.get #. /usr/share/wwwconfig-common/${dbtype}-dropuser.sh - + # To delete database # Needs: $dbname - the database that user should have access to. # $dbserver - the server to connect to. @@ -158,85 +158,85 @@ case "$1" in # Define mysqlcmd if [ -z "$dbserver" ] || [ "$dbserver" = "localhost" ]; then hostopt="" - dbserver=localhost + dbserver=localhost else - case "$dbserver" in - :*) - dbsocket=`echo $dbserver | sed -e 's/^://'` - hostopt="-S $dbsocket" - ;; - *) - hostopt="-h $dbserver" - ;; - esac + case "$dbserver" in + :*) + dbsocket=`echo $dbserver | sed -e 's/^://'` + hostopt="-S $dbsocket" + ;; + *) + hostopt="-h $dbserver" + ;; + esac fi if [ -z "$dbadmpass" ] ; then - log="${log}No password used." - passopt="" + log="${log}No password used." + passopt="" else - passopt="--password='"`echo "$dbadmpass" | sed -e "s/'/'"'"'"'"'"'"'/g"`"'" + passopt="--password='"`echo "$dbadmpass" | sed -e "s/'/'"'"'"'"'"'"'/g"`"'" fi mysqlcmd="mysql $hostopt $passopt -u $dbadmin" mysqlcmdnopass="mysql $hostopt -u $dbadmin" - - # Now run the drop user + + # Now run the drop user if eval $mysqlcmd -f -e "\"DROP USER '$dbuser'@'localhost';\"" ; then echo postrm Database login $dbuser@localhost removed else - error="Unable to run $mysqlcmdnopass -f -e \"DROP USER '$dbuser'@'localhost';\"" + error="Unable to run $mysqlcmdnopass -f -e \"DROP USER '$dbuser'@'localhost';\"" echo postrm $error fi if eval $mysqlcmd -f -e "\"DROP USER '$dbuser'@'%';\"" ; then echo postrm Database login $dbuser@% removed else - error="Unable to run $mysqlcmdnopass -f -e \"DROP USER '$dbuser'@'%';\"" + error="Unable to run $mysqlcmdnopass -f -e \"DROP USER '$dbuser'@'%';\"" echo postrm $error fi - # Now run the drop commands - if eval $mysqlcmd -f -e "\"show databases;\"" | grep -e "^$dbname" > /dev/null 2>&1 ; then - log="${log}Droping database $dbname." + # Now run the drop commands + if eval $mysqlcmd -f -e "\"show databases;\"" | grep -e "^$dbname" > /dev/null 2>&1 ; then + log="${log}Dropping database $dbname." if eval $mysqlcmd -f -e "\"DROP DATABASE $dbname;\"" ; then - if eval $mysqlcmd -f -e "\"show databases;\"" | grep -e "^$dbname" > /dev/null 2>&1 ; then - error="Database $dbname NOT successfully droped. You have to do it manually." - echo postrm $error - else - status=drop - fi + if eval $mysqlcmd -f -e "\"show databases;\"" | grep -e "^$dbname" > /dev/null 2>&1 ; then + error="Database $dbname NOT successfully dropped. You have to do it manually." + echo postrm $error + else + status=drop + fi else - error="Unable to run the drop database script." + error="Unable to run the drop database script." echo postrm $error fi - else + else status=nothing log="${log}Database $dbname already not exists." - fi + fi + + echo "postrm Remove directory $docdir" + rm -rf $docdir ; - echo "postrm Remove directory $docdir" - rm -rf $docdir ; - else - echo "postrm Delete of dolibarr database and uploaded files not wanted" + echo "postrm Delete of dolibarr database and uploaded files not wanted" fi - + rm -rf /etc/dolibarr # We clean variable (we ignore errors because db_reset can fails if var was never set) - set +e + set +e db_reset dolibarr/reconfigure-webserver db_reset dolibarr/postrm - set -e + set -e #db_purge - ;; + ;; failed-upgrade|abort-install|abort-upgrade|disappear) - ;; + ;; *) echo "postrm called with unknown argument $1" >&2 exit 0 - ;; + ;; esac #DEBHELPER# diff --git a/build/debian/get-orig-source.sh b/build/debian/get-orig-source.sh index cc22a53c908..fdd38ea0851 100755 --- a/build/debian/get-orig-source.sh +++ b/build/debian/get-orig-source.sh @@ -5,7 +5,7 @@ tmpdir=$(mktemp -d) # Download source file if [ -n "$1" ]; then - uscan_opts="--download-version=$1" + uscan_opts="--download-version=$1" fi #uscan --noconf --force-download --no-symlink --verbose --destdir=$tmpdir $uscan_opts diff --git a/build/docker/docker-run.sh b/build/docker/docker-run.sh index a2b0ce30dbc..69f9e8e227c 100755 --- a/build/docker/docker-run.sh +++ b/build/docker/docker-run.sh @@ -1,6 +1,6 @@ #!/bin/bash # Script used by the Dockerfile. -# See README.md to know how to create a Dolibarr env with docker +# See README.md to know how to create a Dolibarr env with docker usermod -u ${HOST_USER_ID} www-data groupmod -g ${HOST_USER_ID} www-data diff --git a/build/patch/buildpatch.sh b/build/patch/buildpatch.sh index 3bbc6ea3176..9eb787278b3 100755 --- a/build/patch/buildpatch.sh +++ b/build/patch/buildpatch.sh @@ -1,4 +1,4 @@ -#/bin/ksh +#!/bin/bash #---------------------------------------------------------------------------- # \file build/patch/buildpatch.sh # \brief Create patch files @@ -6,16 +6,16 @@ #---------------------------------------------------------------------------- # This script can be used to build a patch after a developer has made # changes on files in its Dolibarr tree. -# The output patch file can then be submited on Dolibarr dev mailing-list, +# The output patch file can then be submitted on Dolibarr dev mailing-list, # with explanation on its goal, for inclusion in main branch. #---------------------------------------------------------------------------- echo ----- Building patch file mypatch.patch ----- if [ -z "$1" ] || [ -z "$2" ]; -then - echo Usage: buildpatch.sh original_dir_path modified_dir_path - echo Example: buildpatch.sh /mydirA/dolibarrold /mydirB/dolibarrnew +then + echo Usage: buildpatch.sh original_dir_path modified_dir_path + echo Example: buildpatch.sh /mydirA/dolibarrold /mydirB/dolibarrnew else - echo Build patch between \"$1\" and \"$2\" - diff -BNaur --exclude=CVS --exclude="*.patch" --exclude=".#*" --exclude="*~" --exclude="*.rej" --exclude="*.orig" --exclude="*.bak" --exclude=conf.php --exclude=documents $1 $2 > mypatch.patch + echo Build patch between \"$1\" and \"$2\" + diff -BNaur --exclude=CVS --exclude="*.patch" --exclude=".#*" --exclude="*~" --exclude="*.rej" --exclude="*.orig" --exclude="*.bak" --exclude=conf.php --exclude=documents $1 $2 > mypatch.patch fi diff --git a/dev/initdemo/initdemo.sh b/dev/initdemo/initdemo.sh index 7e38e837e0f..be971b4d4be 100755 --- a/dev/initdemo/initdemo.sh +++ b/dev/initdemo/initdemo.sh @@ -9,7 +9,7 @@ # Regis Houssin - regis.houssin@inodbox.com # Laurent Destailleur - eldy@users.sourceforge.net #------------------------------------------------------ -# Usage: initdemo.sh confirm +# Usage: initdemo.sh confirm # usage: initdemo.sh confirm mysqldump_dolibarr_x.x.x.sql database port login pass #------------------------------------------------------ @@ -17,7 +17,7 @@ export mydir=`echo "$0" | sed -e 's/initdemo.sh//'`; if [ "x$mydir" = 'x' -o "x$mydir" = 'x./' ] then - export mydir="." + export mydir="." fi export id=`id -u`; @@ -59,106 +59,106 @@ then fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Init Dolibarr with demo values" --clear \ - --inputbox "Input dump file :" 16 55 $dumpfile 2> $fichtemp + --inputbox "Input dump file :" 16 55 $dumpfile 2> $fichtemp valret=$? case $valret in - 0) - dumpfile=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + dumpfile=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac rm $fichtemp - + # ----------------------------- database name DIALOG=${DIALOG=dialog} DIALOG="$DIALOG --ascii-lines" fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Init Dolibarr with demo values" --clear \ - --inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp + --inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp valret=$? case $valret in - 0) - base=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + base=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac rm $fichtemp - + # ---------------------------- database port DIALOG=${DIALOG=dialog} fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Init Dolibarr with demo values" --clear \ - --inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp - + --inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp + valret=$? - + case $valret in - 0) - port=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + port=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac rm $fichtemp - + # ---------------------------- compte admin mysql DIALOG=${DIALOG=dialog} fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Init Dolibarr with demo values" --clear \ - --inputbox "Mysql user login (ex: root):" 16 55 root 2> $fichtemp - + --inputbox "Mysql user login (ex: root):" 16 55 root 2> $fichtemp + valret=$? - + case $valret in - 0) - admin=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + admin=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac rm $fichtemp - - # ---------------------------- mot de passe admin mysql + + # ---------------------------- password admin mysql (root) DIALOG=${DIALOG=dialog} fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Init Dolibarr with demo values" --clear \ - --passwordbox "Password for Mysql user login :" 16 55 2> $fichtemp - + --passwordbox "Password for Mysql user login :" 16 55 2> $fichtemp + valret=$? - + case $valret in - 0) - passwd=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + passwd=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac rm $fichtemp - - + + export documentdir=`cat $mydir/../../htdocs/conf/conf.php | grep '^\$dolibarr_main_data_root' | sed -e 's/$dolibarr_main_data_root=//' | sed -e 's/;//' | sed -e "s/'//g" | sed -e 's/"//g' ` # ---------------------------- confirmation DIALOG=${DIALOG=dialog} $DIALOG --title "Init Dolibarr with demo values" --clear \ - --yesno "Do you confirm ? \n Dump file : '$dumpfile' \n Dump dir : '$mydir' \n Document dir : '$documentdir' \n Mysql database : '$base' \n Mysql port : '$port' \n Mysql login: '$admin' \n Mysql password : --hidden--" 15 55 - + --yesno "Do you confirm ? \n Dump file : '$dumpfile' \n Dump dir : '$mydir' \n Document dir : '$documentdir' \n Mysql database : '$base' \n Mysql port : '$port' \n Mysql login: '$admin' \n Mysql password : --hidden--" 15 55 + case $? in - 0) echo "Ok, start process...";; - 1) exit;; - 255) exit;; + 0) echo "Ok, start process..." ;; + 1) exit ;; + 255) exit ;; esac fi @@ -180,7 +180,7 @@ export res=$? if [ $res -ne 0 ]; then echo "Error to load database dump with mysql -P$port -u$admin -p***** $base < $mydir/$dumpfile" exit -fi +fi $mydir/updatedemo.php confirm export res=$? @@ -190,32 +190,32 @@ export documentdir=`cat $mydir/../../htdocs/conf/conf.php | grep '^\$dolibarr_ma if [ "x$documentdir" != "x" ] then $DIALOG --title "Reset document directory" --clear \ - --inputbox "DELETE and recreate document directory $documentdir/:" 16 55 n 2> $fichtemp - + --inputbox "DELETE and recreate document directory $documentdir/:" 16 55 n 2> $fichtemp + valret=$? - + case $valret in - 0) - rep=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + rep=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac - + echo "rep=$rep" if [ "x$rep" = "xy" ]; then echo rm -fr "$documentdir/*" rm -fr $documentdir/* fi - + echo cp -pr $mydir/documents_demo/* "$documentdir/" cp -pr $mydir/documents_demo/* "$documentdir/" - + mkdir "$documentdir/doctemplates/" 2>/dev/null echo cp -pr $mydir/../../htdocs/install/doctemplates/* "$documentdir/doctemplates/" cp -pr $mydir/../../htdocs/install/doctemplates/* "$documentdir/doctemplates/" - + echo cp -pr $mydir/../../htdocs/install/medias/* "$documentdir/medias/image/" cp -pr $mydir/../../htdocs/install/medias/* "$documentdir/medias/image/" @@ -224,11 +224,11 @@ then rm -f "$documentdir/doctemplates/"*/index.html echo cp -pr $mydir/../../doc/images/* "$documentdir/ecm/Images" cp -pr $mydir/../../doc/images/* "$documentdir/ecm/Images" - + chmod -R u+w "$documentdir/" chown -R www-data "$documentdir/" else - echo Detection of documents directory from $mydir failed so demo files were not copied. + echo Detection of documents directory from $mydir failed so demo files were not copied. fi diff --git a/dev/initdemo/initdemopassword.sh b/dev/initdemo/initdemopassword.sh index bcf2b14887e..1e5d96d1bb0 100755 --- a/dev/initdemo/initdemopassword.sh +++ b/dev/initdemo/initdemopassword.sh @@ -5,7 +5,7 @@ # # Laurent Destailleur - eldy@users.sourceforge.net #------------------------------------------------------ -# Usage: initdemopassword.sh confirm +# Usage: initdemopassword.sh confirm # usage: initdemopassword.sh confirm base port login pass #------------------------------------------------------ @@ -13,7 +13,7 @@ export mydir=`echo "$0" | sed -e 's/initdemopassword.sh//'`; if [ "x$mydir" = 'x' -o "x$mydir" = 'x./' ] then - export mydir="." + export mydir="." fi export id=`id -u`; @@ -56,87 +56,87 @@ then fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Reset login password" --clear \ - --inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp + --inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp valret=$? case $valret in - 0) - base=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + base=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac rm $fichtemp - + # ---------------------------- database port DIALOG=${DIALOG=dialog} fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Reset login password" --clear \ - --inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp - + --inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp + valret=$? - + case $valret in - 0) - port=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + port=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac rm $fichtemp - - + + # ----------------------------- demo login DIALOG=${DIALOG=dialog} DIALOG="$DIALOG --ascii-lines" fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Reset login password" --clear \ - --inputbox "Login to reset :" 16 55 dolibarrdemologin 2> $fichtemp + --inputbox "Login to reset :" 16 55 dolibarrdemologin 2> $fichtemp valret=$? case $valret in - 0) - demologin=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + demologin=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac rm fichtemp - + # ----------------------------- demo pass DIALOG=${DIALOG=dialog} DIALOG="$DIALOG --ascii-lines" fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Reset login password" --clear \ - --inputbox "Pass to set :" 16 55 dolibarrdemopass 2> $fichtemp + --inputbox "Pass to set :" 16 55 dolibarrdemopass 2> $fichtemp valret=$? case $valret in - 0) - demopass=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + demopass=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac rm fichtemp - - + + export documentdir=`cat $mydir/../../htdocs/conf/conf.php | grep '^\$dolibarr_main_data_root' | sed -e 's/$dolibarr_main_data_root=//' | sed -e 's/;//' | sed -e "s/'//g" | sed -e 's/"//g' ` # ---------------------------- confirmation DIALOG=${DIALOG=dialog} $DIALOG --title "Reset login password" --clear \ - --yesno "Do you confirm ? \n Mysql database : '$base' \n Mysql port : '$port' \n Demo login: '$demologin' \n Demo password : '$demopass'" 15 55 - + --yesno "Do you confirm ? \n Mysql database : '$base' \n Mysql port : '$port' \n Demo login: '$demologin' \n Demo password : '$demopass'" 15 55 + case $? in - 0) echo "Ok, start process...";; - 1) exit;; - 255) exit;; + 0) echo "Ok, start process..." ;; + 1) exit ;; + 255) exit ;; esac fi @@ -152,7 +152,7 @@ fi if [ "x${demopasshash}" != "xpassword_hash" ] then - echo '' > /tmp/tmp.php + echo '' > /tmp/tmp.php newpass=`php -f /tmp/tmp.php` else echo '' > /tmp/tmp.php @@ -167,7 +167,7 @@ export res=$? if [ $res -ne 0 ]; then echo "Error to execute sql with mysql -P$port -u$admin -p***** $base" exit -fi +fi if [ -s "$mydir/initdemopostsql.sql" ]; then echo A file initdemopostsql.sql was found, we execute it. @@ -175,7 +175,7 @@ if [ -s "$mydir/initdemopostsql.sql" ]; then mysql -P$port $base < "$mydir/initdemopostsql.sql" else echo No file initdemopostsql.sql found, so no extra sql action done. -fi +fi if [ "x$res" = "x0" ] diff --git a/dev/initdemo/removeconfdemo.sh b/dev/initdemo/removeconfdemo.sh index b5f76c45205..9bbb01be2a6 100755 --- a/dev/initdemo/removeconfdemo.sh +++ b/dev/initdemo/removeconfdemo.sh @@ -6,7 +6,7 @@ # Regis Houssin - regis.houssin@inodbox.com # Laurent Destailleur - eldy@users.sourceforge.net #------------------------------------------------------ -# WARNING: This script erase setup of instance, +# WARNING: This script erase setup of instance, # but not the database #------------------------------------------------------ @@ -14,7 +14,7 @@ export mydir=`echo "$0" | sed -e 's/removedemo.sh//'`; if [ "x$mydir" = "x" ] then - export mydir="./" + export mydir="./" fi export id=`id -u`; @@ -22,8 +22,8 @@ export id=`id -u`; # ----------------------------- check if root if [ "x$id" != "x0" -a "x$id" != "x1001" ] then - echo "Script must be ran as root" - exit + echo "Script must be ran as root" + exit fi @@ -32,15 +32,15 @@ DIALOG="$DIALOG --ascii-lines" fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Remove Dolibarr install" --clear \ - --yesno "Do you confirm ?" 15 40 + --yesno "Do you confirm ?" 15 40 valret=$? case $valret in - 0) -base=`cat $fichtemp`;; - 1) -exit;; - 255) -exit;; + 0) + base=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac # ---------------------------- remove conf file diff --git a/dev/initdemo/savedemo.sh b/dev/initdemo/savedemo.sh index 97ac279f43c..9b509aba788 100755 --- a/dev/initdemo/savedemo.sh +++ b/dev/initdemo/savedemo.sh @@ -1,6 +1,6 @@ #!/bin/sh #------------------------------------------------------ -# Script to extrac a database with demo values. +# Script to extract a database with demo values. # Note: "dialog" tool need to be available if no parameter provided. # # Regis Houssin - regis.houssin@inodbox.com @@ -14,7 +14,7 @@ export mydir=`echo "$0" | sed -e 's/savedemo.sh//'`; if [ "x$mydir" = "x" ] then - export mydir="." + export mydir="." fi export id=`id -u`; @@ -47,97 +47,97 @@ then fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Save Dolibarr with demo values" --clear \ - --inputbox "Output dump file :" 16 55 $dumpfile 2> $fichtemp + --inputbox "Output dump file :" 16 55 $dumpfile 2> $fichtemp valret=$? case $valret in - 0) - dumpfile=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + dumpfile=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac - + # ----------------------------- database name DIALOG=${DIALOG=dialog} DIALOG="$DIALOG --ascii-lines" fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Save Dolibarr with demo values" --clear \ - --inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp + --inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp valret=$? case $valret in - 0) - base=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + base=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac - + # ---------------------------- database port DIALOG=${DIALOG=dialog} fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Save Dolibarr with demo values" --clear \ - --inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp - + --inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp + valret=$? - + case $valret in - 0) - port=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + port=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac - + # ---------------------------- compte admin mysql DIALOG=${DIALOG=dialog} fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Save Dolibarr with demo values" --clear \ - --inputbox "Mysql root login (ex: root):" 16 55 root 2> $fichtemp - + --inputbox "Mysql root login (ex: root):" 16 55 root 2> $fichtemp + valret=$? - + case $valret in - 0) - admin=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + admin=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac - - # ---------------------------- mot de passe admin mysql + + # ---------------------------- Password for admin mysql (root) DIALOG=${DIALOG=dialog} fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Save Dolibarr with demo values" --clear \ - --passwordbox "Password for Mysql root login :" 16 55 2> $fichtemp - + --passwordbox "Password for Mysql root login :" 16 55 2> $fichtemp + valret=$? - + case $valret in - 0) - passwd=`cat $fichtemp`;; - 1) - exit;; - 255) - exit;; + 0) + passwd=`cat $fichtemp` ;; + 1) + exit ;; + 255) + exit ;; esac - + # ---------------------------- chemin d'acces du repertoire documents #DIALOG=${DIALOG=dialog} #fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ #trap "rm -f $fichtemp" 0 1 2 5 15 #$DIALOG --title "Save Dolibarr with demo values" --clear \ - # --inputbox "Full path to documents directory (ex: /var/www/dolibarr/documents)- no / at end :" 16 55 2> $fichtemp - + # --inputbox "Full path to documents directory (ex: /var/www/dolibarr/documents)- no / at end :" 16 55 2> $fichtemp + #valret=$? - + #case $valret in # 0) #docs=`cat $fichtemp`;; @@ -146,16 +146,16 @@ then # 255) #exit;; #esac - + # ---------------------------- confirmation DIALOG=${DIALOG=dialog} $DIALOG --title "Save Dolibarr with demo values" --clear \ - --yesno "Do you confirm ? \n Dump file : '$dumpfile' \n Dump dir : '$mydir' \n Mysql database : '$base' \n Mysql port : '$port' \n Mysql login: '$admin' \n Mysql password : --hidden--" 15 55 - + --yesno "Do you confirm ? \n Dump file : '$dumpfile' \n Dump dir : '$mydir' \n Mysql database : '$base' \n Mysql port : '$port' \n Mysql login: '$admin' \n Mysql password : --hidden--" 15 55 + case $? in - 0) echo "Ok, start process...";; - 1) exit;; - 255) exit;; + 0) echo "Ok, start process..." ;; + 1) exit ;; + 255) exit ;; esac fi @@ -167,180 +167,180 @@ then export passwd="-p$passwd" fi export list=" - --ignore-table=$base.llx_abonne - --ignore-table=$base.llx_abonne_extrafields - --ignore-table=$base.llx_abonne_type - --ignore-table=$base.llx_abonnement - --ignore-table=$base.llx_accountingaccount - --ignore-table=$base.llx_accountingsystem - --ignore-table=$base.llx_advanced_extrafields - --ignore-table=$base.llx_advanced_extrafields_options - --ignore-table=$base.llx_advanced_extrafields_values - --ignore-table=$base.llx_agefodd_calendrier - --ignore-table=$base.llx_agefodd_certif_state - --ignore-table=$base.llx_agefodd_certificate_type - --ignore-table=$base.llx_agefodd_contact - --ignore-table=$base.llx_agefodd_convention - --ignore-table=$base.llx_agefodd_convention_stagiaire - --ignore-table=$base.llx_agefodd_cursus - --ignore-table=$base.llx_agefodd_cursus_extrafields - --ignore-table=$base.llx_agefodd_formateur - --ignore-table=$base.llx_agefodd_formateur_category - --ignore-table=$base.llx_agefodd_formateur_category_dict - --ignore-table=$base.llx_agefodd_formateur_training - --ignore-table=$base.llx_agefodd_formateur_type - --ignore-table=$base.llx_agefodd_formation_catalogue - --ignore-table=$base.llx_agefodd_formation_catalogue_extrafields - --ignore-table=$base.llx_agefodd_formation_catalogue_modules - --ignore-table=$base.llx_agefodd_formation_catalogue_type - --ignore-table=$base.llx_agefodd_formation_catalogue_type_bpf - --ignore-table=$base.llx_agefodd_formation_cursus - --ignore-table=$base.llx_agefodd_formation_objectifs_peda - --ignore-table=$base.llx_agefodd_opca - --ignore-table=$base.llx_agefodd_place - --ignore-table=$base.llx_agefodd_reg_interieur - --ignore-table=$base.llx_agefodd_session - --ignore-table=$base.llx_agefodd_session_adminsitu - --ignore-table=$base.llx_agefodd_session_admlevel - --ignore-table=$base.llx_agefodd_session_calendrier - --ignore-table=$base.llx_agefodd_session_commercial - --ignore-table=$base.llx_agefodd_session_contact - --ignore-table=$base.llx_agefodd_session_element - --ignore-table=$base.llx_agefodd_session_extrafields - --ignore-table=$base.llx_agefodd_session_formateur - --ignore-table=$base.llx_agefodd_session_formateur_calendrier - --ignore-table=$base.llx_agefodd_session_stagiaire - --ignore-table=$base.llx_agefodd_session_stagiaire_heures - --ignore-table=$base.llx_agefodd_session_status_type - --ignore-table=$base.llx_agefodd_stagiaire - --ignore-table=$base.llx_agefodd_stagiaire_certif - --ignore-table=$base.llx_agefodd_stagiaire_cursus - --ignore-table=$base.llx_agefodd_stagiaire_extrafields - --ignore-table=$base.llx_agefodd_stagiaire_type - --ignore-table=$base.llx_agefodd_training_admlevel - --ignore-table=$base.llx_askpricesupplier - --ignore-table=$base.llx_askpricesupplier_extrafields - --ignore-table=$base.llx_askpricesupplierdet - --ignore-table=$base.llx_askpricesupplierdet_extrafields - --ignore-table=$base.llx_assetOf - --ignore-table=$base.llx_assetOf_line - --ignore-table=$base.llx_asset_workstation_of - --ignore-table=$base.llx_asset_workstation_product - --ignore-table=$base.llx_asset_workstation_task - --ignore-table=$base.llx_assetof_amounts - --ignore-table=$base.llx_asset_workstation_of - --ignore-table=$base.llx_asset_workstation_of - --ignore-table=$base.llx_asset_workstation_of - --ignore-table=$base.llx_bookkeeping - --ignore-table=$base.llx_bootstrap - --ignore-table=$base.llx_bt_namemap - --ignore-table=$base.llx_bt_speedlimit - --ignore-table=$base.llx_bt_summary - --ignore-table=$base.llx_bt_timestamps - --ignore-table=$base.llx_bt_webseedfiles - --ignore-table=$base.llx_c_civilite - --ignore-table=$base.llx_c_dolicloud_plans - --ignore-table=$base.llx_c_pays - --ignore-table=$base.llx_c_source - --ignore-table=$base.llx_c_ticketsup_category - --ignore-table=$base.llx_c_ticketsup_severity - --ignore-table=$base.llx_c_ticketsup_type - --ignore-table=$base.llx_cabinetmed_c_banques - --ignore-table=$base.llx_cabinetmed_c_examconclusion - --ignore-table=$base.llx_cabinetmed_cons_extrafields - --ignore-table=$base.llx_cabinetmed_diaglec - --ignore-table=$base.llx_cabinetmed_examaut - --ignore-table=$base.llx_cabinetmed_exambio - --ignore-table=$base.llx_cabinetmed_examenprescrit - --ignore-table=$base.llx_cabinetmed_motifcons - --ignore-table=$base.llx_cabinetmed_patient - --ignore-table=$base.llx_cabinetmed_societe - --ignore-table=$base.llx_congespayes - --ignore-table=$base.llx_congespayes_config - --ignore-table=$base.llx_congespayes_events - --ignore-table=$base.llx_congespayes_logs - --ignore-table=$base.llx_congespayes_users - --ignore-table=$base.llx_dolicloud_customers - --ignore-table=$base.llx_dolicloud_stats - --ignore-table=$base.llx_dolicloud_emailstemplates - --ignore-table=$base.llx_dolireport_column - --ignore-table=$base.llx_dolireport_criteria - --ignore-table=$base.llx_dolireport_graph - --ignore-table=$base.llx_dolireport_plot - --ignore-table=$base.llx_dolireport_report - --ignore-table=$base.llx_domain - --ignore-table=$base.llx_ecommerce_category - --ignore-table=$base.llx_ecommerce_commande - --ignore-table=$base.llx_ecommerce_facture - --ignore-table=$base.llx_ecommerce_product - --ignore-table=$base.llx_ecommerce_site - --ignore-table=$base.llx_ecommerce_societe - --ignore-table=$base.llx_ecommerce_socpeople - --ignore-table=$base.llx_element_rang - --ignore-table=$base.llx_element_tag - --ignore-table=$base.llx_eleves - --ignore-table=$base.llx_eleves_extrafields - --ignore-table=$base.llx_entity - --ignore-table=$base.llx_entity_extrafields - --ignore-table=$base.llx_entity_thirdparty - --ignore-table=$base.llx_equipement_factory - --ignore-table=$base.llx_factory - --ignore-table=$base.llx_factory_extrafields - --ignore-table=$base.llx_factorydet - --ignore-table=$base.llx_filemanager_roots - --ignore-table=$base.llx_fournisseur_ca - --ignore-table=$base.llx_google_maps - --ignore-table=$base.llx_lead - --ignore-table=$base.llx_lead_extrafields - --ignore-table=$base.llx_milestone - --ignore-table=$base.llx_milestone - --ignore-table=$base.llx_monitoring_probes - --ignore-table=$base.llx_m - --ignore-table=$base.llx_m_extrafields - --ignore-table=$base.llx_monmodule_abcdef - --ignore-table=$base.llx_notes - --ignore-table=$base.llx_packages - --ignore-table=$base.llx_packages_extrafields - --ignore-table=$base.llx_pos_cash - --ignore-table=$base.llx_pos_control_cash - --ignore-table=$base.llx_pos_facture - --ignore-table=$base.llx_pos_moviments - --ignore-table=$base.llx_pos_ticketdet - --ignore-table=$base.llx_pos_paiement_ticket - --ignore-table=$base.llx_pos_places - --ignore-table=$base.llx_pos_ticket - --ignore-table=$base.llx_printer_ipp - --ignore-table=$base.llx_publi_c_contact_list - --ignore-table=$base.llx_publi_c_dnd_list - --ignore-table=$base.llx_publi_c_method_list - --ignore-table=$base.llx_residence - --ignore-table=$base.llx_residence_building - --ignore-table=$base.llx_residence_building_links - --ignore-table=$base.llx_scaninvoices_filestoimport - --ignore-table=$base.llx_scaninvoices_filestoimport_extrafields - --ignore-table=$base.llx_scaninvoices_settings - --ignore-table=$base.llx_scaninvoices_settings_extrafields - --ignore-table=$base.llx_sellyoursaas_blacklistcontent - --ignore-table=$base.llx_sellyoursaas_blacklistdir - --ignore-table=$base.llx_sellyoursaas_blacklistfrom - --ignore-table=$base.llx_sellyoursaas_blacklistip - --ignore-table=$base.llx_sellyoursaas_blacklistmail - --ignore-table=$base.llx_sellyoursaas_blacklistto - --ignore-table=$base.llx_sellyoursaas_deploymentserver - --ignore-table=$base.llx_sellyoursaas_stats - --ignore-table=$base.llx_sellyoursaas_whitelistip - --ignore-table=$base.llx_societe_rib2 - --ignore-table=$base.llx_sellyoursaas_cancellation - --ignore-table=$base.llx_ticketsup - --ignore-table=$base.llx_ultimatepdf - --ignore-table=$base.llx_update_modules - --ignore-table=$base.llx_ventilation_achat - --ignore-table=$base.tmp_llx_accouting_account - --ignore-table=$base.tmp_llx_product_batch - --ignore-table=$base.tmp_llx_product_batch2 - --ignore-table=$base.tmp_tmp - --ignore-table=$base.tmp_user - " +--ignore-table=$base.llx_abonne +--ignore-table=$base.llx_abonne_extrafields +--ignore-table=$base.llx_abonne_type +--ignore-table=$base.llx_abonnement +--ignore-table=$base.llx_accountingaccount +--ignore-table=$base.llx_accountingsystem +--ignore-table=$base.llx_advanced_extrafields +--ignore-table=$base.llx_advanced_extrafields_options +--ignore-table=$base.llx_advanced_extrafields_values +--ignore-table=$base.llx_agefodd_calendrier +--ignore-table=$base.llx_agefodd_certif_state +--ignore-table=$base.llx_agefodd_certificate_type +--ignore-table=$base.llx_agefodd_contact +--ignore-table=$base.llx_agefodd_convention +--ignore-table=$base.llx_agefodd_convention_stagiaire +--ignore-table=$base.llx_agefodd_cursus +--ignore-table=$base.llx_agefodd_cursus_extrafields +--ignore-table=$base.llx_agefodd_formateur +--ignore-table=$base.llx_agefodd_formateur_category +--ignore-table=$base.llx_agefodd_formateur_category_dict +--ignore-table=$base.llx_agefodd_formateur_training +--ignore-table=$base.llx_agefodd_formateur_type +--ignore-table=$base.llx_agefodd_formation_catalogue +--ignore-table=$base.llx_agefodd_formation_catalogue_extrafields +--ignore-table=$base.llx_agefodd_formation_catalogue_modules +--ignore-table=$base.llx_agefodd_formation_catalogue_type +--ignore-table=$base.llx_agefodd_formation_catalogue_type_bpf +--ignore-table=$base.llx_agefodd_formation_cursus +--ignore-table=$base.llx_agefodd_formation_objectifs_peda +--ignore-table=$base.llx_agefodd_opca +--ignore-table=$base.llx_agefodd_place +--ignore-table=$base.llx_agefodd_reg_interieur +--ignore-table=$base.llx_agefodd_session +--ignore-table=$base.llx_agefodd_session_adminsitu +--ignore-table=$base.llx_agefodd_session_admlevel +--ignore-table=$base.llx_agefodd_session_calendrier +--ignore-table=$base.llx_agefodd_session_commercial +--ignore-table=$base.llx_agefodd_session_contact +--ignore-table=$base.llx_agefodd_session_element +--ignore-table=$base.llx_agefodd_session_extrafields +--ignore-table=$base.llx_agefodd_session_formateur +--ignore-table=$base.llx_agefodd_session_formateur_calendrier +--ignore-table=$base.llx_agefodd_session_stagiaire +--ignore-table=$base.llx_agefodd_session_stagiaire_heures +--ignore-table=$base.llx_agefodd_session_status_type +--ignore-table=$base.llx_agefodd_stagiaire +--ignore-table=$base.llx_agefodd_stagiaire_certif +--ignore-table=$base.llx_agefodd_stagiaire_cursus +--ignore-table=$base.llx_agefodd_stagiaire_extrafields +--ignore-table=$base.llx_agefodd_stagiaire_type +--ignore-table=$base.llx_agefodd_training_admlevel +--ignore-table=$base.llx_askpricesupplier +--ignore-table=$base.llx_askpricesupplier_extrafields +--ignore-table=$base.llx_askpricesupplierdet +--ignore-table=$base.llx_askpricesupplierdet_extrafields +--ignore-table=$base.llx_assetOf +--ignore-table=$base.llx_assetOf_line +--ignore-table=$base.llx_asset_workstation_of +--ignore-table=$base.llx_asset_workstation_product +--ignore-table=$base.llx_asset_workstation_task +--ignore-table=$base.llx_assetof_amounts +--ignore-table=$base.llx_asset_workstation_of +--ignore-table=$base.llx_asset_workstation_of +--ignore-table=$base.llx_asset_workstation_of +--ignore-table=$base.llx_bookkeeping +--ignore-table=$base.llx_bootstrap +--ignore-table=$base.llx_bt_namemap +--ignore-table=$base.llx_bt_speedlimit +--ignore-table=$base.llx_bt_summary +--ignore-table=$base.llx_bt_timestamps +--ignore-table=$base.llx_bt_webseedfiles +--ignore-table=$base.llx_c_civilite +--ignore-table=$base.llx_c_dolicloud_plans +--ignore-table=$base.llx_c_pays +--ignore-table=$base.llx_c_source +--ignore-table=$base.llx_c_ticketsup_category +--ignore-table=$base.llx_c_ticketsup_severity +--ignore-table=$base.llx_c_ticketsup_type +--ignore-table=$base.llx_cabinetmed_c_banques +--ignore-table=$base.llx_cabinetmed_c_examconclusion +--ignore-table=$base.llx_cabinetmed_cons_extrafields +--ignore-table=$base.llx_cabinetmed_diaglec +--ignore-table=$base.llx_cabinetmed_examaut +--ignore-table=$base.llx_cabinetmed_exambio +--ignore-table=$base.llx_cabinetmed_examenprescrit +--ignore-table=$base.llx_cabinetmed_motifcons +--ignore-table=$base.llx_cabinetmed_patient +--ignore-table=$base.llx_cabinetmed_societe +--ignore-table=$base.llx_congespayes +--ignore-table=$base.llx_congespayes_config +--ignore-table=$base.llx_congespayes_events +--ignore-table=$base.llx_congespayes_logs +--ignore-table=$base.llx_congespayes_users +--ignore-table=$base.llx_dolicloud_customers +--ignore-table=$base.llx_dolicloud_stats +--ignore-table=$base.llx_dolicloud_emailstemplates +--ignore-table=$base.llx_dolireport_column +--ignore-table=$base.llx_dolireport_criteria +--ignore-table=$base.llx_dolireport_graph +--ignore-table=$base.llx_dolireport_plot +--ignore-table=$base.llx_dolireport_report +--ignore-table=$base.llx_domain +--ignore-table=$base.llx_ecommerce_category +--ignore-table=$base.llx_ecommerce_commande +--ignore-table=$base.llx_ecommerce_facture +--ignore-table=$base.llx_ecommerce_product +--ignore-table=$base.llx_ecommerce_site +--ignore-table=$base.llx_ecommerce_societe +--ignore-table=$base.llx_ecommerce_socpeople +--ignore-table=$base.llx_element_rang +--ignore-table=$base.llx_element_tag +--ignore-table=$base.llx_eleves +--ignore-table=$base.llx_eleves_extrafields +--ignore-table=$base.llx_entity +--ignore-table=$base.llx_entity_extrafields +--ignore-table=$base.llx_entity_thirdparty +--ignore-table=$base.llx_equipement_factory +--ignore-table=$base.llx_factory +--ignore-table=$base.llx_factory_extrafields +--ignore-table=$base.llx_factorydet +--ignore-table=$base.llx_filemanager_roots +--ignore-table=$base.llx_fournisseur_ca +--ignore-table=$base.llx_google_maps +--ignore-table=$base.llx_lead +--ignore-table=$base.llx_lead_extrafields +--ignore-table=$base.llx_milestone +--ignore-table=$base.llx_milestone +--ignore-table=$base.llx_monitoring_probes +--ignore-table=$base.llx_m +--ignore-table=$base.llx_m_extrafields +--ignore-table=$base.llx_monmodule_abcdef +--ignore-table=$base.llx_notes +--ignore-table=$base.llx_packages +--ignore-table=$base.llx_packages_extrafields +--ignore-table=$base.llx_pos_cash +--ignore-table=$base.llx_pos_control_cash +--ignore-table=$base.llx_pos_facture +--ignore-table=$base.llx_pos_moviments +--ignore-table=$base.llx_pos_ticketdet +--ignore-table=$base.llx_pos_paiement_ticket +--ignore-table=$base.llx_pos_places +--ignore-table=$base.llx_pos_ticket +--ignore-table=$base.llx_printer_ipp +--ignore-table=$base.llx_publi_c_contact_list +--ignore-table=$base.llx_publi_c_dnd_list +--ignore-table=$base.llx_publi_c_method_list +--ignore-table=$base.llx_residence +--ignore-table=$base.llx_residence_building +--ignore-table=$base.llx_residence_building_links +--ignore-table=$base.llx_scaninvoices_filestoimport +--ignore-table=$base.llx_scaninvoices_filestoimport_extrafields +--ignore-table=$base.llx_scaninvoices_settings +--ignore-table=$base.llx_scaninvoices_settings_extrafields +--ignore-table=$base.llx_sellyoursaas_blacklistcontent +--ignore-table=$base.llx_sellyoursaas_blacklistdir +--ignore-table=$base.llx_sellyoursaas_blacklistfrom +--ignore-table=$base.llx_sellyoursaas_blacklistip +--ignore-table=$base.llx_sellyoursaas_blacklistmail +--ignore-table=$base.llx_sellyoursaas_blacklistto +--ignore-table=$base.llx_sellyoursaas_deploymentserver +--ignore-table=$base.llx_sellyoursaas_stats +--ignore-table=$base.llx_sellyoursaas_whitelistip +--ignore-table=$base.llx_societe_rib2 +--ignore-table=$base.llx_sellyoursaas_cancellation +--ignore-table=$base.llx_ticketsup +--ignore-table=$base.llx_ultimatepdf +--ignore-table=$base.llx_update_modules +--ignore-table=$base.llx_ventilation_achat +--ignore-table=$base.tmp_llx_accouting_account +--ignore-table=$base.tmp_llx_product_batch +--ignore-table=$base.tmp_llx_product_batch2 +--ignore-table=$base.tmp_tmp +--ignore-table=$base.tmp_user +" echo "mysqldump -P$port -u$admin -p***** $list $base > $mydir/$dumpfile" mysqldump -P$port -u$admin $passwd $list $base > $mydir/$dumpfile export res=$? diff --git a/dev/setup/git/hooks/pre-commit b/dev/setup/git/hooks/pre-commit index 56a4d4876a6..0bb002bade5 100755 --- a/dev/setup/git/hooks/pre-commit +++ b/dev/setup/git/hooks/pre-commit @@ -1,7 +1,7 @@ #!/bin/sh # To install this precommit file: put this file in your local repo in .git/hooks directory and make it executable. # You may need to set th DIRPHPCS to the path to your phpcs install. -# If phpcs check fail and AUTOFIX is set to 1, then it run phpcbf to fix automaticaly the syntax, and git commit is canceled. +# If phpcs checks fail and AUTOFIX is set to 1, then it run phpcbf to fix automatically the syntax, and git commit is canceled. # If you have a multiprocessor computer, you can add to the option --parallel=xx # When running git commit, it first execute this file checking only modified files, so it is faster than running on all files # To run the fix manually: cd ~/git/dolibarr; phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true "fileordir" @@ -16,9 +16,9 @@ echo "Running precommit hook in .git/hooks/pre-commit" 1>&2; # Determine if a file list is passed if [ "$#" -eq 1 ] then - oIFS=$IFS - IFS=' - ' + oIFS=$IFS + IFS=' + ' SFILES="$1" IFS=$oIFS fi @@ -47,11 +47,11 @@ then # Check Dolibarr standard ${DIRPHPCS}phpcs -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES - + # Check a common standard #${DIRPHPCS}phpcs -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=PSR2 --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES - - result2=$? + + result2=$? if [ "x$result2" != "x0" ] then @@ -59,12 +59,12 @@ then if [ "x$AUTOFIX" != "x0" ] then ${DIRPHPCS}phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES - + #${DIRPHPCS}phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=htdocs/custom/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES - + echo "Found some errors in syntax rules. An automatic fix has been applied. Check it before commit." 1>&2; exit 1 - else + else echo "Found some errors in syntax rules. Fix the error(s) before commit." 1>&2; exit 1 fi diff --git a/dev/tools/fixaltlanguages.sh b/dev/tools/fixaltlanguages.sh index 5ed9f704df9..00a271049ca 100755 --- a/dev/tools/fixaltlanguages.sh +++ b/dev/tools/fixaltlanguages.sh @@ -29,61 +29,61 @@ fi # To fix if [ "x$1" = "xfix" ] then - for dir in `find htdocs/langs/$3* -type d` - do - dirshort=`basename $dir` - - #echo $dirshort - - export aa=`echo $dirshort | nawk -F"_" '{ print $1 }'` - export bb=`echo $dirshort | nawk -F"_" '{ print $2 }'` - aaupper=`echo $dirshort | nawk -F"_" '{ print toupper($1) }'` - if [ $aaupper = "EN" ] - then - aaupper="US" - fi - if [ $aaupper = "EL" ] - then - aaupper="GR" - fi - if [ $bb = "EG" ] - then - aaupper="SA" - fi - if [ $bb = "IQ" ] - then - aaupper="SA" - fi + for dir in `find htdocs/langs/$3* -type d` + do + dirshort=`basename $dir` - bblower=`echo $dirshort | nawk -F"_" '{ print tolower($2) }'` + #echo $dirshort + + export aa=`echo $dirshort | nawk -F"_" '{ print $1 }'` + export bb=`echo $dirshort | nawk -F"_" '{ print $2 }'` + aaupper=`echo $dirshort | nawk -F"_" '{ print toupper($1) }'` + if [ $aaupper = "EN" ] + then + aaupper="US" + fi + if [ $aaupper = "EL" ] + then + aaupper="GR" + fi + if [ $bb = "EG" ] + then + aaupper="SA" + fi + if [ $bb = "IQ" ] + then + aaupper="SA" + fi + + bblower=`echo $dirshort | nawk -F"_" '{ print tolower($2) }'` echo "***** Process language "$aa"_"$bb - if [ "$aa" != "$bblower" -a "$dirshort" != "en_US" ] - then - reflang="htdocs/langs/"$aa"_"$aaupper - echo $reflang" "$aa"_"$bb != $aa"_"$aaupper - - # If $reflang is a main language to use to sanitize the alternative file - if [ -d $reflang ] - then - if [ $aa"_"$bb != $aa"_"$aaupper ] - then - echo "***** Search original into "$reflang - echo $dirshort is an alternative language of $reflang - echo ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2 - ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2 - for fic in `ls htdocs/langs/${aa}_${bb}/*.delta`; do f=`echo $fic | sed -e 's/\.delta//'`; echo $f; mv $f.delta $f; done - for fic in `ls htdocs/langs/${aa}_${bb}/*.lang`; - do f=`cat $fic | wc -l`; - #echo $f lines into file $fic; - if [ $f = 1 ] - then - echo Only one line remainging into file $fic, we delete it; - rm $fic - fi; - done - fi - fi - fi - done; + if [ "$aa" != "$bblower" -a "$dirshort" != "en_US" ] + then + reflang="htdocs/langs/"$aa"_"$aaupper + echo $reflang" "$aa"_"$bb != $aa"_"$aaupper + + # If $reflang is a main language to use to sanitize the alternative file + if [ -d $reflang ] + then + if [ $aa"_"$bb != $aa"_"$aaupper ] + then + echo "***** Search original into "$reflang + echo $dirshort is an alternative language of $reflang + echo ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2 + ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2 + for fic in `ls htdocs/langs/${aa}_${bb}/*.delta`; do f=`echo $fic | sed -e 's/\.delta//'`; echo $f; mv $f.delta $f; done + for fic in `ls htdocs/langs/${aa}_${bb}/*.lang`; + do f=`cat $fic | wc -l`; + #echo $f lines into file $fic; + if [ $f = 1 ] + then + echo "Only one line remaining into file '$fic', we delete it"; + rm $fic + fi; + done + fi + fi + fi + done; fi diff --git a/dev/tools/fixdosfiles.sh b/dev/tools/fixdosfiles.sh index 52db065db03..92d9a82bca9 100755 --- a/dev/tools/fixdosfiles.sh +++ b/dev/tools/fixdosfiles.sh @@ -18,7 +18,7 @@ fi if [ "x$1" = "xlist" ] then find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep CRLF -# find . \( -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" \) -exec file "{}" + | grep -v "CRLF" | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep -v 'htdocs\/includes' | grep CRLF + # find . \( -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" \) -exec file "{}" + | grep -v "CRLF" | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep -v 'htdocs\/includes' | grep CRLF fi # To convert diff --git a/dev/tools/fixduplicatelangkey.sh b/dev/tools/fixduplicatelangkey.sh index 2090f8a3504..f792a25df4d 100755 --- a/dev/tools/fixduplicatelangkey.sh +++ b/dev/tools/fixduplicatelangkey.sh @@ -7,7 +7,7 @@ # Syntax if [ "x$1" != "xlist" -a "x$1" != "xfix" ] then - echo "Detect duplicate translation keys inside a file (there is no cross file check)." + echo "Detect duplicate translation keys inside a file (there is no cross file check)." echo "Usage: detectduplicatelangkey.sh (list|fix)" fi @@ -17,19 +17,19 @@ then echo "Search duplicate keys into en_US lang files (there is no cross file check)" for file in `find htdocs/langs/en_US -name *.lang -type f` do - dupes=$( - sed "s/^\s*//" "$file" | # Remove any leading whitespace - sed "s/\s*\=/=/" | # Remove any whitespace before = - grep -Po "(^.*?)=" | # Non greedeely match everything before = - sed "s/\=//" | # Remove trailing = so we get the key - sort | uniq -d # Find duplicates - ) - - if [ -n "$dupes" ] - then - echo "Duplicates found in $file" - echo "$dupes" - fi + dupes=$( + sed "s/^\s*//" "$file" | # Remove any leading whitespace + sed "s/\s*\=/=/" | # Remove any whitespace before = + grep -Po "(^.*?)=" | # Non greedeely match everything before = + sed "s/\=//" | # Remove trailing = so we get the key + sort | uniq -d # Find duplicates + ) + + if [ -n "$dupes" ] + then + echo "Duplicates found in $file" + echo "$dupes" + fi done fi diff --git a/dev/tools/fixduplicatelanglines.sh b/dev/tools/fixduplicatelanglines.sh index 0c0e2eecb4b..8cecb3752ea 100755 --- a/dev/tools/fixduplicatelanglines.sh +++ b/dev/tools/fixduplicatelanglines.sh @@ -17,22 +17,22 @@ fi if [ "x$1" = "xlist" ] then echo "Search duplicate line for lang en_US" - for file in `find htdocs/langs/en_US -type f -name *.lang` - do - if [ `sort "$file" | grep -v '^$' | uniq -d | wc -l` -gt 0 ] - then - echo "***** $file" - sort "$file" | grep -v '^$' | uniq -d - fi - done + for file in `find htdocs/langs/en_US -type f -name *.lang` + do + if [ `sort "$file" | grep -v '^$' | uniq -d | wc -l` -gt 0 ] + then + echo "***** $file" + sort "$file" | grep -v '^$' | uniq -d + fi + done fi # To fix if [ "x$1" = "xfix" ] then echo "Fix duplicate line for lang en_US" - for file in `find htdocs/langs/en_US -type f -name *.lang` - do - awk -i inplace ' !x[$0]++' "$file" - done; + for file in `find htdocs/langs/en_US -type f -name *.lang` + do + awk -i inplace ' !x[$0]++' "$file" + done; fi diff --git a/dev/tools/fixhasRights.sh b/dev/tools/fixhasRights.sh index 46a015a7c2b..d25e6abd0b0 100755 --- a/dev/tools/fixhasRights.sh +++ b/dev/tools/fixhasRights.sh @@ -4,17 +4,17 @@ # for f in $(grep -l -e 'user->rights' -R); do - sed -i -r 's/!empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\) *\? *\$user->rights->\1->\2->\3 *: *0;/$user->hasRight("\1", "\2", "\3");/' $f - sed -i -r 's/ empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\) *\? *0 *: *\$user->rights->\1->\2->\3;/ !$user->hasRight("\1", "\2", "\3");/' $f - sed -i -r 's/!empty\((DolibarrApiAccess::)\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\)/\1$user->hasRight("\2", "\3", "\4")/g' $f - sed -i -r 's/!empty\((DolibarrApiAccess::)\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)\)/\1$user->hasRight("\2", "\3")/g' $f - sed -i -r 's/empty\((DolibarrApiAccess::)\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\)/!\1$user->hasRight("\2", "\3", "\4")/g' $f - sed -i -r 's/empty\((DolibarrApiAccess::)\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)\)/!\1$user->hasRight("\2", "\3")/g' $f - sed -i -r 's/!empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\)/$user->hasRight("\1", "\2", "\3")/g' $f - sed -i -r 's/!empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)\)/$user->hasRight("\1", "\2")/g' $f - sed -i -r 's/empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\)/!$user->hasRight("\1", "\2", "\3")/g' $f - sed -i -r 's/empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)\)/!$user->hasRight("\1", "\2")/g' $f - sed -i -r 's/\$user->rights\??->([_a-z0-9]+)\??->([_a-z0-9]+)\??->([_a-z0-9]+)/$user->hasRight("\1", "\2", "\3")/g' $f - sed -i -r 's/\$user->rights\??->([_a-z0-9]+)\??->([_a-z0-9]+)/$user->hasRight("\1", "\2")/g' $f + sed -i -r 's/!empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\) *\? *\$user->rights->\1->\2->\3 *: *0;/$user->hasRight("\1", "\2", "\3");/' $f + sed -i -r 's/ empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\) *\? *0 *: *\$user->rights->\1->\2->\3;/ !$user->hasRight("\1", "\2", "\3");/' $f + sed -i -r 's/!empty\((DolibarrApiAccess::)\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\)/\1$user->hasRight("\2", "\3", "\4")/g' $f + sed -i -r 's/!empty\((DolibarrApiAccess::)\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)\)/\1$user->hasRight("\2", "\3")/g' $f + sed -i -r 's/empty\((DolibarrApiAccess::)\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\)/!\1$user->hasRight("\2", "\3", "\4")/g' $f + sed -i -r 's/empty\((DolibarrApiAccess::)\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)\)/!\1$user->hasRight("\2", "\3")/g' $f + sed -i -r 's/!empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\)/$user->hasRight("\1", "\2", "\3")/g' $f + sed -i -r 's/!empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)\)/$user->hasRight("\1", "\2")/g' $f + sed -i -r 's/empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)->([_a-z0-9]+)\)/!$user->hasRight("\1", "\2", "\3")/g' $f + sed -i -r 's/empty\(\$user->rights->([_a-z0-9]+)->([_a-z0-9]+)\)/!$user->hasRight("\1", "\2")/g' $f + sed -i -r 's/\$user->rights\??->([_a-z0-9]+)\??->([_a-z0-9]+)\??->([_a-z0-9]+)/$user->hasRight("\1", "\2", "\3")/g' $f + sed -i -r 's/\$user->rights\??->([_a-z0-9]+)\??->([_a-z0-9]+)/$user->hasRight("\1", "\2")/g' $f done diff --git a/dev/tools/fixperms.sh b/dev/tools/fixperms.sh index 6b11f25112b..e3d7fe3cc69 100755 --- a/dev/tools/fixperms.sh +++ b/dev/tools/fixperms.sh @@ -17,14 +17,14 @@ fi # To detect if [ "x$1" = "xlist" ] then - echo Feature not yet available + echo Feature not yet available fi # To convert if [ "x$1" = "xfix" ] then - find ./htdocs -type f -iname "*.php" -exec chmod a-x {} \; - find ./htdocs/install/ -type d -exec chmod ug+rw {} \; + find ./htdocs -type f -iname "*.php" -exec chmod a-x {} \; + find ./htdocs/install/ -type d -exec chmod ug+rw {} \; chmod a+x ./scripts/*/*.php chmod a+x ./scripts/*/*.sh chmod g-w ./scripts/*/*.php diff --git a/dev/tools/fixsnakeCaseToCamelCase.sh b/dev/tools/fixsnakeCaseToCamelCase.sh index 9196c130755..0cfbf256672 100755 --- a/dev/tools/fixsnakeCaseToCamelCase.sh +++ b/dev/tools/fixsnakeCaseToCamelCase.sh @@ -3,28 +3,28 @@ ## Need "rpl" package RPL_INSTALLED=$(dpkg -s rpl) if [[ -z ${RPL_INSTALLED} ]]; then - echo "This bash need rpl command, you can install it with: sudo apt install rpl" + echo "This bash need rpl command, you can install it with: sudo apt install rpl" fi DIR_HTDOCS=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../htdocs" >/dev/null && pwd ) PATTERN="" if [[ -f $1 ]]; then - TFile=("$1") # specific file + TFile=("$1") # specific file elif [[ -n $1 ]]; then - PATTERN=$1 # name of a particular file or pattern (ex: societe.class.php) + PATTERN=$1 # name of a particular file or pattern (ex: societe.class.php) else - PATTERN="*.class.php" # *.lib.php + PATTERN="*.class.php" # *.lib.php fi if [[ -n ${PATTERN} ]]; then - TCLASSFILE=$(find "${DIR_HTDOCS}" -name "${PATTERN}" | grep -v "/custom/" | grep -v "/includes/" | grep -v -F -f "${DIR_HTDOCS}/../.gitignore") - TFile=() - I=0 - for f in ${TCLASSFILE}; do - TFile[${I}]="${f}" - ((I++)) - done + TCLASSFILE=$(find "${DIR_HTDOCS}" -name "${PATTERN}" | grep -v "/custom/" | grep -v "/includes/" | grep -v -F -f "${DIR_HTDOCS}/../.gitignore") + TFile=() + I=0 + for f in ${TCLASSFILE}; do + TFile[${I}]="${f}" + ((I++)) + done fi @@ -32,99 +32,99 @@ REGEX_FNC_W='^([[:blank:]]*)(public|private|protected)?[ \t]*(static)?[ \t]*[^\$ INDENT=" " for f in ${TFile[@]}; do -# echo ${f} + # echo ${f} - IFS=$'\n' - TLine=($(cat "${f}" | grep -E "${REGEX_FNC_W}")) + IFS=$'\n' + TLine=($(cat "${f}" | grep -E "${REGEX_FNC_W}")) - for LINE in ${TLine[@]}; do + for LINE in ${TLine[@]}; do - if [[ ${LINE} =~ ^${REGEX_FNC_W}$ ]]; then - FIRST_INDENT=${BASH_REMATCH[1]} # seem not work - FNC_TYPE=${BASH_REMATCH[2]} - STATIC=${BASH_REMATCH[3]} - FNC_NAME=${BASH_REMATCH[4]} - PARAMETERS_ORIGIN=${BASH_REMATCH[5]} - BRACKET_END=${BASH_REMATCH[6]} + if [[ ${LINE} =~ ^${REGEX_FNC_W}$ ]]; then + FIRST_INDENT=${BASH_REMATCH[1]} # seem not work + FNC_TYPE=${BASH_REMATCH[2]} + STATIC=${BASH_REMATCH[3]} + FNC_NAME=${BASH_REMATCH[4]} + PARAMETERS_ORIGIN=${BASH_REMATCH[5]} + BRACKET_END=${BASH_REMATCH[6]} - if [[ ${LINE} =~ ^([[:blank:]]*) ]]; then # but this seems work to get indentation - FIRST_INDENT=${BASH_REMATCH[1]} - fi + if [[ ${LINE} =~ ^([[:blank:]]*) ]]; then # but this seems work to get indentation + FIRST_INDENT=${BASH_REMATCH[1]} + fi - [[ ${FNC_NAME} =~ ^__ ]] && continue # skip magic function + [[ ${FNC_NAME} =~ ^__ ]] && continue # skip magic function - CAMEL_CASE=$(echo "${FNC_NAME}" | sed -r 's/(_)([a-zA-Z0-9])/\U\2/g') - [[ ${CAMEL_CASE} = ${FNC_NAME} ]] && continue # skip if no difference + CAMEL_CASE=$(echo "${FNC_NAME}" | sed -r 's/(_)([a-zA-Z0-9])/\U\2/g') + [[ ${CAMEL_CASE} = ${FNC_NAME} ]] && continue # skip if no difference -#echo A: ${#FIRST_INDENT} -#printf "${FIRST_INDENT}TEST INDENT\n" -#echo B: ${FNC_TYPE} -#echo C: ${STATIC} -#echo D: ${FNC_NAME} -#echo D: ${CAMEL_CASE} -#echo E: ${PARAMETERS_ORIGIN} -#echo F: ${BRACKET_END} -#exit + #echo A: ${#FIRST_INDENT} + #printf "${FIRST_INDENT}TEST INDENT\n" + #echo B: ${FNC_TYPE} + #echo C: ${STATIC} + #echo D: ${FNC_NAME} + #echo D: ${CAMEL_CASE} + #echo E: ${PARAMETERS_ORIGIN} + #echo F: ${BRACKET_END} + #exit - [[ -n $(cat "${f}" | grep -i "function[[:blank:]]*${CAMEL_CASE}") ]] && continue # skip if already exists + [[ -n $(cat "${f}" | grep -i "function[[:blank:]]*${CAMEL_CASE}") ]] && continue # skip if already exists - TCommentLine=() - J=1 - while :; do - COMMENT=$(cat ${f} | grep -B ${J} ${LINE/\$/\\$} | head -n1 | grep -P '^[\t\ ]*(/\*\*|\*[^/]?|\*/)') - if [[ -n ${COMMENT} ]]; then - TCommentLine[${J}]="${COMMENT}" - ((J++)) - else - break - fi - done + TCommentLine=() + J=1 + while :; do + COMMENT=$(cat ${f} | grep -B ${J} ${LINE/\$/\\$} | head -n1 | grep -P '^[\t\ ]*(/\*\*|\*[^/]?|\*/)') + if [[ -n ${COMMENT} ]]; then + TCommentLine[${J}]="${COMMENT}" + ((J++)) + else + break + fi + done - COMMENT_ORIGIN="" - COMMENT_ORIGIN_WITH_DEPRECATED="" - COMMENT_DUPLICATE="" - if [[ ${#TCommentLine[@]} -gt 0 ]]; then - for (( idx=${#TCommentLine[@]} ; idx>0 ; idx-- )) ; do - COMMENT_ORIGIN="${COMMENT_ORIGIN}\n${TCommentLine[idx]}" - done + COMMENT_ORIGIN="" + COMMENT_ORIGIN_WITH_DEPRECATED="" + COMMENT_DUPLICATE="" + if [[ ${#TCommentLine[@]} -gt 0 ]]; then + for (( idx=${#TCommentLine[@]} ; idx>0 ; idx-- )) ; do + COMMENT_ORIGIN="${COMMENT_ORIGIN}\n${TCommentLine[idx]}" + done - COMMENT_DUPLICATE=${COMMENT_ORIGIN} + COMMENT_DUPLICATE=${COMMENT_ORIGIN} - COMMENT_ORIGIN_WITH_DEPRECATED=$(echo "${COMMENT_ORIGIN%?} @deprecated\n${FIRST_INDENT} * @see ${CAMEL_CASE}\n${FIRST_INDENT} */") - fi + COMMENT_ORIGIN_WITH_DEPRECATED=$(echo "${COMMENT_ORIGIN%?} @deprecated\n${FIRST_INDENT} * @see ${CAMEL_CASE}\n${FIRST_INDENT} */") + fi - PARAMETERS=${PARAMETERS_ORIGIN} - TParam=() - I=0 - while [[ ${PARAMETERS} =~ (\$[a-zA-Z0-9\_\-]+) ]]; do - TParam[${I}]=${BASH_REMATCH[1]} - PARAMETERS=${PARAMETERS#*"${BASH_REMATCH[1]}"} - ((I++)) - done + PARAMETERS=${PARAMETERS_ORIGIN} + TParam=() + I=0 + while [[ ${PARAMETERS} =~ (\$[a-zA-Z0-9\_\-]+) ]]; do + TParam[${I}]=${BASH_REMATCH[1]} + PARAMETERS=${PARAMETERS#*"${BASH_REMATCH[1]}"} + ((I++)) + done - PARAMS_STR=$(printf ", %s" "${TParam[@]}") - PARAMS_STR=${PARAMS_STR:2} + PARAMS_STR=$(printf ", %s" "${TParam[@]}") + PARAMS_STR=${PARAMS_STR:2} - REPLACE=${LINE} - [[ -z ${BRACKET_END} ]] && REPLACE="${LINE}\n${FIRST_INDENT}{\n${FIRST_INDENT}${INDENT}" || REPLACE="${LINE}\n${FIRST_INDENT}${INDENT}" - [[ -n ${STATIC} ]] && REPLACE="${REPLACE}return self::" || REPLACE="${REPLACE}return \$this->" - REPLACE="${REPLACE}${CAMEL_CASE}(${PARAMS_STR});\n${FIRST_INDENT}}\n\n" - REPLACE="${REPLACE}${FIRST_INDENT}${COMMENT_ORIGIN}\n${FIRST_INDENT}" - [[ -n ${STATIC} ]] && REPLACE="${REPLACE}${STATIC} " - [[ -n ${FNC_TYPE} ]] && REPLACE="${REPLACE}${FNC_TYPE} " - REPLACE="${REPLACE}function ${CAMEL_CASE}(${PARAMETERS_ORIGIN})" - [[ -n ${BRACKET_END} ]] && REPLACE="${REPLACE}\n${FIRST_INDENT}{" + REPLACE=${LINE} + [[ -z ${BRACKET_END} ]] && REPLACE="${LINE}\n${FIRST_INDENT}{\n${FIRST_INDENT}${INDENT}" || REPLACE="${LINE}\n${FIRST_INDENT}${INDENT}" + [[ -n ${STATIC} ]] && REPLACE="${REPLACE}return self::" || REPLACE="${REPLACE}return \$this->" + REPLACE="${REPLACE}${CAMEL_CASE}(${PARAMS_STR});\n${FIRST_INDENT}}\n\n" + REPLACE="${REPLACE}${FIRST_INDENT}${COMMENT_ORIGIN}\n${FIRST_INDENT}" + [[ -n ${STATIC} ]] && REPLACE="${REPLACE}${STATIC} " + [[ -n ${FNC_TYPE} ]] && REPLACE="${REPLACE}${FNC_TYPE} " + REPLACE="${REPLACE}function ${CAMEL_CASE}(${PARAMETERS_ORIGIN})" + [[ -n ${BRACKET_END} ]] && REPLACE="${REPLACE}\n${FIRST_INDENT}{" - echo " ${FNC_NAME} -> ${CAMEL_CASE}" + echo " ${FNC_NAME} -> ${CAMEL_CASE}" - if [[ -n ${COMMENT_ORIGIN_WITH_DEPRECATED} ]]; then - rpl -e --quiet "${COMMENT_ORIGIN}" ${COMMENT_ORIGIN_WITH_DEPRECATED} "${f}" - fi - rpl -e --quiet "${LINE}" ${REPLACE} "${f}" + if [[ -n ${COMMENT_ORIGIN_WITH_DEPRECATED} ]]; then + rpl -e --quiet "${COMMENT_ORIGIN}" ${COMMENT_ORIGIN_WITH_DEPRECATED} "${f}" + fi + rpl -e --quiet "${LINE}" ${REPLACE} "${f}" - fi + fi - done + done done diff --git a/dev/tools/fixutf8bomfiles.sh b/dev/tools/fixutf8bomfiles.sh index bda503d28ec..3d0d7975806 100755 --- a/dev/tools/fixutf8bomfiles.sh +++ b/dev/tools/fixutf8bomfiles.sh @@ -12,7 +12,7 @@ # Syntax if [ "x$1" != "xlist" -a "x$1" != "xfix" ] then - echo "Detect and fix bad UTF8 encoded files (UTF8 must not use BOM char)" + echo "Detect and fix bad UTF8 encoded files (UTF8 must not use BOM char)" echo "Usage: fixutf8bomfiles.sh (list|fix) [addincludes]" fi diff --git a/dev/tools/github_authors_and_commits_peryear.sh b/dev/tools/github_authors_and_commits_peryear.sh index 9b6d299601e..cbc20503151 100755 --- a/dev/tools/github_authors_and_commits_peryear.sh +++ b/dev/tools/github_authors_and_commits_peryear.sh @@ -3,7 +3,7 @@ # Count number of different contributors and number of commits for a given year. # Can be used for statistics (for example to generate the inforgraphy of the year) # - + if [ "x$1" = "x" ]; then echo "Usage: $0 YEARSTART [YEAREND]" exit diff --git a/dev/tools/github_commits_perversion.sh b/dev/tools/github_commits_perversion.sh index f0fb2a90e5c..13fcc43936b 100755 --- a/dev/tools/github_commits_perversion.sh +++ b/dev/tools/github_commits_perversion.sh @@ -21,31 +21,31 @@ cd /tmp/git/dolibarr firstline=1 for i in "${Releases[@]}" do - if [ $firstline -eq 1 ]; then - firstline=0 - continue - fi - - #echo "=== Version $i (counter $counter):" - echo "=== Version $i (counter $counter):" - echo "Get common commit ID between origin/${Releases[counter]} and origin/${Releases[counter+1]}" - echo "git merge-base origin/${Releases[counter]} origin/${Releases[counter+1]}" - commitidcommon=`git merge-base origin/${Releases[counter]} origin/${Releases[counter+1]}` - echo "Found commitid=$commitidcommon" - - echo "Checkout into version $i" - git checkout $i - #git shortlog -s -n --after=YYYY-MM-DD --before=YYYY-MM-DD | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion.txt - git shortlog -s -n $commitidcommon.. | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion.txt - #cat /tmp/github_commits_perversion.txt - echo "Total for version $i:" - echo -n "- Nb of commits: " - git log $commitidcommon.. --pretty=oneline | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion2.txt - cat /tmp/github_commits_perversion2.txt | wc -l - echo -n "- Nb of different authors: " - awk ' { print $2 } ' < /tmp/github_commits_perversion.txt | sort -u | wc -l - echo "=======================" - echo - let "counter +=1" + if [ $firstline -eq 1 ]; then + firstline=0 + continue + fi + + #echo "=== Version $i (counter $counter):" + echo "=== Version $i (counter $counter):" + echo "Get common commit ID between origin/${Releases[counter]} and origin/${Releases[counter+1]}" + echo "git merge-base origin/${Releases[counter]} origin/${Releases[counter+1]}" + commitidcommon=`git merge-base origin/${Releases[counter]} origin/${Releases[counter+1]}` + echo "Found commitid=$commitidcommon" + + echo "Checkout into version $i" + git checkout $i + #git shortlog -s -n --after=YYYY-MM-DD --before=YYYY-MM-DD | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion.txt + git shortlog -s -n $commitidcommon.. | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion.txt + #cat /tmp/github_commits_perversion.txt + echo "Total for version $i:" + echo -n "- Nb of commits: " + git log $commitidcommon.. --pretty=oneline | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion2.txt + cat /tmp/github_commits_perversion2.txt | wc -l + echo -n "- Nb of different authors: " + awk ' { print $2 } ' < /tmp/github_commits_perversion.txt | sort -u | wc -l + echo "=======================" + echo + let "counter +=1" done diff --git a/dev/tools/make_sprite.sh b/dev/tools/make_sprite.sh index 41a280fb860..0fb433025d8 100755 --- a/dev/tools/make_sprite.sh +++ b/dev/tools/make_sprite.sh @@ -35,20 +35,20 @@ counter=0; offset=0; for file in $path*$ext do - width=`identify -format "%[fx:w]" "$file"`; - height=`identify -format "%[fx:h]" "$file"`; - idname=`basename "$file" $ext`; - clean=${idname// /-} - echo -e ".$classname.$clean {" >> $css; - echo -e "\tbackground-position:0 -${offset}px;" >> $css; - echo -e "\twidth: ${width}px;" >> $css; - echo -e "\theight: ${height}px;\n}" >> $css; + width=`identify -format "%[fx:w]" "$file"`; + height=`identify -format "%[fx:h]" "$file"`; + idname=`basename "$file" $ext`; + clean=${idname// /-} + echo -e ".$classname.$clean {" >> $css; + echo -e "\tbackground-position:0 -${offset}px;" >> $css; + echo -e "\twidth: ${width}px;" >> $css; + echo -e "\theight: ${height}px;\n}" >> $css; - echo -e "
\n" >> $html; + echo -e "\n" >> $html; - let offset+=$height; - let counter+=1; - echo -e "\t#$counter done"; + let offset+=$height; + let counter+=1; + echo -e "\t#$counter done"; done echo -e "