Smokes your problems, coughs fresh air.

Author: halfgaar (Page 12 of 26)

Halfgaar is Wiebe. Wiebe is a contributing author on this weblog. He also has a lot of stuff (such as long, in-depth articles) on his personal website.

Wiebe's day job is as a senior software developer and system administrator at YTEC.

In his free time, he built the free, open-source FlashMQ software. Together with Jeroen and Rowan, he is now building a managed MQTT hosting business around his open masterpiece.

Bash parameter parsing

Here is a code snippet I use for parameter parsing:

dohelp()
{
  "Example script"
  ""
 
  # Exit because you don't want the script to do anything after
  # displaying help, and do so with error, so that calling scripts won't think it succeeded
  1
}
 
  [ -n "$*" ];
  flag="$1"
  value="$2"
 
  "$flag"
    "--one")
      one="$value"
     
    ;;
    "--two")
      two="$value"
     
    ;;
    "--pretend")
      pretend=true
    ;;
    "--help")
      dohelp
    ;;
    "--")
     
    ;;
    *)
      -e "unknown option $flag\n"
      dohelp
    ;;
 
 

Allowing apache to set Nagios cmd file

On debian, to prevent:

Error: Could not stat() command file ‘/var/lib/nagios3/rw/nagios.cmd’!

Do:

/etc/init.d/nagios3 stop
dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
/etc/init.d/nagios3 start

source.

Setting up pptpd and pptp for a VPN

source and source and source. I’m keeping it as simple as possible.

The serverside LAN in this example is 10.50.0.0/16.

On the server, install pptpd. Then edit /etc/pptpd.conf and set:

# This is the IP the server will have from the clients perspective. SHould be the servers local IP.
localip 10.50.0.1
# And from this range, the client IPs will be given. Here, the range 10.50.91.x is reserved for VPN hosts.
remoteip 10.50.91.1-254

Then edit /etc/ppp/pptpd-options and set options (comments have been removed from this example):

name my-pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
proxyarp
nodefaultroute
lock
nobsdcomp

Then restart pptpd.

Then edit accounts in /etc/ppp/chap-secrets. Example:

user            my-pptpd   password                       *

On the client, /etc/options.pptp (comments once again removed):

lock
noauth
refuse-pap
refuse-eap
refuse-chap
refuse-mschap
nobsdcomp
nodeflate

/etc/ppp/chap-secrets:

user      my-pptpd    password        *

Then make /etc/ppp/peers/johnsvpn:

pty "pptp hostname --nolaunchpppd"
name user
remotename my-pptpd
require-mppe-128
file /etc/ppp/options.pptp
ipparam johnsvpn

You should then be able to turn it on with “pon johnsvpn”. Use poff to turn it off.

To be able to access the entire LAN from the client, run this:

route add -net 10.50.0.0 netmask 255.255.0.0 dev ppp0

More is necessary, like permanent host-to-LAN config (with route pushing or something), DNS, testing if windows works, etc. More is to come.

Making a Compaq Deskpro sff boot without keyboard

To boot a compaq Deskpro sff without keyboard, you need to configure the BIOS in a special way.

I found this:

– Run BIOS setup by pressing F10
– Goto ‘Security’ and ‘Set Power On Password’
– Type in a password and F10 to accept the change
– As soon as password is set, ‘Password Options’ will appear under ‘Security’ tab
– Enable ‘Network Server’ mode in there
– F10 to save changes and exit

When booting up it won’t ask you for F1 anymore. However, if you or
someone else plugs in a keyboard it will ask for a power-on password.

Disabling exim port 25 listening when zimbra is installed

Edit: This doesn’t work anymore I don’t think, because more modern versions check for SMTP conflicts and don’t allow this.

When you’re installing zimbra in an Ubuntu or Debian machine, it seems it installs the MTA in such a way that command line tools like mail and such don’t work. But when you install exim, it conflicts with the postfix in Zimbra.

To fix it, you can install exim4, but configure this line in /etc/default/exim4:

QUEUERUNNER='queueonly'

Zimbra has no shutdown init script on Debian and Ubuntu

There is a K01zimbra in rc6.d for reboot, but not in rc0.d. See this bug report I made.

Workaround:

cd /etc/rc0.d/
ln -s ../init.d/zimbra K01zimbra

I noticed that after an upgrade, the bootscript was gone again, so I made this cron task and put it in cron.daily:

#!/bin/bash
#
# Zimbra bug: no rc0 bootscript: http://bugzilla.zimbra.com/show_bug.cgi?id=54099
#
# The bootscript I put there gets removed upon upgrade, so I put this script in
# place which mails root if it is missing.
#
# The bug is fixed, but in 6.0.10 it still wasn't there, so I don't know when
# it will be included in the release.
#
# Install it in /etc/cron.daily.
 ! [ -e "/etc/rc0.d/K01zimbra" -a -e "/etc/rc6.d/K01zimbra" ];
  message="Kill zimbra bootscript not found in either rc0 (shutdown) or rc6 (reboot)."
  "$message"
  "$message" | mail -s "Zimbra bootscript error" root
« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑