Johan Känngård » Linux http://johankanngard.net Useful tips for developers Thu, 19 May 2011 18:40:56 +0000 en hourly 1 http://wordpress.org/?v=3.0.1 HOWTO Restart shoutcast if inbound stream is lost http://johankanngard.net/2008/10/21/howto-restart-shoutcast-if-inbound-stream-is-lost/ http://johankanngard.net/2008/10/21/howto-restart-shoutcast-if-inbound-stream-is-lost/#comments Tue, 21 Oct 2008 14:31:58 +0000 Johan Känngård http://johankanngard.net/?p=325 This is a simple way to get Shoutcast restarted (tested in Ubuntu 8.04) if the inbound stream is lost. You need Lynx installed for this to work, there might be better ways of achieving the same result though. To install Lynx:


$ sudo apt-get install lynx

Put in file shoutcast_supervisor.sh in /usr/bin:

#!/bin/bash
ONLINE=$(lynx -dump localhost:8000 | grep "Stream is up" | wc -l)
if [ "$ONLINE" -eq "0" ]
then
logger -i Inbound connection not found. Restarting Shoutcast.
/etc/init.d/shoutcast restart
fi

Change ownership, group and execution:

$ sudo chown root /usr/bin/shoutcast_supervisor.sh
$ sudo chgrp root /usr/bin/shoutcast_supervisor.sh
$ sudo chmod +x /usr/bin/shoutcast_supervisor.sh

Add the script to cron.d your preferred way, I do it in /etc/cron.d in a file name shoutcast_supervisor:

0 * * * * root /usr/bin/shoutcast_supervisor.sh
15 * * * * root /usr/bin/shoutcast_supervisor.sh
30 * * * * root /usr/bin/shoutcast_supervisor.sh
45 * * * * root /usr/bin/shoutcast_supervisor.sh

Restart cron:

$ sudo /etc/init.d/cron restart

…and the script is run every 15 minutes and will restart the Shoutcast daemon if the inbound connection was lost. Change the interval if you need to check more often. Sometimes this solves connection problems. Check the syslog for any message that the daemon was restarted, like:

$ tail /var/log/syslog

]]>
http://johankanngard.net/2008/10/21/howto-restart-shoutcast-if-inbound-stream-is-lost/feed/ 0
HOWTO Use Lotus Notes, Domino Designer and Domino Administrator 8.01 on Ubuntu 8.04 via Wine 1.0.0 http://johankanngard.net/2008/09/01/howto-use-lotus-notes-domino-designer-and-domino-administrator-801-on-ubuntu-804-via-wine-100/ http://johankanngard.net/2008/09/01/howto-use-lotus-notes-domino-designer-and-domino-administrator-801-on-ubuntu-804-via-wine-100/#comments Mon, 01 Sep 2008 20:09:28 +0000 Johan Känngård http://johankanngard.net/?p=294 I just followed Julian’s excellent guide and it worked! Even though the guide was for previous versions of both Notes, Ubuntu and Wine, I did not have to make any additional steps to get it working. All programs works, I haven’t found anything that is broken (yet), and it’s great having the Designer “directly” in Ubuntu instead of firing up VirtualBox.

Thanks Julian, for your excellent guide!

]]>
http://johankanngard.net/2008/09/01/howto-use-lotus-notes-domino-designer-and-domino-administrator-801-on-ubuntu-804-via-wine-100/feed/ 2
Bash Variables Cheat Sheet http://johankanngard.net/2008/07/31/bash-variables-cheat-sheet/ http://johankanngard.net/2008/07/31/bash-variables-cheat-sheet/#comments Thu, 31 Jul 2008 08:49:34 +0000 Johan Känngård http://johankanngard.net/?p=248 For a complete list, see Bash Reference Manual – Bash Environment Variables. This is just my own memory-dump. To get the value of a variable, you can use:

echo $OLDPWD

OLDPWD
previous current directory
PWD
current directory
LANG
the language used by programs, check with locale -a for available locales. Can be set in .bash_profile with export LANG=”en_US.utf8″
LANGUAGE
the language used by programs, check with locale- a for available locales. Can be set in .bash_profile with export LANGUAGE=”en_US.utf8″
RSYNC_RSH
the shell used for rsync, usually /usr/bin/ssh
]]>
http://johankanngard.net/2008/07/31/bash-variables-cheat-sheet/feed/ 0
Linux Directories and Files Cheat Sheet http://johankanngard.net/2008/07/31/linux-directories-and-files-cheat-sheet/ http://johankanngard.net/2008/07/31/linux-directories-and-files-cheat-sheet/#comments Thu, 31 Jul 2008 08:10:30 +0000 Johan Känngård http://johankanngard.net/?p=234 Just a memory dump for important files and directories.

~/.bashrc
runs on interactive login
~/.bash_aliases
runs from .bashrc (if uncommented…)
~/.emacs
Emacs settings
/etc/crontab
file that controls scheduled running of scripts
/etc/cron.d/hourly, daily, weekly, monthly
for running scripts on a scheduled basis
/etc/group
groups in the system
/etc/hosts
hard-coded hosts like in Windows.
/etc/motd
the greetings text when logging into the system
/etc/resolv.conf
DNS hosts
/etc/sudoers
users and groups that can do sudo. Edit via sudo visudo.
/etc/syslog.conf
log configuration (cron etc)
/etc/init.d/
daemon control files. To remove from startup, use sudo /etc/init.d/XYZ stop, sudo update-rc.d -f XYZ remove. To start manually: sudo /etc/init.d/XYZ start
/etc/init.d/gdm
Gnome Desktop Manager.
/etc/rcS
file run at system start. Runs the files in /etc/rcX.d depending on run level
/etc/rcX.d/
files that are run from /etc/rcS depending on run level. See The Linux Boot Process Explained
/var/log/
log files
/var/run/
lock files and run-time information
/etc/apt/sources.list
the list of URLs for apt-get for upgrading / installing packages

Also see Filesystem Hierarchy Standard.

]]>
http://johankanngard.net/2008/07/31/linux-directories-and-files-cheat-sheet/feed/ 0
Linux Commands Cheat Sheet http://johankanngard.net/2008/07/31/linux-commands-cheat-sheet/ http://johankanngard.net/2008/07/31/linux-commands-cheat-sheet/#comments Thu, 31 Jul 2008 07:48:45 +0000 Johan Känngård http://johankanngard.net/?p=229 There are a lot of these on the net. Why not one more? :-) I will try to keep this updated. Some commands are shell-specific (I use bash), and some are application specific, like the Apache commands.

a2enmod
enable apache module
a2dismod
disable apache module
a2ensite
enable apache site
a2dissite
disable apache site
apt-get
upgrades Debian/Ubuntu. Do sudo apt-get update first to update info, then sudo apt-get upgrade to get new version of installed files. To install a specific package, use sudo apt-get install foo, where foo is the package name.
alias
creates an alias of a command in the shell
awk
see gawk
cat
show / concatenates files
cd
change current directory
cd ~ / cd
go to home directory
cd -
go to previous directory
chgrp
changes a group of a file
chmod
changes the access rights of a file
chown
changes owner of a file
clear
clears the screen
cp
copies files
cut
cuts lines into (like @SubSet in @Forula)
date
shows the time and date
dd
convert and copy files
df
disk / partition info
dhclient
dhcp-client, use dhclient -r to release, and only dhclient to renew
dig
DNS entries
du
show directory / file sizes, use du -sh / to show total size and in “human-readable” form.
echo
prints characters
ed
text editor
emacs
text editor
exit
logs out (also CTRL-D)
fdisk
disk handling. Can list devices via fdisk -l
fg
moves a background program to the foreground
find
find files in the filesystem. Go to the directory where you want to find the file, use “find -name hosts” to find files named hosts.
ftp
file transfer utility (use scp or sftp instead)
fsck
filesystem check
fuser
shows who and what process is using a specific file or file system. Good when you want to unmount a drive. For example, fuser /media/cdrom shows the process and user that is using the cdrom and fuser -k /media/cdrom kills the associated process
gawk
reads records and fields from a file. Or words.
gpasswd
manages /etc/group
grep
searches a file for a regular expression pattern. grep -ir ‘johan’ .finds all files with the text johan, case insensitive and recursively
groupadd
adds a group
groupdel
deletes a group
gzip
compresses files
hcitool
configures BlueTooth connections. Use hcitool search to search for discoverable BlueTooth devices.
hidd
BlueTooth HID daemon. Use sudo hidd –connect XX:XX:XX:XX:XX:XX to connecto to a HID device
id
see your user id and group id’s
ifconfig
network configuration
info
show textinfo files
jobs
lists active jobs
kill
kills a process, use kill %jobno to kill a job. Some jobs may not respond to normal kill, you must use kill -KILL %jobno
less
show contents of files (backward / forward)
ln
creates a link between files
locate
find files in index
logout
logs out (also CTRL-D) or exit
ls
list files / directory
lshal
list HAL devices
lspci
list PCI devices
lsusb
list USB devices
mail
starts the mail program
man
shows manual page for a command
mkdir
creates a directory
mke2fs
formats drives
mkswap
sets up a swap partition
more
show contents of files (only forward)
mount
mounts a filesystem
mv
move or rename
nano
text editor
netstat
shows network connections
nice
handles process priority
ping
pings a host
procinfo
shows memory usage
ps
process status
pwd
print working directory
rm
removes a file
rmdir
removes a directory
passwd
sets log in passwd
route
set the ip routes
run-parts
runs all commands in a directory
scp
secure copy via ssh. Use ” and \ to escape filenames with spaces, like this: “HOWTO\ Create\ SSH\ Keys.txt”
sftp
secure file transfer (use scp if possible instead)
sed
stream editor, replaces strings in streams. Example cat test.txt | sed s/testing/helloworld/, replaces testing with helloworld in text.txt to stdout.
sensors
to read temperatures on motherboard, cpu etc.
shutdown
in SU mode, shutdowns the system, sudo shutdown -r now restarts the system.
sleep
sleeps the specified amount of time
sort
sorts the contents of a file
ssh
secure shell, use it like this: ssh username@host
su
goes to “super user mode” = root. In Ubuntu you have to set a root password first.
sudo
goes to “super user mode” on one command
swapon
activates a swap area
tar
binary to ascii encoder
telnet
telnet session, unsecure, use ssh instead.
top
monitors processes
touch
creates a new empty file or changes the date of an existing file
traceroute
traces ip hosts
tree
shows a tree of the filesystem
umount
umounts a filesystem
unalias
removes an alias
uname
shows information about the current system
unzip
decompresses ZIP files
update-rc.d
adds something to startup (Debian)
uptime
shows the uptime for the server
useradd
add a user
userdel
remove a user
usermod
modify a user
users
lists the users currently logged into the computer
vi
text editor
vmstat
shows memory usage
w
shows who are logged on and what they are doing
wait
waits for a job to finish
watch
runs a command every 2 seconds until CTRL+C
wc
word count. Also count lines
whatis
short explanation of command
whereis
shows where the specified command is and its related files
which
shows the path to the specified command
who
shows who are logged on
whoami
shows what user I am
write
sends a message to another user
xviddetect
setup video card for X
Xconfigurator
setup for X

Also see the good man-page-like command list at Oreillynet.

]]>
http://johankanngard.net/2008/07/31/linux-commands-cheat-sheet/feed/ 0
HOWTO: Install Shoutcast 1.9.8 on Ubuntu 8.0.4 http://johankanngard.net/2008/07/22/howto-install-shoutcast-on-ubuntu-804/ http://johankanngard.net/2008/07/22/howto-install-shoutcast-on-ubuntu-804/#comments Tue, 22 Jul 2008 13:31:21 +0000 Johan Känngård http://johankanngard.net/?p=218 If you want to stream your own radio station, Shoutcast is an easy solution. This little HOWTO focus only on the server part, and not on the actual audio/feeding client part. I recommend reading ShoutCast Streaming for beginners and Streaming radio with ShoutCast and WinAmp to get the hang of the audio part.

Install

Download the tarball from shoutcast.com.


$ tar -xvf sc_serv_1.9.8_Linux.tar.gz
$ sudo cp sc_serv_1.9.8_Linux/sc_serv /usr/sbin
$ sudo mkdir /etc/shoutcast
$ sudo cp sc_serv.conf /etc/shoutcast

Automatic start

This will make shoutcast start when the server starts. Download the initscript (which I have modified to work in Ubuntu 8.04, source script here).


$ sudo cp shoutcast /etc/init.d/shoutcast
$ sudo update-rc.d /etc/init.d/shoutcast defaults

Check settings

The default sc_serv.conf says logging should go to the current directory. I changed the lines:

LogFile=sc_serv.log
...
W3CLog=sc_w3c.log

into:

LogFile=/var/log/sc_serv.log
...
W3CLog=/var/log/sc_w3c.log

Also, make sure you set a password on the line saying:

Password=changeme

Firewall

If you have a locally installed firewall, you have to open up two ports. First the port mentioned in sc_serv.conf on the line saying:

PortBase=8000

The second is the PortBase + 1, i.e. in the default example above it is 8001. The 8001 port is used to receive data from Winamp or other audio streaming feeder and the 8000 port is used to send streaming audio to listening clients. Make sure both ports are open for TCP and UDP. And don’t forget any hardware firewalls, they have to be opened too.

Restart

Restart the server or do:

$ sudo /etc/init.d/shoutcast start

and try opening localhost:8000 in your browser and you should see the (in-)famous Shoutcast page.

]]>
http://johankanngard.net/2008/07/22/howto-install-shoutcast-on-ubuntu-804/feed/ 0
HOWTO: Install Lotus Domino 7.0.2 on Ubuntu 8.0.4 http://johankanngard.net/2008/07/16/howto-install-lotus-domino-702-on-ubuntu-804/ http://johankanngard.net/2008/07/16/howto-install-lotus-domino-702-on-ubuntu-804/#comments Wed, 16 Jul 2008 09:05:23 +0000 Johan Känngård http://johankanngard.net/?p=196 This minimalistic guide shows how to install Domino 7.0.2 on Ubuntu 8.0.4 server or workstation. I did this on Ubuntu 7, but did not write everything down, which meant learning/searching for the information once more. Please let me know if you have better ways of doing this!

Create a domino user and group


$ sudo useradd -m domino
$ sudo groupadd domino
$ sudo passwd domino

Add required libraries

Domino uses some libraries that is not installed by the standard Ubuntu installation.


$ sudo apt-get install libstdc++5
$ sudo apt-get install libxmu6
$ sudo apt-get install libxp6
$ sudo apt-get install libxp-java
$ sudo apt-get install libxtst6

Install

Unpack the installation file (my is named S7.0.2.tar) and run the linux/domino/install script as root. Use default settings (except user, enter domino), use “Manual setup”.


$ tar -xvf S7.0.2.tar
$ cd S7.0.2/linux/domino
$ sudo install

Change ownerships on files

Since you installed as root, the files is owned by root. I guess if install was run as the domino user, this step would not be required.


$ sudo chown -R domino /local/notesdata
$ sudo chgrp -R domino /local/notesdata
$ sudo chown -R domino /opt/ibm
$ sudo chgrp -R domino /opt/ibm

Firewall

Stop your local firewall or open 1352 in the local firewall. If you are using shorewall, you can do your own Notes macro. Change the port from 80 to 1352 in the macro.Notes file.


$ sudo cp /usr/share/shorewall/macro.HTTP /usr/share/shorewall/macro.Notes
$ sudo gedit /usr/share/shorewall/macro.Notes

Add the following (depending on setup…) to /etc/shorewall/rules:


Notes/ACCEPT net $FW

Conflicting services

Stop any mail, web, ldap services, so that Domino does not conflict on ports. Remember to disable those you don’t need or disable the Domino services that you don’t need.

$ sudo /etc/init.d/postfix stop
$ sudo /etc/init.d/courier-imap stop
$ sudo /etc/init.d/courier-imap-ssl stop

Relink sh

The server script uses /bin/sh, relink sh to bash that normally links to /bin/dash.


$ sudo rm /bin/sh
$ sudo ln -s /bin/bash /bin/sh

nsd.sh

I got many “Command not found” errors when starting the server first time. After some research, I found that the script requires gawk in sd.sh:

$ sudo apt-get install gawk

Start the server setup listener


$ su notes
$ DISPLAY=:0.0
$ export DISPLAY
$ cd /local/notesdata
$ /opt/ibm/lotus/bin/server -listen

If you want to add a server with existing IDs, put the certifier ID, the server ID and the admin ID in the notesdata directory on the server. Run the Remote Server Setup utility on a client. Usually in Start\Lotus Applications\Remote Server Setup. Configure as a normal setup.

Server startup script

To be able to start Domino on startup, restart it and shutdown when system restarts, you can download domino init.d-script and put in /etc/init.d. Restart the server to see if it works.


$ cd /etc/init.d
$ sudo wget http://johankanngard.net/wp-content/uploads/2008/07/domino
$ sudo chmod +x domino
$ sudo chown domino domino
$ sudo chgrp domino domino
$ sudo update-rc.d domino defaults
$ sudo shutdown -r now

Test

Use a Notes client and test that the server is up and running. To see if the server is running on the server, you use telnet.


$ ps a | grep server
4505 pts/0 Ss+ 0:00 su - domino -c /opt/ibm/lotus/bin/server

You can also try connecting to the server locally with telnet using:


$ telnet localhost 1352
Trying 127.0.0.1...
Connected to localhost.
Escape character is \\\\\\\\\\\\\\\'^]\\\\\\\\\\\\\\\'.

Some links of interest


Updated the startup script since the stop argument wasn’t working.

]]>
http://johankanngard.net/2008/07/16/howto-install-lotus-domino-702-on-ubuntu-804/feed/ 8
Starting with Ubuntu http://johankanngard.net/2006/10/12/starting-with-ubuntu/ http://johankanngard.net/2006/10/12/starting-with-ubuntu/#comments Thu, 12 Oct 2006 13:34:05 +0000 Johan Känngård http://johankanngard.net/2006/10/12/starting-with-ubuntu/ I am about to change my home server from Windows to Linux, and started looking at Ubuntu. It’s very easy to install and manage, and there are lots of good HOWTO’s out there, like “How to set up a mail server on a GNU / Linux system“. I will try getting Domino to run on it too, but time is money these days…
[tags]Ubuntu, Linux[/tags]

]]>
http://johankanngard.net/2006/10/12/starting-with-ubuntu/feed/ 2