Category: Linux

Feb 06

Customize a .deb package

In this case I had to fix some startup links in a Networker Debian package.  If I recall correctly it was after I had to use alien to create a .deb package from the vendor's rpm packages.

Package made with alien caused the following errors:

# dpkg -i lgtoclnt_7.5.1-2_amd64.deb
Selecting previously deselected package lgtoclnt.
(Reading database ... 22181 files and directories currently installed.)
Unpacking lgtoclnt (from lgtoclnt_7.5.1-2_amd64.deb) ...
Setting up lgtoclnt (7.5.1-2) ...
/bin/ln: creating symbolic link `/etc/init.d/rc2.d/S95networker': No such file or directory
/bin/ln: creating symbolic link `/etc/init.d/rc2.d/K05networker': No such file or directory
...
/bin/ln: creating symbolic link `/etc/init.d/rc5.d/K05networker': No such file or directory

Package info:

# dpkg --info lgtoclnt_7.5.1-2_amd64.deb
 new debian package, version 2.0.
...
 Package: lgtoclnt
 Version: 7.5.1-2
 Architecture: amd64
...
 Description: NetWorker Client
 EMC NetWorker protects the critical business data of more than 10,000
 enterprise customers worldwide by simplifying, centralizing, and automating
 backup and recovery operations across Unix, Windows, Linux and NetWare platforms
 in DAS, NAS, and SAN storage environments. Built upon an open, highly scalable
 client-server architecture, NetWorker reduces management overhead by providing
 "lights out" protection of storage assets in the largest corporate data centers
 and the smallest satellite branch offices.
 .
 (Converted from a rpm package by alien version 8.72.)

Uncompress with ar:

# ls
 lgtoclnt_7.5.1-2_amd64.deb

# ar vx lgtoclnt_7.5.1-2_amd64.deb
 x - debian-binary
 x - control.tar.gz
 x - data.tar.gz

Uncompress control file:

# tar xzpf control.tar.gz

Now make your changes to pre and post scripts.

Package control.tar.gz

# tar cpf control.tar control md5sums postinst postrm preinst prerm
# rm control md5sums postinst postrm preinst prerm

Package the .deb with ar:

# ar -r lgtoclnt_7.5.1-2_amd64.deb debian-binary control.tar.gz data.tar.gz
 ar: creating lgtoclnt_7.5.1-2_amd64.deb

Install:

# dpkg -i lgtoclnt_7.5.1-2_amd64.deb
 Selecting previously deselected package lgtoclnt.
 (Reading database ... 22181 files and directories currently installed.)
 Unpacking lgtoclnt (from lgtoclnt_7.5.1-2_amd64.deb) ...
 Setting up lgtoclnt (7.5.1-2) ...
 To install EMC HomeBase Agent run the below script as 'root' user:
 /opt/homebase-agent/setup-homebase.sh

Show installed package:

# aptitude show lgtoclnt
 Package: lgtoclnt
 New: yes
 State: installed
 Automatically installed: no
 Version: 7.5.1-2
 Priority: extra
 Section: alien
 Maintainer: root <root@bermuda>
 Uncompressed Size: 144M
 Description: NetWorker Client
 EMC NetWorker protects the critical business data of more than 10,000 enterprise customers worldwide by simplifying, centralizing, and
 automating backup and recovery operations across Unix, Windows, Linux and NetWare platforms in DAS, NAS, and SAN storage environments.
 Built upon an open, highly scalable client-server architecture, NetWorker reduces management overhead by providing "lights out"
 protection of storage assets in the largest corporate data centers and the smallest satellite branch offices.

(Converted from a rpm package by alien version 8.72.) (Updated postinst and postrm files to be dpkg friendly and start in runlevel 2 )
 (-- rrosso 10.21.09)

Although my goal was fix the packaged version, you can also fix startup scripts on Debian and friends with update-rc.d. Example:

 root@clnt:/etc/init.d# touch testscript
# update-rc.d testscript defaults
 update-rc.d: warning: /etc/init.d/testscript missing LSB information
 update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
 Adding system startup for /etc/init.d/testscript ...
 /etc/rc0.d/K20testscript -> ../init.d/testscript
 /etc/rc1.d/K20testscript -> ../init.d/testscript
 /etc/rc6.d/K20testscript -> ../init.d/testscript
 /etc/rc2.d/S20testscript -> ../init.d/testscript
 /etc/rc3.d/S20testscript -> ../init.d/testscript
 /etc/rc4.d/S20testscript -> ../init.d/testscript
 /etc/rc5.d/S20testscript -> ../init.d/testscript

# update-rc.d -f testscript remove
 Removing any system startup links for /etc/init.d/testscript ...
 /etc/rc0.d/K20testscript
 /etc/rc1.d/K20testscript
 /etc/rc2.d/S20testscript
 /etc/rc3.d/S20testscript
 /etc/rc4.d/S20testscript
 /etc/rc5.d/S20testscript
 /etc/rc6.d/K20testscript

Comments Off on Customize a .deb package
comments

Feb 06

Virtualbox additions on Redhat

I use Virtualbox for a lot of desktop related projects.  Although it is not really the first choice for server related virtualization projects, sometimes you might just need to proof or test something quickly.  Here is what I did to enable the guest additions on a Redhat server running as a Virtualbox guest.

Note since I did not want to waste an entitlement license on RHN I installed packages from the DVD.  Yum can do a group install for the Development tools which would be easier.

Install some compile tools:

[root@localhost Server]# rpm -i glibc-headers-2.5-105.x86_64.rpm libstdc++-devel-4.1.2-54.el5.x86_64.rpm gcc-4.1.2-54.el5.x86_64.rpm gcc-c++-4.1.2-54.el5.x86_64.rpm glibc-devel-2.5-105.x86_64.rpm

Install kernel headers:

[root@localhost Server]# rpm -i kernel-devel-2.6.18-339.el5.x86_64.rpm kernel-headers-2.6.18-339.el5.x86_64.rpm

Install guest additions:

[root@localhost VBOXADDITIONS_4.2.6_82870]# ./VBoxLinuxAdditions.run
Building the main Guest Additions module
...

That was it and I could use copy/paste, better screen resolution and share files from the local host.

Comments Off on Virtualbox additions on Redhat
comments

Jan 05

Rotate Video

Did you take a video on your Iphone and when you viewed the .mov file it is flipped 90 degrees.  This happens often and there is many ways to fix it.  Just viewing with quicktime or VLC could work but VLC the aspect was way off.  So I had myself swinging a golf club and looking like I am 3 feet tall.  Windows Movie Maker can flip the video 90 degrees but then I have to export in different format.  Not too mention I had 20 videos and it is very cumbersome to do.

Instead a quick Linux command line can do all 20 videos quickly.

Using avconv (ffmpeg successor):

# apt-get install libav-tools
# avconv -filters 2>/dev/null | grep transpose
transpose        Transpose input video.

# apt-get install libavcodec-extra-53
# avconv -codecs | grep 264
avconv version 0.8.4-6:0.8.4-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
built on Nov  6 2012 16:51:11 with gcc 4.7.2
D V D  h264            H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
D V D  h264_vdpau      H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)
EV    libx264         libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10

# avconv -i 838.MOV -vf transpose=1 -c:v libx264 -crf 23 -c:a copy 838.m4v

Or use mencoder (quality might be worse):

# apt-get install mencoder

# mencoder 827.MOV -vf rotate=1 -oac pcm -ovc x264 -o 827.MP4

The rotate / transpose settings: http://libav.org/libavfilter.html#transpose
** rotate 1 =  90 degrees clockwise

TODO:

Is there a good way to tell the video is flipped without looking at it.  Probably looking at the width and height dimensions (1280x720) but I have not looked into it further.


# avconv -i 838.MOV 2>&1 | grep Video:
Stream #0.0(und): Video: h264 (Baseline), yuv420p, 1280x720, 10722 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 1200 tbc

# avconv -i 838.m4v 2>&1 | grep Video:
Stream #0.0(und): Video: h264 (Main), yuv420p, 720x1280, 1184 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc

Comments Off on Rotate Video
comments

Dec 20

Nautilus Mount Windows Share

I have successfully used the Gnome Nautilus browser in the past to mount Windows as well as Microsoft DFS shares.

The File > Connect To Server > Windows Share and filling out the form should suffice for a normal server.  For a DFS mount I normally go to Bookmarks > Edit bookmarks and add a short cut:

Name: US
Location: smb://domain.com;rrosso@domain.com/corp/US

This should work fine.  However recently I had issues with this on Ubuntu 12.10 64-bit.  The Nautilus mount kept asking for the password.  If you do have this issue you can try using the command line first:

~$ smbclient \\\\server1\\Docs -U rrosso -W domain <your_password>

or

~$ gvfs-mount smb://server1/Docs

If that does work for you but Nautilus does not you might need to add one or all of the following settings to /etc/samba/smb.conf:

# more /etc/samba/smb.conf
 ...
 [global]
 client use spnego = no
 client lanman auth = yes
 client ntlmv2 auth = no
 ...

Comments Off on Nautilus Mount Windows Share
comments

Dec 18

Mutt Mass Delete

From time to time I still use mutt to check or delete mail. For instance where I only have terminal access to a root account and something caused the account to collect thousands of e-mail.  Here is how to delete a lot of mutt e-mail.

In the main screen press D (shift + d)
Delete messages matching: ~s .*

~s will search the subject for the given expression and ".*" is a global regex wild card

All messages will now be marked for deletion.  Press q and y to confirm.

Comments Off on Mutt Mass Delete
comments

Dec 12

Ssh and Scp through intermediate host

Quick way to use ssh / scp through an intermediate host.

~$ cat .ssh/config
Host rrhome
User    rrosso
HostName x.x.x.x
ProxyCommand    ssh rrosso@dmzhostname nc %h %p 2> /dev/null

~$ scp rrhome:/ts/hdpvrgrab/output.ts ./

Comments Off on Ssh and Scp through intermediate host
comments

Nov 23

Dell Drac Console Repeating Keys

I have had issues using Dell Drac’s on some servers. It appears to be related to high latency network connections.

Sometimes it is important to login to a Hypervisor Linux console and it is impossible if your keys repeat and you try to login as rrrooooottttt. Believe me I thought it was mildly amusing trying to get logged in like that but no dice. Hint: You can’t see the password.

It is possible this issue could be related to the Windows client.  I was using a Windows 7 client in a Virtualbox VM and I am not 100% sure but someone else was able to connect from a KVM client without the keys repeating. I played with a lot of options to fix this and some people had luck with setterm on the command line.

setterm -repeat off

However I need the repeating keys fixed before login and not after we logged in so above would not work for me. Also I could not get setterm to work, no matter where I tried inserting the command during OS startup. Options are:
- Change the getty for the virtual console in inittab or wherever the OS runs getty. In our case with Ubuntu upstart in /etc/init/tty[1|8].conf. The idea is to pass the –I variable to getty with a command string.
- Run setterm in rc.local or wherever newer flavors of Linux want to run custom command on startup.
- Kernel parameter with atkbd.reset= or something similar although it sounded like the kernel developers gave up on this idea. I am not sure.

I finally had some success by sending raw codes to the terminal direct ie not using setterm. So for instance sending the virtual console a keycode to change the foreground color to green as follow:

# echo -en "\\033[32m\\033[8]" > /dev/tty1

The following command which appears is for DEC terminals did work.

Turn on:

# echo -en "\\033[?8h" > /dev/tty1

Turn off:

# echo -en "\\033[?8l" > /dev/tty1

More codes here: http://linux.about.com/library/cmd/blcmdl4_console_codes.htm

So I ended up adding below to INKVM001 to give us a green and no key repeat virtual console on tty4:

# tail -1 console-setup.conf
 exec echo -en "\\033[32m\\033[8\\033[?8l" > /dev/tty4

To access different virtual console you just use Alt-F# when in text mode and Ctrl-Alt-F# when in a graphics mode. In this case the Drac menu can send the an Alt-F4 macro and you will have a safe (and green) login terminal which will not drive you innnnsssssannnnneeeee.

Other commands I was playing with just for reference:

# dpkg-reconfigure keyboard-configuration

setterm -blank 0 -powerdown 0 -powersave off > /dev/tty${index}

exec /sbin/getty -I `setterm -clear all -foreground yellow -bold -store` -8 38400 tty1

# kbdrate -d 1000
 Typematic Rate set to 10.9 cps (delay = 1000 ms)

Links:
http://www.kernel.org/doc/Documentation/kernel-parameters.txt
http://www.win.tue.nl/~aeb/linux/kbd/scancodes-12.html
http://luv.asn.au/overheads/virtualconsoles.html
http://linux.about.com/library/cmd/blcmdl4_console_codes.htm
http://www.linuxquestions.org/questions/linux-general-1/setting-terminal-colors-with-setterm-718290/
http://shallowsky.com/blog/linux/install/ctrl-key-debian-squeeze.html
https://bugzilla.redhat.com/show_bug.cgi?id=181457
http://www.ibiblio.org/pub/Linux/docs/HOWTO/Keyboard-and-Console-HOWTO

Comments Off on Dell Drac Console Repeating Keys
comments

Nov 06

Find and Remove Old Files on Linux

bash-3.00# find FOO/*bar* -mtime +30 -exec ls -lh {} \;
-rwxrwxrwx   1 143      staff        16G Jul 13 04:08 FOO/bar_backup_201207130403.bak
...snip
-rwxrwxrwx   1 143      staff        16G Sep 12 18:34 FOO/bar_backup_201209121827.bak

bash-3.00# find FOO/*bar* -mtime +30 -exec rm -f {} \;

bash-3.00# find FOO/*bar* -mtime +30 -exec ls -lh {} \;

Comments Off on Find and Remove Old Files on Linux
comments