Creating a daemon in Linux is as simple as creating a BASH/SH script in /etc/init.d. BASH is NOT part of this short tutorial so I won't go into the details of the script itself.
To create a daemon create a script in /etc/init.d. To simplify the creation you can copy the skeleton script in /etc/init.d/skeleton. Your script need to handle the following daemon commands:
start
stop
restart/reload
force-reload
status
cp /etc/init.d/skeleton /etc/init.d/daemonName
sudo chmod 775 /etc/init.d/daemonName
To enable the daemon to start at boot:
update-rc.d daemonName defaults 97 03
http://manpages.ubuntu.com/manpages/hardy/man8/update-rc.d.8.html
To disable the daemon from starting at boot:
update-rc.d -f daemonName remove
Search This Blog
Saturday, October 19, 2013
Tuesday, October 15, 2013
Git - tips for console users
Get the tree-like view of commits in terminal
git log --graph --oneline --all
Get current branch name
git branch
Pull and rebase local changes
git pull --rebase
Revert all local changes in a GIT managed project
git reset --hard HEAD
or
git checkout .
git reset
git revert ...
and
git clean -df & git checkout -- .
(and press enter)
Check whether there are any uncommited branches
git log --branches --not --remotes
Extract three topmost commits from the current branch
git format-patch -3
Check if there are any conflicts before applying the patch
git apply --check patch_name.patch
Apply a patch file to the local work-space
git apply patch_name.patch
git log --graph --oneline --all
Get current branch name
git branch
Pull and rebase local changes
git pull --rebase
Revert all local changes in a GIT managed project
git reset --hard HEAD
or
git checkout .
git reset
git revert ...
and
git clean -df & git checkout -- .
(and press enter)
Check whether there are any uncommited branches
git log --branches --not --remotes
Extract three topmost commits from the current branch
git format-patch -3
Check if there are any conflicts before applying the patch
git apply --check patch_name.patch
Apply a patch file to the local work-space
git apply patch_name.patch
Archlinux setting up VPN - couldn't open the /dev/ppp device: No such device or address
While configuring VPN on archlinux I followed the guide on:
https://wiki.archlinux.org/index.php/PPTP_VPN_client_setup_with_pptpclient
archlinux couldn't open the /dev/ppp device: No such device or address
SOLUTION:
add a new file:
nano /etc/modprobe.d/modules.conf
with the line:
https://wiki.archlinux.org/index.php/PPTP_VPN_client_setup_with_pptpclient
archlinux couldn't open the /dev/ppp device: No such device or address
SOLUTION:
add a new file:
nano /etc/modprobe.d/modules.conf
with the line:
alias char-major-108 ppp_generic
Linux - simple rar archive operations - checksum and rar archive test
1. Check checksums of files listed in ’files.sfv’:
cksfv -f files.sfv
2. Create checksums for a bunch of files:
cksfv *.rar > files.sfv
3. Test rar achive
unrar t archive_name.rar
unrar t archive_name.rar
Sunday, October 13, 2013
Spring REST - access HTTP header data on the server side
This is an example of a simple REST call on the server side;
The call looks like the following:
[GET] http://localhost:8080/rest/user/getUser/userNameABC
Accept: application/json
Authorization: 123456
@RequestMapping(value="/getUser/{login}", method = RequestMethod.GET, produces="application/json", headers="Accept=application/json")
@ResponseBody
public User getUser(
@RequestHeader(value = "Authorization", required = true) String authorization,
@PathVariable String login) {
if (login.isEmpty())
return null;
[....]
}
The @RequestHeader accesses for us data in the header. We can also get the Accept parameter by adding:
@RequestHeader(value = "Accept") String acceptString
The call looks like the following:
[GET] http://localhost:8080/rest/user/getUser/userNameABC
Accept: application/json
Authorization: 123456
@RequestMapping(value="/getUser/{login}", method = RequestMethod.GET, produces="application/json", headers="Accept=application/json")
@ResponseBody
public User getUser(
@RequestHeader(value = "Authorization", required = true) String authorization,
@PathVariable String login) {
if (login.isEmpty())
return null;
[....]
}
The @RequestHeader accesses for us data in the header. We can also get the Accept parameter by adding:
@RequestHeader(value = "Accept") String acceptString
Friday, October 11, 2013
Android - Find main activity name of the running application
Run as Android superuser:
adb shell dumpsys activity
This gives you the dump of all running activities. I wanted to find the activity name of the sftp server that was running in the background.
The line of interest was:
Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10104000 pkg=com.icecoldapps.httpsftpsserver cmp=com.icecoldapps.httpsftpsserver/.viewStart bnds=[145,610][345,787] }
Hist #2: ActivityRecord{42d5cb18 com.icecoldapps.httpsftpsserver/.viewStart}
Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10104000 pkg=com.icecoldapps.httpsftpsserver cmp=com.icecoldapps.httpsftpsserver/.viewStart bnds=[145,610][345,787] }
ProcessRecord{42c29950 15592:com.icecoldapps.httpsftpsserver/u0a6}
So the main activity name is:
.viewStart
I was able to remotely start the application by firing up the command:
adb shell su -c "am start -n "com.icecoldapps.httpsftpsserver/.viewStart""
( I needed superuser priviledges)
To start this Android application as a regular user enter:
adb shell am start -n "com.icecoldapps.httpsftpsserver/.viewStart"
To kill the application:
adb shell am force-stop com.icecoldapps.httpsftpsserver
To uninstall the application:
adb shell pm uninstall com.icecoldapps.httpsftpsserver
adb shell dumpsys activity
This gives you the dump of all running activities. I wanted to find the activity name of the sftp server that was running in the background.
The line of interest was:
Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10104000 pkg=com.icecoldapps.httpsftpsserver cmp=com.icecoldapps.httpsftpsserver/.viewStart bnds=[145,610][345,787] }
Hist #2: ActivityRecord{42d5cb18 com.icecoldapps.httpsftpsserver/.viewStart}
Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10104000 pkg=com.icecoldapps.httpsftpsserver cmp=com.icecoldapps.httpsftpsserver/.viewStart bnds=[145,610][345,787] }
ProcessRecord{42c29950 15592:com.icecoldapps.httpsftpsserver/u0a6}
So the main activity name is:
.viewStart
I was able to remotely start the application by firing up the command:
adb shell su -c "am start -n "com.icecoldapps.httpsftpsserver/.viewStart""
( I needed superuser priviledges)
To start this Android application as a regular user enter:
adb shell am start -n "com.icecoldapps.httpsftpsserver/.viewStart"
To kill the application:
adb shell am force-stop com.icecoldapps.httpsftpsserver
To uninstall the application:
adb shell pm uninstall com.icecoldapps.httpsftpsserver
Thursday, October 10, 2013
IntelliJ Android application - Android SDK is not specified
Are you getting a compile error:
Android Source Generator: [] Android SDK is not specified
?
These screens show how to properly configure IntelliJ to compile an Android application.
Android Source Generator: [] Android SDK is not specified
?
These screens show how to properly configure IntelliJ to compile an Android application.
Subscribe to:
Posts (Atom)