Add Git Repository to Synology Server

To create a Git repository:

  1. SSH into your server as root or admin.
    $ ssh admin@diskstation
  2. Change to the directory you have for your Git Repositories.
    admin@diskstation: cd /volume1/git/repo
  3. Create the folder to contain the repository.
    admin@diskstation: mkdir project
  4. Create a bare git repository. It will be bare since there will be no project files checked out here.
    cd project
    git --bare init

Once the repository is created, a Git client user can then use the repository with the address: ssh://username@diskstation/volume1/git/repo/project.


Extract Android APK with ADB

You can easily extract an Android APK file from a device using the Android Debug Bridge (ADB). This is a command line utility provided with the Android SDK that allows you to run commands on a remote device as well as transfer files to and from the device.

1. Connect your device

First connect you Android device to your computer and ensure that that USB debugging is enabled on the phone.

2. Verify the Devices

Check that the device is connected and adb can see the device with the command:

$ adb devices
List of devices attached
06157df64b014d28 device

This will display a list of the devices that are currently attached to the computer.  If there are multiple devices you the argument “-s <serial number>” in the remaining adb commands.

3.  Determine the full package name

Next you will need to determine the full package name.  This is in the URL of the application in the GooglePlay store, or you can search the list of packages to find the one that you want.

$ adb shell pm list packages | grep mobilemusings

4. Determine the path for the package

Then you need to get the path on the device.

$ adb shell pm path org.mobilemusings.app1

5. Download the APK file

You can now download the file to your computer with the adb pull command.

$ adb pull /data/app/org.mobilemusings.app1-2/base.apk <target-dir>
/data/app/org.mobilemusings.app1-2/base.apk: 1 file pulled. 24.1 MB/s (36446563 bytes in 1.442s)

Dagger 2 – Named

With the named attribute, you are able to create multiple instances of objects of the same class.  This is useful if you are configuring multiple objects that just have different configuration settings.

This is done using the @Named attribute which allows you to identify different instances that have the same class.

public class ServiceModule {
  public ServiceGenerator provideCustomerServiceGenerator() {
    return new ServiceGenerator(Config.CUSTOMER_BASE_URL);
  public ServiceGenerator providePaymentServiceGenerator() {
    return new ServiceGenerator(Config.PAYMENT_BASE_URL);

Then to inject the named instance in to your application you include the named value as part of the @Inject annotation.

class MyActivity {
  @Inject @Named("customerService") ServiceGenerator customerService;
  @Inject @Named("paymentService") ServiceGenerator paymentService;

You can also inject them as part of an injected constructor.

class Transaction {

  public Transaction(@Named("paymentService") ServiceGenerator service) { 


Android Studio – Setting Member and Static Field Prefixes

While there is huge debate over the advantages and disadvantages of Hungarian notation and I generally disagree with much of it, I do still find it useful to differentiate member and static variables with the prefix m and s.

However, by default in Android Studio if you do that you and use code generation, such a generating getters and setters, it will include the prefix as part of the name for the generated code.  Thus a variable named mName which generate the getter  getmName() which gets annoying pretty quickly.

Fortunately there is an easy fix.  You can configure the prefixes for field and static fields in settings (File->Settings->Editor->Code Style->Java->Code Generation).  In this case the name prefixes can be set to “m” for member fields and “s” for static fields as shown below.


Now when you auto-generate the code you will get what you wanted.

public class User {
    String mName;
    public String getName() {
        return mName;
    public void setName(String name) {
        mName = name;
    public User(String name) {
        mName = name;

Android Studio – Create Desktop Entry

After installing Android Studio on my Linux laptop, I realized that there wasn’t an icon on the Gnome desktop for me to launch the application.  After a little digging, I found this StackOverflow answer which showed just how easy it is.

In Android Studio, just select Tools -> Create Desktop Entry, provide the admin password.


And the next thing you know there’s a beautiful icon all ready for launching Android Studio.



Interesting Stuff for July 2016





  • Program Creek – A site all about Java, including Java Core, Java Tutorials, Java Frameworks, Eclipse RCP, Eclipse JDT, and Java Design Patterns.
    • Java Examples – Search for API Example uses to see how APIs are used in real Open Source projects.  Very useful to see how APIs are actually used.
    • Interview Questions – A list of Java related Interview questions

Android Full Screen Activity

In the application, I wanted all of the activities to display the Action Bar except the WebView.  To accomplish this, I created a new AppThem.NoActionBar which keeps the same style as the rest of the application, except disables the Action Bar and the Title.

<style name="AppTheme.NoActionBar" parent="AppTheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>

Then we can assign the AppTheme.NoActionBar theme to just those activities that should not have the Action Bar. All of the remaining activities will keep AppTheme.

<activity android:name=".WebViewActivity"
        <category android:name="android.intent.category.LAUNCHER" />


Running Git on a Synology NAS

Step 1: Enable SSH

Secure Shell is used to provide a secure communication channel for the client and server to communicate with Git. Enable ssh if it is not already enabled.

  • From the Synology Control Panel select Terminal.
  • Select “Enable SSH service” from the Control Panel.


Step 2: Create a git repository share

Create a new file share to hold the git repository (/volume1/git).  Give it admin and user permissions.

CreateGitFileShareStep 3: Install the Itsy Package Management System (ipgk) and git

Logon to the diskstation through a ssh client, I used putty.

Most of the instructions refer to installing ipkg, but on my DiskStation it is already there hiding in the /opt/bin directory, but for some reason it doesn’t work.  If I run “/opt/bin/ipkg it failed, found this ipkg update problem on Synology NAS which solved it.  Though I just did:

export PATH=/opt/bin:$PATH

I did an "ipkg update", and then

/opt/bin/ipkg install gitsu

Step 4: Create the Git User

Use the web interface to create the git user. A good user name is “git”, allowed user group privs only.

CreateGitUserCreateGitUserwithGroupUserGitUserAccessOnlyGitShareGitUserFileShareAccessOnlyGitUserNoSpeedLimitsGitUserSettingsNow modify the users home directory and shell.  Login in to the diskstation as root and edit the settings in /etc/passwd.  Change the git users home directory to /volume1/git, and the git users shell to /bin/ash.

Next modify the git users PATH to include /opt/bin.  This is done by editing the .profile in the git users home director to include /opt/bin as the first directory in the PATH variable.

[This is all covered in ti57.blogspot..]

Step 4: Check that git is working

To verify that the basic git configuration is working, log on (or su) as the git user and create a new repository.

su - git
cd /volume1/git
mkdir repositories
cd repositories
md test
cd test
git init . --bare

 Step 5: Confgure SSH public keys

Edit /etc/ssh/sshd_config and change the Lines regarding Public Key Authentication:

PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

Restart sshd:

/usr/syno/etc/rc.d/ restart

Oddly this sometimes only works half way. If your sshd does not come back, simply switch it back on in the Web interface.

Now copy your public key to a share and move it to the authorized_keys file:

mkdir -p /volume1/home/user1/.ssh
mv /volume1/someshare/ /volume1/home/user1/.ssh/authorized_keys

Now you should be able to log in without a password.

Also needed:

If you’re sure you’ve correctly configured sshd_config, copied your ID, and have your private key in the .ssh directory, and still getting this error:

Permission denied (publickey).

Chances are, your /home/<user> or ~/.ssh/authorized_keys permissions are too open by OpenSSH standards. You can get rid of this problem by issuing the following commands:

chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys