Saturday, September 1, 2018

Ubuntu WOL not working anymore after apt-get upgrade

I got a problem on my server that it could not be woken up after I did apt-get upgadre and apt-get dist-upgrade to my system.

Quick googling the problem, I found that doing this would solve the problem. The reference was https://help.ubuntu.com/community/WakeOnLan

Enabling WoL in the NIC

Determining whether the NIC supports WoL

First, determine which NIC will be used, and then check whether it supports the Magic Packet™ using
sudo ethtool 
where is the device name of your NIC, e.g. eth0. This command will output some information about your the capabilities of your NIC. If this output contains a line similar to the following:
Supports Wake-on: 
where  contains the letter g, the NIC should support the WoL Magic Packet™ method (for the other letters look at man ethtool).

Enabling WoL in the NIC

To check whether WoL is enabled in the NIC, one could use
sudo ethtool 
and look for
Wake-on: 
If  contains g and not d, then Magic Packet™ is enabled. However, if  does contain d, WoL needs to be enabled by running the following command:
sudo ethtool -s  wol g
On most systems, issuing this command is required after each boot. If the system's networking is configured via ifupdown, then it is easy to add the line up ethtool -s  wol g below the interface's configuration stanza in /etc/network/interfaces. For example:
shahar@shahar-backup:~$ cat /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface

auto lo
iface lo inet loopback
# The primary network interface

auto eth0
iface eth0 inet static
        address 10.0.0.1
        netmask 255.255.255.0
        gateway 10.0.0.138
        up ethtool -s eth0 wol g

This will ensure that WoL is enabled in the NIC on each boot. Fore more information see the interfaces manual.

However, my network setting was done using Network Manager. I did not dare to follow edit of /etc/network/interfaces since I was afraid it would ruin the network setting. Another googling found this, https://apuntesderootblog.wordpress.com/2015/12/02/enable-wake-on-lan-with-networkmanager/

Enable wake-on-lan with NetworkManager

This little tip enables wake-on-lan on our network interfaces so the computer can be awaken with a magic packet from other host in the same network.
First, identify your connection:
# nmcli connection 
NOMBRE      UUID                                  TIPO            DISPOSITIVO 
virbr0      3ee5c0b6-1030-4609-b087-4ab3d39ccdfa  bridge          virbr0      
br-lan      e7b20dc3-9d8e-4b0e-b56f-27a87f17ebe3  bridge          br-lan      
enp5s0      8581aa55-eead-41d6-a216-41f52b4e0c30  802-3-ethernet  enp5s0      
virbr0-nic  04cc0eff-0b0d-4440-9e7b-1c54418e8ef7  generic         virbr0-ni
Then, activate the wake-on-lan functionality:
# nmcli connection modify enp5s0 802-3-ethernet.wake-on-lan magic
Your BIOS has to support and had enabled waking up from your network card.

Thank you so much for both who provide those references. It as useful for me and I hope also for you.

Friday, February 16, 2018

Swiftmailer cannot work after upgrade php to 5.5


I'm using SwiftMailer to send email by SMTP. The library is working fine when running in the server with PHP version 5.4. However, after upgrading the server to PHP version 5.5, email was not sent and the server threw the following error:
Undefined property: Swift_Transport_StreamBuffer::$_sequence
How can I resolve this issue? Thanks.

Simple solution:
In swift-mailer/classes/Swift/ByteStream/AbstractFilterableInputStream.php change
 private $_sequence = 0;
to
 protected $_sequence = 0;
Then the message goes away.
I must use a different version of Swiftmailer than you in the legacy project I got the exact same error notice. My Swift::VERSION is 4.1.1.

Source of solution: https://stackoverflow.com/questions/26020949/swiftmailer-error-undefined-property-swift-transport-streambuffer-sequence

Friday, January 26, 2018

dpkg cannot find ldconfig/start-stop-daemon in the PATH variable


I have this problem in my ubuntu server 11.04,

Preconfiguring packages ...
dpkg: warning: 'ldconfig' not found in PATH or not executable.
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable.
dpkg: error: 2 expected programs not found in PATH or not executable.
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
E: Sub-process /usr/bin/dpkg returned an error code (2)

And I found the solution from  https://ubuntuforums.org/showthread.php?t=1266104, I adjust it to my ubuntu version.

1. sudo apt-get download libc-bin    // download the library
2. sudo dpkg-deb -x libc-bin*.deb libc-bin-unpacked/              // unpack it
3. sudo cp libc-bin-unpacked/sbin/ldconfig* /sbin/    // copy to sbin folder
--- sometimes, you need to remove old one, I did it using sudo rm -rf /sbin/ldconfig*

4. sudo apt-get -f install
5. sudo dpkg-reconfigure libc-bin
6. sudo apt-get install --reinstall libc-bin

One error now is gone. Another one is solved using guide from https://ubuntuforums.org/showthread.php?t=1919127, Below is the guide:

1. Download the dpkg package from http://launchpadlibrarian.net/63806751/dpkg_1.15.8.10ubuntu1_amd64.deb


2. Copy the file into a temporary location:
mkdir ~/dpgk_temp
cp ~/Downloads/dpgk*.deb ~/dpkg_temp
cd ~/dpgk_temp


3. Extract the files from the archive:
ar x dpkg*.deb
tar xfvz data.tar.gz


4. Copy the file to /sbin:
sudo cp ./sbin/start-stop-daemon /sbin


5. Try update the apt information:
sudo apt-get update
sudo apt-get upgrade



Thank you to those who gives us solution, I just put this in here as my reference.