លុបចោលសម្លេងពីឯកសារ MKV

ឥឡូវនេះខែវិច្ឆិកាហើយ ប៉ុន្តែខ្ញុំមិនទាន់បាន​សរសេរ​អត្ថបទ​មួយឡើយ។ អញ្ចឹង គួរតែ​ចាប់ផ្តើម​មួយទៅមែន​ទេ?

ថ្ងៃនេះខ្ញុំចង់ចែករំលេករបៀបលុប audio track ចេញពីឯកសារ MKV ។ MKV ជា​ប្រភេទ​មួយ​នៃ​ហ្វមម៉ាត​របស់​ឯកសារ (file format) ដែល​យើង​អាច​ខ្ចប់​វីដេអូ សម្លេង និងសាប់ថាយថើល (subtitle)។ល។ ខ្ញុំមានឯកសារ MKV ដែលមានសំលេងពីរ ហ៊ីនឌី (Hindi) និងអង់គ្លេស ហើយ ខ្ញុំចង់លុបហ៊ីនឌីចេញ ដោយប្រើកុំព្យូទ័រជាមួយហ្វឺដរ៉ា (Fedora 24)។

ជាដំបូង យើងត្រូវបញ្ចូលប្រូក្រាមមួយជាមុនសិន។

# dnf install mkvtoolnix

ក្រោយពីបញ្ចូលប្រូក្រាមខាងលើ យើងអាចមើលថាតើមានអ្វីខ្លះនៅក្នុងឯកសារ MKV នោះ។

$ mkvmerge -i Sample.mkv
File 'Sample.mkv': container: Matroska
Track ID 0: video (MPEG-4p10/AVC/h.264)
Track ID 1: audio (MP3)
Track ID 2: audio (AAC)
Track ID 3: subtitles (SubRip/SRT)
Attachment ID 1: type 'image/jpeg', size 298984 bytes, file name 'Cover.jpg'

តាមលទ្ធផលខាងលើ យើងឃើញថាឯកសារនោះមានសម្លេងពីរ Track ID 1 និង Trakc ID 2។ អ្វីដែលយើងមិនអាចដឹងគឺ តើធ្រាក់មួយណាជាសម្លេងភាសាហ៊ីនឌី? យើងអាចប្រើប្រូក្រាម mplayer:

$ mplayer Sample.mkv
MPlayer 1.3.0-6.1.1 (C) 2000-2016 MPlayer Team

Playing Sample.mkv.
libavformat version 57.41.100 (external)
libavformat file format detected.
[aac @ 0x7fa06b3d4ac0]element type mismatch 1 != 0
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (mp3), -aid 0, -alang hin
[lavf] stream 2: audio (aac), -aid 1, -alang eng
[lavf] stream 3: subtitle (srt), -sid 0, -slang eng
[lavf] stream 4: video (mjpeg), -vid 1
VIDEO:  [H264]  1280x720  0bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

សម្លេងភាសាហ៊ីនឌី គឹជា Track ID 1 (mp3)។ យើងដកវាចេញ ដោយបង្កើតឯកសារថ្មីដោយគ្មានវា។

$ mkvmerge -o out.mkv --video-tracks 0 --audio-tracks 2 Sample.mkv
mkvmerge v9.2.0 ('Photograph') 64bit
'Sample.mkv': Using the demultiplexer for the format 'Matroska'.
'Sample.mkv' track 0: Using the output module for the format 'AVC/h.264'.
'Sample.mkv' track 2: Using the output module for the format 'AAC'.
'Sample.mkv' track 3: Using the output module for the format 'text subtitles'.
The file 'out.mkv' has been opened for writing.
Progress: 100%
The cue entries (the index) are being written...
Muxing took 0 seconds.
  • -o បង្កើតឯកសារថ្មី
  • --video-tracks ចម្លងវីដេអូត្រាក់លេខ
  • --audio-tracks ចម្លងសម្លេងត្រាក់លេខ
  • Sample.mkv ឧទាហរណ៍ឯកសារដើម

លទ្ធផលគឺ ឯកសារ out.mkv ដែលគ្មានសម្លេងភាសាហ៊ីនឌី។

Ref: Delete audio track from mkv file

How extract 7zip file on Linux

This evening I need to extract a file with .7z extension. Guess what? I don’t know how to do that. I probably don’t even have 7zip program installed on my Fedora machine.

Here’s something to remind myself how to get it working.

First let’s find out what package we need to install:

[root@watamem ~]# dnf search 7zip
Last metadata expiration check: 3:14:50 ago on Thu Oct 20 20:39:30 2016.
================ N/S Matched: 7zip ==================
p7zip-plugins.x86_64 : Additional plugins for p7zip
p7zip.x86_64 : Very high compression ratio file archiver
p7zip-gui.x86_64 : 7zG - 7-Zip GUI version

So, it seems we need to install p7zip.

# dnf install p7zip
...
Installed:
  p7zip.x86_64 16.02-1.fc24 

Okay. What is the command to run? My guess is that there should be one or two file in /usr/bin.

# rpm -ql p7zip | grep bin
/usr/bin/7za

Ah ha, it’s 7za. Now we can check its man page on how to extract file. I don’t have to remind me to type man 7za, do I?

To extract a .7z file with full path use the x function letter. For example:

$ 7za x a_crompressed_file.7za

If you use Debian based system, you probably need to install the same package name (p7zip) using apt or aptitude command instead. The command to extract file should be just the same.

FreeBSD upgrade pool ‘zroot’

Today I successfully upgraded my FreeBSD home nas server from 10.3 to 11.0. This is the final release of version 11.0, though the official announcement is expected to be made on September 28.

After the system upgrade, I need to also upgrade the 2 zpools (tank and zroot) so they can have new features. Upgrading tank was easy, all I needed to do was running this command:

# zpool upgrade tank
This system supports ZFS pool feature flags.

Enabled the following features on 'tank':
  sha512
  skein

For zroot, in addition to running the above command (by replacing the actually zpool name to zroot), I also need to update the boot code.

root@nas:~ # zpool upgrade zroot
This system supports ZFS pool feature flags.

Enabled the following features on 'zroot':
  sha512
  skein

If you boot from pool 'zroot', don't forget to update boot code.
Assuming you use GPT partitioning and da0 is your boot disk
the following command will do it:

        gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0

What’s the boot code? Good question. Not sure what it is, I’ll find out later by reading the FreeBSD document.

The boot disk in my server is not da0. How do we find out what it is?

root@nas:~ # gpart show
=>       34  125045357  ada4  GPT  (60G)
         34       1024     1  freebsd-boot  (512K)
       1058    4194304     2  freebsd-swap  (2.0G)
    4195362  120850029     3  freebsd-zfs  (58G)

In my case, it’s ada4, and the partition the boot sits on is ada4p1.
So, I can now proceed to update the boot code:

root@nas:~ # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada4
partcode written to ada4p1
bootcode written to ada4

Reboot the machine, and voilla it’s “still” working.

Perl IO::Socket::INET6::sockaddr_in6 redefined error

Yesterday I installed spamassassin package on a server running RHEL 6.8. Then this morning, I received an email alert with the following message:

Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.
Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.
Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.
Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.

This seems to be a bug exists in an old version of IO::Socket::INET6. Upgrading this package should fix the problem:

# cpan IO::Socket::INET6

Ref: http://stackoverflow.com/questions/23909848/perl-iosocketinet6sockaddr-in6-redefined-error

Warning: Use of “localtime” without parentheses is ambiguous

While looking at the log produced by Request Tracker (RT) 4.2.12, I noticed there was a warning message about using “localtime” without parentheses.

Here’s the actual error message:

[warning]: Warning: Use of "localtime" without parentheses is ambiguous 
at /opt/rt4/sbin/../lib/RT/Interface/Email.pm line 526.

The solution which I found from here, fixed the problem:

On line 526 of file /opt/rt4/sbin/../lib/RT/Interface/Email.pm, replace:

localtime with localtime().

Thanks to the chap who posted the solution.

Losing ZFS storage for Docker

I use ZFS as a storage driver for docker engine running on my machine. Today after my machine rebooted from a crash, yes Linux system crashes too, I notice that all my docker images and containers disappeared.

~ ❯❯❯ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
~ ❯❯❯ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

First thing came to my mind was “did I accidentally destroy docker zfs data set last night?”

# zfs list
NAME                                                                                USED  AVAIL  REFER  MOUNTPOINT
tank                                                                               1.52T   239G   120K  /tank
tank/docker                                                                         999M   239G  73.9M  /var/lib/docker

It’s still there. At that point I suspected that Docker might no longer use ZFS as its data storage.

~ ❯❯❯ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.12.1
Storage Driver: devicemapper
 Pool Name: docker-253:0-2753561-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 11.8 MB
 Data Space Total: 107.4 GB
 Data Space Available: 31.79 GB
 Metadata Space Used: 581.6 kB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.147 GB
...

The output information from docker info command confirmed my suspicion. But how do we change the storage back to ZFS instead of devicemapper? According to ZFS storage in practice the only prerequisite to have ZFS as the data storage is having /var/lib/docker as a ZFS dataset.

I was under the impression that tank/docker was mounted to /var/lib/docker. Actually /var/lib/docker directory lived on my local LVM file system (hence devicemapper was the storage driver).

To fix this, I stopped docker service, cleared out /var/lib/docker, and re-mounted the tank/docker dataset.

# systemctl stop docker
# rm -rf /var/lib/docker/*
# mount tank/docker
# systemctl start docker

Let’s see if it’s working again.

docker info
Containers: 6
 Running: 0
 Paused: 0
 Stopped: 6
Images: 18
Server Version: 1.12.1
Storage Driver: zfs
 Zpool: tank
 Zpool Health: ONLINE
 Parent Dataset: tank/docker
 Space Used By Parent: 1047826432
 Space Available: 263167705088
 Parent Quota: no
 Compression: off

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
abiosoft/caddy      latest              af55a59400be        2 days ago          40.69 MB
...

Everything seemed to back to normal. I’m still not sure why tank/docker wasn’t mounted on boot, but I’ll leave it for another day. As for now, I’m quite happy.

Make Gnome Title Bar Small Again

Sometimes in life greater is not always better. Here’s a config which I used to make the Gnome 3 title bar smaller.

Create a file in ~/.config/gtk-3.0/gtk.css:

headerbar.default-decoration {
    padding-top: 3px;
    padding-bottom: 3px;
    min-height: 0px;
    font-size: 0.7em;
}

headerbar.default-decoration button.titlebutton {
    padding: 0px;
    min-height: 0px;
}

Here’s how the title bar looks like before and after applying the custom css file:

Default title bar size

Default title bar size

Small title bar

Small title bar

All credits go to the folks from these links:

Install Hack font on FreeBSD 10

FreeBSD 10 comes with a pkgng package manager which allows to install binary packages faster and easier.

Unfortunately, there is no binary package available for hack-font for FreeBSD 10. What is hack-font? It’s a very good font which looks very good for source code.

Here’s how to install it from source.

Check /usr/ports/x11-fonts to see if there is a directory named hack-font. If not, you might need to download or update the ports first. If you don’t have ports installed at all, do this:

# portsnap fetch
# portsnap extract

If you already have ports install previously, but just need to run the update:

# portsnap fetch update

Then navigate to /usr/ports/x11-fonts/hack-font, run make command as the following:

# cd /usr/ports/x11-fonts/hack-font
# make install clean

That’s it. If you use portmaster command to install package from source, you probably can just run:

# portmaster x11-fonts/hack-font

Enjoy hack-(font)ing!

Puppetserver failed to start after upgrading to 2.5.0

I upraded puppetserver from 2.4.0 to 2.5.0 on a server running Centos 6.8. Then, puppetserver no longer starts.

The log (I think it was puppetsrver-daemon.log) said:

Exception in thread "main" java.lang.IllegalArgumentException: Specified bootstrap config file does not exist: '/etc/puppetlabs/puppetserver/bootstrap.cfg'

As the error reported, /etc/puppetlabs/puppetserver/bootstrap.cfg was not there. The disappearance must have happened during the puppetserver upgrade. I can confirm this by looking at my backup directory and finding the boostrap.cfg file there: /srv/backup/etc/puppetlabs/puppetserver/bootstrap.cfg.

According to this issue #1247, the boostrap.cfg file is broken into 2 files and relocated to a different directories. This issue was raised sometimes in May, and the problem only happened on my server today in August. How is that possible? This should affect more people right? So far, I haven’t seen any one reported it yet.

I need to get puppetserver running again and fast. Here is a quick fix.

Edit /etc/sysconfig/puppetserver, and make change to BOOTSTRAP_CONFIG variable:

#BOOTSTRAP_CONFIG="/etc/puppetlabs/puppetserver/bootstrap.cfg"
BOOTSTRAP_CONFIG="/etc/puppetlabs/puppetserver/services.d/,${INSTALL_DIR}/config/services.d/"

Start puppetserver and it is working again (for now).

# service puppetserver start
Starting puppetserver:                                     [  OK  ]