2015年1月6日 星期二

Redmine - Fixed for Large SVN Repository



How to:
    Turn off "Autofetch commits" in Settings and add a cron the runs fetch commit periodically as follow.
  rake -f /opt/bitnami/apps/redmine/htdocs/Rakefile RAILS_ENV=production redmine:fetch_changesets




Steps under bitnami redmine:

  1. Go to Administrator->Settings->Repositories page, unchecked "Fetch commits automatically" item
  2. Run "crontab -e" in the linux console, then add following
    1. */5 * * * * syncRepo.sh
  3. Create a shell script syncRepo.sh with the following content
#!/bin/bash

PATH="/opt/bitnami/perl/bin:/opt/bitnami/git/bin:/opt/bitnami/sqlite/bin:/opt/bitnami/ruby/bin:/opt/bitnami/subversion/bin:/opt/bitnami/php/bin:/opt/bitnami/mysql/bin:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:$PATH"

NOW_DATE=$(date +"%m%d%Y")
NOW_TIME=$(date +"%H%M")
LOGDIR=/home/bitnami/logs
LOGFILE="syncRepo.$NOW_DATE.log"

NAME=`basename $0`
RUNNING_PROC_ID=$(pgrep -f "bash.*$(basename $0)")

if [ "$RUNNING_PROC_ID" != "$$" ]; then
        echo "$NOW_DATE-$NOW_TIME :: $NAME($$) still works! Exit Now!!!" >> $LOGDIR/$LOGFILE
        echo "Running Proc ID:" >> $LOGDIR/$LOGFILE
        echo "$RUNNING_PROC_ID" >> $LOGDIR/$LOGFILE
        exit
fi

echo "$NOW_DATE-$NOW_TIME :: $NAME sync start at $(date)" >> $LOGDIR/$LOGFILE
mkdir -p $LOGDIR
cd /opt/bitnami/apps/redmine/htdocs/
nice -n 19 rake -f /opt/bitnami/apps/redmine/htdocs/Rakefile RAILS_ENV=production redmine:fetch_changesets >> $LOGDIR/$LOGFILE 2>&1
echo "$NOW_DATE-$NOW_TIME :: $NAME sync end at $(date)" >> $LOGDIR/$LOGFILE






Reference : http://www.redmine.org/boards/2/topics/44076
Reference : http://www.redmine.org/projects/redmine/wiki/FAQ#I-cant-browse-my-svn-repository-through-redmine




2014年12月31日 星期三

[FW]linux - bash script environment variables

Reference:https://sites.google.com/site/tiger2000/home

$BASH_ENV absolute path of startup file
$CDPATH directories searched by cd
$FCEDIT absolute path of history editor
$HISTCMD the history number of the current command
$HISFILE absolute path of history file
$HISTSIZE number of remembered commands
$HOME login directory
$IFS token delimiters
$LINENO current line number in shell script
$LINES terminal height
$MAIL  absolute path of mailbox
$MAILCHECK number of seconds to check mail
$OLDPWD absolute path of previous directory
$OPTARG option set by getopt
$OPTIND option's ordinal position set by getopt
$OSTYPE the OS on which bash is executing
$PATH command search path
$PPID  process ID of parent
$PS1  primary prompt
$PS2 secondary prompt
$PWD absolute path of current directory
$RANDOM random integer
$REPLY default variable for read
$SECONDS number of seconds since shell started
$SHELL absolute pathname of preferred shell
$TMOUT seconds to log out after lack of use
$UID user ID of the current user
$$ process ID of current shell
$? exit status of most recent statement
$# 參數的數目
$* 代表所有參數
$! PID of the most recently started backgroup job

2014年12月30日 星期二

[FW] Linux - shell script - detect multiple running instances of it self


Reference: http://giantdorks.org/alain/make-a-bash-script-quit-if-it-detects-multiple-running-instances-of-itself/

#!/bin/bash
if [ "$(pgrep -x $(basename $0))" != "$$" ]; then
 echo "Error: another instance of $(basename $0) is already running"
 exit 1
fi

Redmie - Useful plugin



  1. redmine dashboard
    1. Info: http://www.redmine.org/plugins/redmine-dashboard
    2. Steps
      1. cd /opt/bitnami/apps/redmine/htdocs/plugins
      2. git clone https://github.com/jgraichen/redmine_dashboard.git
      3. bundle install
  2. redmine default assign
    1. Info: https://github.com/giddie/redmine_default_assign
    2. Steps
      1. cd /opt/bitnami/apps/redmine/htdocs/plugins
      2. git clone https://github.com/giddie/redmine_default_assign.git
      3. rake db:migrate_plugins RAILS_ENV=production


2014年5月28日 星期三

VirtualBox - Waiting for network configuration issue (Missing eth0)


  • if MAC address changed
    • Remove /etc/udev/rules.d/70-persistent-net.rules file to make sure the new adapter to be eth0;
    • Or update the /etc/network/interfaces for proper configuration for the new adapter (it maybe eth1, eth2 or ...)

2014年5月20日 星期二

[FW] Using gzip and gunzip with mysql to import/export backups


Exporting:
mysqldump -u user -p database | gzip > database.sql.gz
Importing:
gunzip < database.sql.gz | mysql -u user -p database

refer: http://failshell.io/mysql/using-gzip-and-gunzip-with-mysql-to-importexport-backups/

2014年5月19日 星期一

Mount cifs on Ubuntu Server (Microsoft Windows Shares)

1. sudo apt-get install cifs-utils
2. Temporary
2.1. mount -t cifs //XXX/XXX -o username=XXX,password=xxx /media/mnt
3. Permanent (for user MyAccount which uid is 1000)
3.1. Add a file .smbcredentials under /home/MyAccount with following informaiton
       username=XXX
       password=xxx
3.2 Add following into /etc/fstab
      //XXX/XXX /media/mnt cif uid=1000,credentials=/home/MyAccount/.smbcredentials 0 0
3.3. mount -a

refer: https://wiki.ubuntu.com/MountWindowsSharesPermanently