Relocate your WP website

Move your WordPress website anywhere in 10 minutes via an SSH shell with access to your website files directory and database.

Current URL: example.com/wordpress
Where to: example.com

Or, complete URL change, it doesn’t matter using this method.

Export your WordPress database.

mysqldump -u loginID -p example.com_wp > example.com_wp.sql

Now bust out a little sed.

cat example.com_wp.sql | s/example.com\/wordpress/example.com/g > new.sql

Now import your db sed edits.

mysql -u loginID -p example.com_wp < new.sql

Now move your directory files.

cd /var/www/example.com/wordpress/
tar cvf all.tar *
mv all.tar ../
cd ../
tar xvf all.tar
rm ./wordpress
rm all.tar

Done. Visit example.com

Send CLI commands to syslog

Create a CLI command syslog service

echo "local6.*    /var/log/commands.log" >> /etc/rsyslog.d/bash.conf
systemctl restart rsyslog.service

Set global .bashrc shells to log

vi /etc/bash.bashrc

# log all bash shell sessions globally
export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$(whoami) [$$]: $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" ) [$RETRN_VAL]"'

To test new configuration:

  • Either log out and log back into your shell.
  • Or source bashrc with the command
    source ~/.bashrc
  • Or start a new shell with the command
    bash

Type a few commands… then

tail /var/log/commands.log

Flash OpenWRT to RouterBoard

# No dhcpd or tftpd, no problem. Load OpenWRT firmware on Mikrotik RouterBoards the easy way using dnsmasq. Open two bash shell windows. In the 1st window execute the following and create your loader file:

# FIRST BASH SHELL WINDOW

mkdir -p /var/lib/tftpboot
vi /var/lib/tftpboot/loader.sh

# Create your loader.sh file

#/bin/bash
ifconfig enp6s0 192.168.1.10 up
dnsmasq -i enp6s0 --dhcp-range=192.168.1.100,192.168.1.200 \
--dhcp-boot=openwrt-18.06.1-<your supported routerboard-initramfs>-kernel.bin \
--enable-tftp --tftp-root=/var/lib/tftpboot/ -d -u root -p0 -K --log-dhcp --bootp-dynamic

# Make it executable.

chmod 755 /var/lib/tftpboot/loader.sh

# Ensure both your desired initram AND upgrade image files (2 files) have been moved to the above tftpboot directory. If you forget the corresponding upgrade file, on reboot you’ll find RouterOS is back. Once you’re interfacing with OpenWRT, make sure to manually execute the upgrade in order to purge the RouterOS. It will ensure your OpenWRT kernel sticks and survives power cycles.

# Unplug your ethernet cable that connects the Linux host you are currently on from your current internet router. Then connect this loose end into the WAN/Internet port on your MikroTik Routerboard.

# In your second bash window, execute the following commands: First we determine what the main interface name is that’s using your ethernet connection (in my case its enp6s0). Then we create a virtual interface assigning it an IP address that resides on the 192.168.88.0/24 network.

# SECOND BASH SHELL WINDOW

ifconfig | grep Ethernet | cut -d" " -f1
#enp6s0  <-- e.g. output. You may have more than one listed, its usually the top.
ifconfig enp6s0:0 192.168.88.2 up

# Now telnet to 192.168.88.1 and login (u:admin p:) assuming this is a new Routerboard. Once logged in execute the following two commands (do not close this window.)

/system routerboard settings set boot-device=try-ethernet-once-then-nand
/system routerboard settings set boot-protocol=dhcp

# FIRST BASH SHELL WINDOW

cd /var/lib/tftpboot/
./loader.sh

# Now quickly Unplug the power source from your Routerboard and plug it back in. You should soon see in your FIRST BASH WINDOW dhcp and a tftp directives and the sending of your OpenWRT image to the Routerboard. Give it some time to complete. A sign of completion is you will see OpenWRT dhcp messages in your FIRST BASH WINDOW.

# Once the first flashing is complete, unplug your ethernet cable from the Routerboard WAN port and plug it into its first LAN port. Depending on which Routerboard you have it may vary. You should now be able use a browser and log into OpenWRT via ip address 192.168.1.1. NOTE! you’re NOT FINISHED! Log into OpenWRT and navigate to System> Backup / Flash Firmware. In the Flash new firmware image section click choose file and load the OpenWRT sysupgrade image you stored in /var/lib/tftpboot then click Flash Image. Now your new OpenWRT router will survive reboots.

# Lastly decide to delete, or keep but disable and lock loader.sh until its needed again.

chmod 000 /var/lib/tftpboot/loader.sh
chattr +i /var/lib/tftpboot/loader.sh

# Visual confirmation loader.sh is locked down using lsattr.

# Sample results:
root@host:/var/lib/tftpboot# lsattr
-------------e-- ./openwrt-18.06.1-ramips-mt7621-mikrotik_rbm33g-initramfs-kernel.bin
-------------e-- ./openwrt-18.06.1-ar71xx-mikrotik-rb-nor-flash-16M-squashfs-sysupgrade.bin
-------------e-- ./openwrt-18.06.1-ar71xx-mikrotik-rb-nor-flash-16M-initramfs-kernel.bin
----i--------e-- ./loader.sh
-------------e-- ./openwrt-18.06.1-ramips-mt7621-mikrotik_rbm33g-squashfs-sysupgrade.bin

Linux VR: A whole new world

Safespaces and Linux will lead this space, mark my words.  If you think Facebooks Oculus is cool, this is where not just entertainment is going – but the workplace as well. If you’re upset with today’s society of detached youth in public places staring at their mobile phones, VR Goggles are the next wave. Feeling a fool giving a pair a go, I found the experience quite entertaining. Expecting to see maybe a movie in 3D, it was so much more – playback presented in 180 degree 3D and even 360 degree 3D with HD going higher.

References:

https://www.phoronix.com/scan.php?page=news_item&px=Safespaces-VR-Desktop

Projects:

https://github.com/letoram/safespaces

https://github.com/OpenHMD/OpenHMD