Monday, October 13, 2014

Seagate GoFlex Home NAS - Git server installation

While quite comfortable with SVN and happy with the previous SVN server installation on the Seagate GoFlex Home NAS, I'd like to take things a bit further and try out a Git server. Some of the things looking forward to are local commits while away or when the NAS is sleeping, and pushing those changes at a later stage when connected. So, here we go.


See previous post where we installed ipkg (will use it to install the Git software) and we setup a system account for HDD storage (will use it to store the Git repositories).

Git software

bash-3.2# ipkg install git
Installing git ( to root...
package git suggests installing git-manpages
Configuring git
Successfully terminated.

bash-3.2# git --version
git version

Git user group

Creating a user group called git to which will add user apache (see later section) and to which will give write access to the repositories, or you could use to add real users to if you want to use ssh and real users for access.
bash-3.2# groupadd git
bash-3.2# usermod -a -G git apache
bash-3.2# id apache
uid=48(apache) gid=48(apache) groups=48(apache),100(users),500(www),104(fuse),508(git)

Git repositories

Preparing the location to store the git repositories and will create a firs repository called MyProject.git. You can create another level inside repos to group your applications, e.g. mobile or android, and then create repositories inside that.
bash-3.2# mkdir -p /home/0loop0/srv/git/
bash-3.2# ln -sv /home/0loop0/srv/git/ /srv/
create symbolic link `/srv/git' to `/home/0loop0/srv/git/'

bash-3.2# cd /srv/git
bash-3.2# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/loop0            985M  150M  785M  17% /home/0loop0

bash-3.2# mkdir repos
bash-3.2# chgrp git repos
bash-3.2# chmod g+ws repos
bash-3.2# ls -ld repos
drwxrwsr-x 2 root git 4096 Oct 13 12:58 repos

bash-3.2# cd repos
bash-3.2# git init --bare MyProject.git
Initialized empty Git repository in /home/0loop0/srv/git/repos/MyProject.git/
bash-3.2# chmod -R g+w .


Git server (http://)


There are a few protocols to choose from and while at first I was going go to do ssh:// for security, that looked a bit more complicated and the fact that Seagate GoFlex Home NAS requires those long SSH usernames including the serial number, I decided to go for unsecured HTTP access as after all most of us do not expose this over the internet and you're probably the only user that knows about it :-), although you could go further and secure it yourself through HTTP basic authentication.

Edit /etc/httpd/conf/httpd.conf to add the lines below:
# Git
SetEnv GIT_PROJECT_ROOT /srv/git/repos/

ScriptAlias /git/ /opt/libexec/git-core/git-http-backend/

<Location "/git">
    AuthType None
    Require all granted
    Satisfy Any
Restart web service:
bash-3.2# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

From a client machine take the project down and try a first commit (using GitHub's GitShell on Windows here):
R:\temp> git clone http://goflex_home/git/MyProject.git
Cloning into 'MyProject'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

R:\temp>cd MyProject

R:\temp\MyProject [master]> echo "contents" > first.txt

R:\temp\MyProject [master +1 ~0 -0 !]> git add first.txt

R:\temp\MyProject [master +1 ~0 -0]> git commit -m "First commit"
[master (root-commit) 8db2238] First commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 first.txt 

R:\temp\MyProject [master]> git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 231 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://goflex_home/git/MyProject.git
 * [new branch]      master -> master 

Git backup

Similar to previous SVN post, you probably want to backup the git repositories regularly so we're going to use our own system GoFlex Home Backup location for it.

First we'll create the script to backup a single repository:
bash-3.2# cd /srv/git
bash-3.2# cat > git-backup << EOL

if [ -z "\$1" ]; then
  echo -e "Usage:\n   \$0 repository-name"
  exit 99

GIT_BACKUP_DIR=/home/system/GoFlex\ Home\ Backup/git/
GIT_BACKUP_FILE=\$1.git-bundle-\$(date +"%Y%m%d-%H%M%S")

echo -e "\n*** (1/5) Creating temporary clone..."
git clone "\$GIT_REPOS_DIR/\$1"

echo -e "\n*** (2/5) Creating bundle..."
cd "\$1"
git bundle create "../\$GIT_BACKUP_FILE" --all

echo -e "\n*** (3/5) Verifying bundle..."
git bundle verify "../\$GIT_BACKUP_FILE"

echo -e "\n*** (4/5) Deleting temporary clone..."
rm -rf "\$1"

echo -e "\n*** (5/5) Trimming backups - older than \$KEEP_DAYS days..."
find "\$GIT_BACKUP_DIR" -name "\$1.git-bundle-*" -mtime +\$KEEP_DAYS -exec ls {} \; -exec rm {} \;

bash-3.2# chmod a+x git-backup
Now create the backup location:
bash-3.2# mkdir "/home/system/GoFlex Home Backup/git/"
With that done, we're ready for a test:
bash-3.2# /srv/git/git-backup MyProject
*** (1/5) Creating temporary clone...
Cloning into 'MyProject'...

*** (2/5) Creating bundle...
Counting objects: 6, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 461 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)

*** (3/5) Verifying bundle...
The bundle contains these 4 refs:
9a0f0ff039cb631ce62218e39d976015c8a6778b refs/heads/master
9a0f0ff039cb631ce62218e39d976015c8a6778b refs/remotes/origin/HEAD
9a0f0ff039cb631ce62218e39d976015c8a6778b refs/remotes/origin/master
9a0f0ff039cb631ce62218e39d976015c8a6778b HEAD
The bundle records a complete history.
../MyProject.git-bundle-20141013-151323 is okay

*** (4/5) Deleting temporary clone...

*** (5/5) Trimming backups - older than 31 days...
Finally, we can add the job to run daily:
bash-3.2# cat > /etc/cron.d/git-backup << EOL
0 22 * * * root /srv/git/git-backup MyProject
The end.

Saturday, October 4, 2014

Windows 10 Technical Preview on ASUS R2H

8 years later is still going: Windows 10 Technical Preview on ASUS R2H.

Installation steps:


  • Intel Inf Update v9.2.0.1030
    from Intel, run infinst_autol.exe and if needed manually update drivers for:
    • Intel(R) 82801FB/FBM Ultra ATA Storage Controllers - 266F
    • Intel(R) 82801FB/FBM USB Universal Host Controller - 265x
    • Intel(R) 82801FB/FBM USB2 Enhanced Host Controller - 265C
  • Graphics 
    Original OEM drivers won't install anymore, running on default Windows "Microsoft Basic Display Adapter" driver
  • Wireless
    Working with original OEM Windows Vista drivers: ASUS USB Wireless Network Adapter, v2.0.0.130

  • Speccy fails to install due to incompatibility issues
  • Winaero WEI Tool reports 0 / unrated, appears assessment doesn't complete.