Some errors are hard to trace, especially when no line of error or function/variable is
If you ever ecounter “The plugin generated x characters of unexpected output” in your WordPress plugin development, a simple solution is to include the following line in your function/method:
file_put_contents(__DIR__ . '/activation_log.txt', ob_get_contents());
This will write any output to a file in the current directory where the file containing the function/method resides.
This small guide is meant for those who need to
- clone an existing server/desktop the hard way (for those who lack virtualization tools)
- start from scratch with all packages previously installed (with or without maintaining the personalized settings)
- Get the current installed packages on the main machine: dpkg –get_selections > installed_packages.txt
- Make a copy of your old /etc/apt/sources.list and copy everyting from /etc/apt/sources.list.d/* onto your new machine
- Still on the new new machine, make sure you install dselect: apt-get install dselect
- Update to check for missing keys: apt-get update
- And add the missing keys: apt-key adv –keyserver keyserver.ubuntu.com –recv-keys XXXXXXXX
- Update again: apt-get update
- Register the new packages: dpkg –set-selections < installed_packages.txt
Now the fun part – use dselect to install the missing packages:
- dselect update
- dselect install
If you’d like the same personalized settings, simply copy the config files and folders from your /home/user located on the old machine -> onto the new machine. Same rule applies for other programs (apache, fpm, postfix): copy all files from /etc/apache, /etc/postfix and so on onto the new machine. For the future, using rsync or something similar might come more in handy.
This was the ‘hard way’ of cloning a server. Since the best sysadmin is a lazy sysadmin, you might want to consider Chef/Puppet/Ansible/SaltStack or any virtualization & cloning tool.
For mirroring purposes, this is a working copy-paste of https://madebits.github.io/#blog/2014/2014-12-12-Using-DNSCrypt-on-Ubuntu-14.04.md
DNSCrypt enables making encrypted DNS quires to the DNS providers that support it. There is PPA for DnsCrypt for Ubuntu, but it is not maintained at the time of this writing and it has no binary for Ubuntu 14.04 LTS. To install DNSCryp I used these steps, that I tried on Lubuntu 14.04 LTS:
- Visit DNSCryp PPA packages and download libsodium for trusty and dnscrypt-proxy for saucy (I used the 64 bit version for my machine, you may need the 32 bit versions).
- I used
gdebi-gtk tool to install first
libsodium4_0.4.5-0~trusty5_amd64.deb and then
dnscrypt-proxy_1.4.0-0~oldconf2+saucy1_amd64.deb (you can also use
dnscrypt-proxy runs then locally in address
127.0.0.2 on port
netstat -tuplen to verify).
- The default DNSCryp PPA package
apparmor profile prevents Ubuntu 14.04 from shutting down. To fix that I edited it (
sudo leafpad /etc/apparmor.d/usr.sbin.dnscrypt-proxy) and replacing its content with the following:
# Last Modified: Tue Dec 02 22:20:12 2014
network inet stream,
network inet6 stream,
network inet dgram,
network inet6 dgram,
# In case of custom libsodium installation
# Reasonable pidfile location - tweak this if you prefer a different one
(Ed.) You may want to
which libsodium4 and
which dnscrypt-proxy and check the actual paths.
dnscrypt-proxy configuration for the init service daemon is found in
/etc/default/dnscrypt-proxy. The parameters (with — added) are documented in
man dnscrypt-proxy. I edited
/etc/default/dnscrypt-proxy as root to specify an alternative DNS server. The list of the official available servers can be found in GitHub, or locally in
/usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv. To verify that a given server works use
dig -p 443 @18.104.22.168 google.com (replace ip and port as needed). If you edit
/etc/default/dnscrypt-proxy, you should run
sudo restart dnscrypt-proxy afterwards.
- Verify that
dnscrypt-proxy runs by using
ps -ef | grep dnscrypt. Then verify it can resolve addresses by using
dig @127.0.0.2 google.com (if you configured
dnscrypt-proxy then use
dig +vc @127.0.0.2 google.com).
- If all ok, you can replace you current DNS servers in the Network Manager UI. If you use DHCP, select Automatic (DHCP) addresses only, and set the 127.0.0.2 in Additional DNS servers. Once done, run
sudo service network-manager restart for it to take effect. Verify the server used with
nm-tool | grep -i dns.
End of copy-paste. You could download the latest package of
libsodium and compile it locally – best advice so far.
While giving birth to your first bash scripts, you may encounter various barriers. Today we’ll discuss how to deal with a default value (yes) while updating or upgrading your Linux system.
yes | apt-get upgrade
yes | yum update
y | apt-get upgrade
y | yum update
And so on.
If you clone (make a snapshot) of a CentOS 6 in your RunAbove ControlPanel, you might encounter difficulties placing it online. This is due to the fact that a snapshot is literally a clone, therefore cloning IP and MAC addresses onto the new server. To overcome this, we should…
- Check your old MAC address `ifconfig -a`.
- Login into the new server via VNC and do a `ifconfig -a`
- your interface will show up as `eth1` at this very moment.
- go to `/etc/udev/rules.d/70-persistant-net.rules`.
- Confront the two interfaces eth1/eth0 and
- delete or comment out `eth0`
- modify the `eth1` to `eth0` parameter on the line where you MAC (HWaddr) address resembles the `ifconfig -a` on the cloned server
- Reboot and voila, you’re online.
- Some modifications need to be made
- `/etc/hostname` and enter the corresponding hostname + IP address
- run `hostname your.new.hostname`
- `service network restart` or reboot
Shortcut: simply delete the
/etc/udev/rules.d/70-persistant-net.rules file and reboot :)
Don’t forget! You’re ssh keys will be cloned too. Fork the old putty config for the new server and simply change the IP address. You may want to generate a new login key and add it to .ssh/authorized_keys!
We are going to quickly transfer some folders (recursive) from server1 to server2 through SCP (Secure Copy). Let us spam the std/out/in a little.
scp -2 -P your_custom_ssh_port -r /path/to/target user@server2:/path/to/destination
-2: use protocol 2
-P: use non standard port
your_custom_ssh_port = I hope you’re not using the standard 22!