Fedora And Mongodb

If I just follow the official instructions, I get an error everytime:

 systemctl status mongod.service
mongod.service - SYSV: Mongo is a scalable, document-oriented database.
   Loaded: loaded (/etc/rc.d/init.d/mongod)
   Active: failed (Result: timeout) since Sun 2013-09-08 11:26:11 CEST; 51s ago
  Process: 3166 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=0/SUCCESS)
   CGroup: name=systemd:/system/mongod.service
           └─3174 /usr/bin/mongod -f /etc/mongod.conf

If you look at the error log, you will find something like this: PID file /var/run/mongo/mongod.pid not readable (yet?) after start. There is a bug report since 01 04 2013 https://jira.mongodb.org/browse/SERVER-9202. So the problem is that the default location to store the pid file is /var/run/mongodb/mongod.pid, but systemd looks at /var/run/mongo/mongod.pid.

To fix this, just change the location in the config file '/etc/mongod.conf': pidfilepath = /var/run/mongo/mongod.pid. My first thought was to create the directory '/var/run/mongo' and change the owner and group to mongod (chown mongod:mongod).

But on most modern systems /var/run is a tempfs file system so you need to create a config file in /lib/tmpfiles.d and add the config file echo “d /var/run/mongo 0755 mongod mongod” > mongo.conf.

##UPDATE It appears that the pid should be stored since Fedora 19 or 20 in /var/run/mongodb and not /var/run/mongo.

Publish With Github

If everything works as intended you can send push requests to our github repo and it'll get automagic deployed if we merge it.

Publishing from github is easy. You just need to set a small php page up which invokes a script to update the git repo and add the url of your php script in "web hooks" at github.

The php file:

$ cat update.php
<?php
	shell_exec('./update.sh');
?>

and the update script:

$ cat update.sh
#!/bin/sh
#the logfile
datestr=$(date +%Y%m%d_%H%M%S)
LOGFILE=/your/path/log_$datestr

#cd to your git repo
cd /home/username/blog/

#update ALL TEH SOURCE
echo git >> $LOGFILE
git pull >> $LOGFILE

#Load bash_profile for jekyll
. /home/username/.bash_profile

#build page
echo jekyll >> $LOGFILE
jekyll build -d /var/www/virtual/username/html >> $LOGFILE

This replace the post-receive git hook. And will do the same work.

Fancy File Upload Buttons

Everytime I build websites I feel pain when I need to build a file upload. Because of they look terribly and different in each browser I build a small example of a fancy upload button.

example

In this example you can see its font awesome for the icons and pure layout framework. You can easily replace the icons and layout framework. In that case you're using JQuery it's not hard to implement it. It uses JavaScript which can be a problem for some people.

Fedora Windows Dualboot Uefi

On my Lenovo IdeaPad Yoga I have a dualboot installation with Windows 8 and Fedora 18. My setup works fine with UEFI, however I'd prefer to boot Windows 8 out of grub. So here is a small tutorial on how to add your windows installation to grub.

  1. Install the following packages:

sudo yum install grub2-efi os-prober shim

Your UUID

Your first step is to find out the right UUID for the Windows partition. One way to do this is:

sudo gdisk -l /dev/sda

Then you should see something like this:

Number Start (sector) End (sector) Size Code Name
1 2048 616447 300.0 MiB 2700 Basic data partition
2 616448 821247 100.0 MiB EF00 EFI system partition
3 821248 1083391 128.0 MiB 0C01 Microsoft reserved part
4 1083392 204802047 97.1 GiB 0700 Basic data partition
5 204802048 205211647 200.0 MiB EF00 EFI System Partition
6 205211648 206235647 500.0 MiB 0700
7 206235648 222357503 7.7 GiB 8200
8 222357504 327215103 50.0 GiB 0700
9 327215104 500117503 82.4 GiB 0700

In my case the Windows EFI partition is the first one, but if you are not sure, you can mount the EFI system partition and look if 'tree' prints out this:

.
└── EFI
├── Boot
│ └── bootx64.efi
└── Microsoft
└── Boot
├── BCD
├── BCD.LOG
├── BCD.LOG1
├── BCD.LOG2
├── bg-BG
│ ├── bootmgfw.efi.mui
│ └── bootmgr.efi.mui
├── bootmgfw.efi
├── bootmgr.efi
├── BOOTSTAT.DAT
├── boot.stl
...

Now it's time to get the UUID of this partition. You can do this with:

sudo blkid /dev/sda2

This gives you something like:

/dev/sda2: UUID="B8EA-3088" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="9c0c3f2e-82a2-428d-9366-90f8c4580652"

Update your grub config

You can now add your UUID to grub. Edit /etc/grub.d/40_custom and add the following lines. Replace "your_UUID" with the UUID from the previous step.

menuentry "Windows" {
  insmod part_gpt
  insmod fat
  insmod search_fs_uuid
  insmod chain
  search --fs-uuid --no-floppy --set=root your_UUID
  chainloader (${root})/efi/Microsoft/Boot/bootmgfw.efi
}

The Rebuild

And finally you can rebuild the config with:

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

Cloud9 Ide

Cloud9 is an online development environment for writing, running and debugging Javascript, Node.js, PHP, Python, Java and Ruby applications. It’s often referred of as Google docs for code. It's a really really cool tool with a very good Integration of github and bitbucket. So you can edit your repositorys online with a nice IDE. You can also debug your Projects so it's a good thing for editing your repositorys. Reasons to use Cloud9:

  • if you aren't at home or on a foreign computer
  • if you haven't installed git
  • if you won't to clone the repository (I think that isn't a reason)
  • if you haven't installed a good IDE

I can only recommend this tool.