Wednesday, 12 March 2014

Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces ... (warning). SOLVED!!!

I have few Debian servers. (Debian GNU/Linux 6.0 \n \l )

Recently, I had demand to add another ethernet card and assign IP to it. No big deal, right? Right!

But ...

This was my network configuration

-# cat /etc/network/interfaces
 

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 192.168.1.2
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1


So I just append configuration for eth1.

allow-hotplug eth1
iface eth1 inet static
        address 192.168.1.3
        netmask 255.255.255.0
        network 192.168.1.0       



And normally restart network and than ......

#/etc/init.d/networking restart
Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces ... (warning).

and than nothing. Both interface were down. I manually bring then up

#ifup eth0
#ifup eth1

And that worked just fine. I was able to connect thru both IP addresses.
But when I try to restart network using /etc/init.d/networking restart same thing occurred. That was strange because they read same configuration file but from some reason restart do not work and ifup works.

Hm....

After 30 minutes of googling ....

Running either /etc/init.d/networking restart or invoke-rc.d networking restart would run: # ifdown -a
then
# ifup -a

The problem is that ifdown -a will bring down all network interfaces, whereas ifup -a will only bring up any network devices in /etc/network/interfaces that are set to auto, anything with allow-hotplug won't be bought back up until it detects a hotplug event, usually when a network cable is plugged in.

So I add

auto eth0

and

auto eth1

And now /etc/init.d/networking start/restart works fine!!!

Thursday, 6 March 2014

Start/stop/restart alfresco as non root user SOLVED

It is always pain in the ass when you have to start/stop/restart application as root user but you cannot give root password to admin of that application. So how to change/bend this? (Morpheus: Some of them can be bent, others can be broken)

So application is Alfresco(alfresco-4.2.d). You have to be root user to start/stop/restart this application. My application admin do not have root password so he cannot start/stop/restart Alfresco.
Last couple off days, he is testing some new features and he need frequent restart of Alfresco. So he calls me every. And that start to bother me because sometimes I am not there or I am doing something more important. And then he waits and waits.

So how I solve problem for him as non root user to restart alfresco as he is root?


I created a script that will check content of a file that he can write in. Depending of value in that file, alfresco will restart or not.

I called script res_alfresco.sh
Script look like this:

#!/bin/bash
FILE=/location/file.txt
if [ `cat $FILE` == 1 ]
then
echo 1
/etc/init.d/alfresco restart
sleep 10
echo 0 > $FILE
else
echo 0
fi


I put it in crontab for root user and set to run every 2 minutes
*/2 * * * * /opt/scripts/res_alfresco.sh

Value in file has to be 1 for restart.
In case that is 1, restart of alfesco and set write 0 in file. In this case restart will only happen once.

I hope that will help someone.