$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 |
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月31日 星期三
[FW]linux - bash script environment variables
Reference:https://sites.google.com/site/tiger2000/home
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
- redmine dashboard
- Info: http://www.redmine.org/plugins/redmine-dashboard
- Steps
- cd /opt/bitnami/apps/redmine/htdocs/plugins
- git clone https://github.com/jgraichen/redmine_dashboard.git
- bundle install
- redmine default assign
- Info: https://github.com/giddie/redmine_default_assign
- Steps
- cd /opt/bitnami/apps/redmine/htdocs/plugins
- git clone https://github.com/giddie/redmine_default_assign.git
- 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
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
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
Update timezone on Ubuntu Server
1. Check Timezone
$ cat /etc/timezone
Etc/UTC
2. sudo dpkg-reconfigure tzdata
select Asia
select Taipei
Refer: http://www.christopherirish.com/2012/03/21/how-to-set-the-timezone-on-ubuntu-server/
2014年5月14日 星期三
Redmine - Implementation
- System installation
- Basic installation
- standard installation
- Ubuntu Linux(or MS Windows)
- Apache
- MySQL (or Postgre SQL)
- Redmine
- Ruby & Rails
- bitnami installation
- packed installer
- Virtual Machine (*)
- VMWare and VirtualBox are all workable.
- Email setup
- Modify configuration.yml under /opt/bitnami/apps/redmine/htdocs/config
- Fill up the SMTP information (our SMTP server or Email)
- Subversion integration
- Link the exist repository
- Link between Revision and Issue
- Standard link
- Go to specified revision under Repository page
- Add the Issue id releated.
- Subversion message log
- #XXX will be translated to a link refer to the Issud ID XXX
- Issue comment log
- rXXX will be translated to a link refer to the Revision ID XXX.
- System backup/restore
- Backup items
- Redmine database
- For MySQL:
- mysqldump -u root -p XXX bitnami_redmine > sqldump.sql
- Attached files
- rsync -a /opt/bitnami/apps/redmine/htdocs/files /mnt/storage/redmine/files
- Work Flow
- Issue reporting flow
- Bug fix flow
- Reporter creates an issue with “New” state and assign to TaskOwner
- TaskOwner assigns the issue to the Developer (TaskOwner may be the issue owner).
- Developer changes the state to “In Progress” when handling.
- Developer changes the state to “Resolved” or “Rejected” then assigned to Verifier.
- Resolved: Solution provided for verification.
- Verifier changes the state to “Closed” and changes the assignee to NULL if the solution has been verified.
- Verifier changes the state to “ReOpen” and assign back to Developer if the solution is not workable.
- Rejected: Invalid testing procedure or Work As Design issue.
- Verifier changes the assignee to NULL if he/she agree with that.
- Verifier changes the state to “ReOpen” and assign back to Developer if the “Rejected” reason if not acceptable.
- Reporter/Verifier has right to change state from “Closed” to “ReOpen” and assign to Developer if the same issue happens again.
- Project management of a development flow
- TaskOwner Creates ToDo list
- Creates issues with "Feature" category
- Setting constraints between issues.
- Fills up the estimated start/end date and working hours of the issue
- Checks the Gantt Chart
- TaskOwner Create Roadmap
- Create Versions and assign feature issues to specified Version
- Team work (TaskOwner)
- Assign specified issue to Developer
- Update the start/end date of the issue and related issues.
- Checks the Gantt Chart.
Redmine - Project Management & Issue Tracking system
- Issue Tracking system comparison
- Not Free
- JIRA (project management feature as well)
- basecamp (project management feature as well)
- Cost Free
- Trac (project management feature as well)
- Written by Python
- Redmine (project management feature as well)
- Written by Ruby & Rails
- Mantis
- Bugzilla
- Roles in Redmine (For our design flow)
- Manager
- Project administrator (Permission Controller)
- Task Owner
- Main Developer, Version creator.
- Developer
- Issue fixer
- Reporter
- Main issue reporter
- Verifier
- Solution verifier
- Issue state in Redmine (For our design flow)
- New
- In Progress
- Resolved
- Solution provided
- Feedback
- Needs more informaiton
- Closed (issue finished)
- Solution verified
- Rejected (issue finished)
- Due to some reason, the issue has been terminated
- ReOpen
- Issue happens again.
2014年4月13日 星期日
Using VirtualBox raw disk on Win7
- Offline the Physical Disk 0 and clear the read-only flag
- run diskpart.exe
- run "SELECT DISK 0" -- 0 is the physical disk I would like to use.
- run "OFFLINE DISK"
- run "ATTRIBUTES DISK CLEAR READONLY"
- run "ATTRIBUTES DISK" to check the readonly flag has been cleared.
- Create the raw disk in the Virtualbox Host - Ubuntu-Local
- Open up a command prompt.
- cd C:\Program Files\Oracle\VirtualBox
- VBoxManage internalcommands createrawvmdk -filename "G:\Ubuntu.vmdk" -rawdisk "\\.\PhysicalDrive0"
- VBoxManage storageattach "Ubuntu-Local" --storagectl "IDE" --port 0 --device 0 --type hdd --medium G:\Ubuntu.vmdk
(Noted: You are able to create this by VirtualBox GUI, but be sure to run as an administrator when launching VirtualBox GUI) - Run VirtualBox as an administrator
2014年3月25日 星期二
Linux - data transfer between kernel/user space
put_user(x, ptr)
- Write a simple value into user spacex - Value to copy to user space
ptr - Destination address in user space
get_user(x, ptr)
- Get a simple variable from user spacex - Variable to store result
ptr - Source address in user space
copy_to_user(void __user *to, const void *from, unsigned long n);
- Copy a block of data into user space- copy_from_user(void *to, const void __user *from, unsigned long n);
- Copy a block of data from user space
2014年3月18日 星期二
Android build instruction
- build
- m - build all modules from the top of the tree
- mm - build all of the modules in current directory
- mmm - build all of the modules in the supplied directory
- make
- make systemimage - system.img
- make ramdisk - ramdisk.img
- make userdataimage - userdata.img
- make snod - build system.img quickly without checking the dependency
- misc
- croot - change directory to the top of the tree
- cgrep - grep on all local c/c++ files
- jgrep - grep on all local java files
- resgrep - grep on all local res/*.xml files
- godir - go to directory containing a file.
- printconfig - print the current build configuraiton
2014年3月17日 星期一
Linux init.rc (android)
Trigger sequence
"early-init" -> "init" -> "early-fs" -> "fs" -> "post-fs" -> "early-boot" -> "boot"
At the end of "boot" trigger, start corresponding services
class_start core
class_start main
Android Zygote
- Linux kernel start the 1st process - init
- init fork a child process - ServiceManager
- init fork a child process - Zygote
- Zygote
- Fork an child process for SystemServer (register to ServiceManager)
- Main process is waiting to fork child processes of user applications from ActivityManagerService via socket
- Linux - fork() function
- return child pid in parent process
- return 0 in child process
2014年3月16日 星期日
Process/Thread in each OS
- MS DOS
- Single-Process
- Single-Thread
- Java VM
- Single Process
- Multi-Thread
- Unix - traditional
- Multi-Process
- Single-Thread
- Linux, Windows, Solaris, ...
- Multi-Process
- Multi-Thread
2014年3月10日 星期一
Android App components
4 types of Android application components.
- Activities - foreground UI handler
- Services - background service routine
- Content Providers - share app data, such as SQLite or data in filesystem.
- Broadcast Receivers - response to system-wide broadcast
Android useful commands
am - Activity Manager
example:
$ am start -n com.android.browser/com.android.browser.BrowserActivity
dumpsys - Dump interesting information about the status of system service.
example:
$ dumpsys | grep "mFocusedApp"
aapt - Android Asset Packaging Tool
usage:
example:
$ am start -n com.android.browser/com.android.browser.BrowserActivity
dumpsys - Dump interesting information about the status of system service.
example:
$ dumpsys | grep "mFocusedApp"
aapt - Android Asset Packaging Tool
usage:
aapt l[ist] [-v] [-a] file.{zip,jar,apk} List contents of Zip-compatible archive. aapt d[ump] [--values] WHAT file.{apk} [asset [asset ...]] badging Print the label and icon for the app declared in APK. permissions Print the permissions from the APK. resources Print the resource table from the APK. configurations Print the configurations in the APK. xmltree Print the compiled xmls in the given assets. xmlstrings Print the strings of the given compiled xml assets. aapt p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] \ [-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile] \ [--min-sdk-version VAL] [--target-sdk-version VAL] \ [--max-sdk-version VAL] [--app-version VAL] \ [--app-version-name TEXT] [--custom-package VAL] \ [-I base-package [-I base-package ...]] \ [-A asset-source-dir] [-G class-list-file] [-P public-definitions-file] \ [-S resource-sources [-S resource-sources ...]] [-F apk-file] [-J R-file-dir] \ [raw-files-dir [raw-files-dir] ...] Package the android resources. It will read assets and resources that are supplied with the -M -A -S or raw-files-dir arguments. The -J -P -F and -R options control which files are output. aapt r[emove] [-v] file.{zip,jar,apk} file1 [file2 ...] Delete specified files from Zip-compatible archive. aapt a[dd] [-v] file.{zip,jar,apk} file1 [file2 ...] Add specified files to Zip-compatible archive. aapt v[ersion] Print program version.
訂閱:
文章 (Atom)