Tag Archives: ubuntu

Ubuntu 16.04 GUI remote login

This a script that setup your ubuntu machine with GUI to share the main login screen (like a Windows RDP connection), using x11vnc software.

It installs x11vnc, create a startup service, enable it and reboot the box for you.

    # ##################################################################
    # Script Name : vnc-startup.sh
    # Description : Perform an automated install of X11Vnc
    # Configure it to run at startup of the machine 
    # Date : Feb 2016
    # Written by : Griffon 
    # Web Site :http://www.c-nergy.be - http://www.c-nergy.be/blog
    # Version : 1.0
    #
    # Disclaimer : Script provided AS IS. Use it at your own risk....
    #
    # #################################################################

    # Step 1 - Install X11VNC 
    # ################################################################# 
    sudo apt-get install x11vnc -y

    # Step 2 - Specify Password to be used for VNC Connection 
    # #################################################################

    sudo x11vnc -storepasswd /etc/x11vnc.pass

    # Step 3 - Create the Service Unit File
    # #################################################################

    cat > /lib/systemd/system/x11vnc.service << EOF
    [Unit]
    Description=Start x11vnc at startup.
    After=multi-user.target

    [Service]
    Type=simple
    ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared

    [Install]
    WantedBy=multi-user.target
    EOF

    # Step 4 -Configure the Service 
    # ################################################################

    echo "Configure Services"
    sudo systemctl enable x11vnc.service
    sudo systemctl daemon-reload

    sleep 10

    # Step 5 - Restart System 
    # ################################################################
    sudo shutdown -r now

Source: http://c-nergy.be/blog/?p=8984

Improve/Ubuntu-like Font Rendering in Debian using Infinality Font

/etc/apt/sources.list

#Infinality Fonts
deb http://ppa.launchpad.net/no1wantdthisname/ppa/ubuntu saucy main

apt-get install fontconfig-infinality

cd /etc/fonts/infinality/
bash infctl.sh setstyle

chose 3 (i.e. linux).

In /etc/profile.d/infinality-settings.sh --> search for “USE_STYLE” or scroll (around line 710) till you see the option to set the style => USE_STYLE=”UBUNTU”


Settings -> Appearance.

    Tick the checkbox to Enable anti-aliasing
    Set Sub-pixel order to RGB
    Set Hinting to Slight


======================================

Personally installed before also: cabextract fonts-liberation ttf-mscorefonts-installer


======================================

Other fonts:

1) Install pretty fonts (you'll need non-free for mscorefonts): apt-get install ttf-dejavu ttf-liberation ttf-mscorefonts-installer xfonts-terminus
2) dpkg-reconfigure fontconfig-config, select Autohinter, Automatic and No
3) dpkg-reconfigure fontconfig
4) Restart Xorg
5) Gnome-specific (these are largely personal preferences): System -> Preferences -> Appearances -> Fonts: Enable 'Best Shapes', Details -> Dots per Inch: 110, Smoothing -> Grayscale

======================================

Source: http://linuxpanda.wordpress.com/2014/03/14/improve-ubuntu-like-font-rendering-in-debian-using-infinality-font/

Rackspace – Reinstall Nova-Agent

apt-get purge nova-client
apt-get update && apt-get upgrade

Used this script to re-install nova-agent: https://github.com/rackerlabs/openstack-guest-agents-unix/blob/master/tools/nova-agent-builder.sh

>> extract the tar and ./install.sh

sed '1i### BEGIN INIT INFO\n# Provides: Nova-Agent\n# Required-Start: $remote_fs $syslog\n# Required-Stop: $remote_fs $syslog\n# Default-Start: 2 3 4 5\n# Default-Stop: 0 1 6\n# Short-Description: Start daemon at boot time\n# Description: Enable service provided by daemon.\n### END INIT INFO\n' /usr/share/nova-agent/1.39.1/etc/generic/nova-agent > /usr/share/nova-agent/1.39.1/etc/generic/nova-agent.lsb

cp /usr/share/nova-agent/1.39.1/etc/generic/nova-agent.lsb /etc/init.d/nova-agent

chmod +x /etc/init.d/nova-agent

service xe-linux-distribution stop
service xe-linux-distribution start
service nova-agent start

# ps aux | grep nova
root      7874  0.0  0.7 143984  7464 ?        Ssl  09:02   0:00 /usr/sbin/nova-agent -q -p /var/run/nova-agent.pid -o /var/log/nova-agent.log -l debug /usr/share/nova-agent/nova-agent.py
root      7890  0.0  0.0  11980   928 pts/0    S+   09:03   0:00 grep --color=auto nova


Sources:
http://www.syntheticworks.com/rackspace-cloud/linux-rackspace-cloud/all-about-nova-agent-linux/
https://github.com/rackerlabs/openstack-guest-agents-unix/blob/master/tools/nova-agent-builder.sh
http://bootrackspacecom.readthedocs.org/en/latest/nova_agent/

Apache 2.4 + PHP-FPM Ubuntu 14.04

apt-get install php5-mysql php5-fpm php5-gd php5-cli apache2-mpm-worker libapache2-mod-fastcgi

Create a php-fpm pool /etc/php5/fpm/pool.d/$USER.cnf

[$USER]
user = $USER
group = www-data
listen = 127.0.0.1:9000
listen.owner = www-data
listen.group = www-data

pm = dynamic
pm.max_children = 100
pm.start_servers = 35
pm.min_spare_servers = 15
pm.max_spare_servers = 35
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session/$USER
chdir = /

In Vhost:

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/vhosts/MYDOMAIN.COM/public_html/$1

Enable/disable modules and restart services

a2dismod mpm_prefork php5 && a2enmod actions fastcgi alias mpm_event proxy_fcgi proxy

service php5-fpm restart
service apache2 restart

Don’t forget to enable “index.php” in your DirectoryIndex directive, if using PHP-FPM! Also, remove any PHP directives from Apache, and configure in PHP-FPM instead.

Dynamic DNS update script

Below a script that I’ve created to update your Dynamic DNS service.

It has been tested on Raspian (Raspberry Pi), Ubuntu 18.04 and Debian 9.

It works with Internet.bs, No-ip.com and CloudFlare

https://bitbucket.org/thtieig/dynip_update/src/master/

Also, for who as a router running DD-WRT, here a quick article about how to set it up.

Enjoy! 😉

Minimal X server – Less then 1.2GB

Packages required:

apt-get install xinit blackbox menu xterm xdm

Full list of packages installed (including dependencies):

<code>blackbox fontconfig-config libaudit0 libbt0 libdrm-intel1 libdrm-nouveau1a libdrm-radeon1 libdrm2 libffi5 libfontconfig1 libfontenc1 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libice6 libmtdev1 libpciaccess0 libpixman-1-0 libsm6 libutempter0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-glx0 libxcb-shape0 libxcb-util0 libxcomposite1 libxdamage1 libxfixes3 libxfont1 libxft2 libxi6 libxinerama1 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1 libxt6 libxtst6 libxv1 libxvmc1 libxxf86dga1 libxxf86vm1 menu ttf-dejavu-core x11-common x11-utils x11-xkb-utils xbitmaps xfonts-base xfonts-encodings xfonts-utils xinit xserver-common xserver-xorg xserver-xorg-core xserver-xorg-input-all xserver-xorg-input-evdev xserver-xorg-input-mouse xserver-xorg-input-synaptics xserver-xorg-input-vmmouse xserver-xorg-input-wacom xserver-xorg-video-all xserver-xorg-video-apm xserver-xorg-video-ark xserver-xorg-video-ati xserver-xorg-video-chips xserver-xorg-video-cirrus xserver-xorg-video-fbdev xserver-xorg-video-i128 xserver-xorg-video-intel xserver-xorg-video-mach64 xserver-xorg-video-mga xserver-xorg-video-neomagic xserver-xorg-video-nouveau xserver-xorg-video-openchrome xserver-xorg-video-r128 xserver-xorg-video-radeon xserver-xorg-video-rendition xserver-xorg-video-s3 xserver-xorg-video-s3virge xserver-xorg-video-savage xserver-xorg-video-siliconmotion xserver-xorg-video-sis xserver-xorg-video-sisusb xserver-xorg-video-tdfx xserver-xorg-video-trident xserver-xorg-video-tseng xserver-xorg-video-vesa xserver-xorg-video-vmware xserver-xorg-video-voodoo xterm cpp cpp-4.7 libgmp10 libmpc2 libmpfr4 libxcursor1 x11-xserver-utils xdm</code>

I personally needed a light editor, possibly not related to KDE or Gnome (which generally means plenty of packages installed).
I found Leafpad, which does the job. So, I generally install it as well:

With these packages, you should have a very light X environment, with xterm, a basic text editor and a basic bar with workspaces and current time.
Super basic. Super light. Super Functional. 🙂

I liked also to customise the menu, because the default one was too messy for me.

To do this, create a .blackboxrc file if not present in your home directory.
After, just add the following:

session.menuFile: ~/.blackbox/blackbox-menu

Of course, make sure to have also a folder called .blackboxand the file blackbox-menu customised like this one:

[begin] (MinimalMenu)
[exec] (XTerm) {xterm}
[exec] (LeafPad) {/usr/bin/leafpad}
[submenu] (Blackbox)
[config] (Configuration)
[submenu] (Styles)
[stylesdir] (~/.blackbox/styles)
[sep]
[stylesdir] (/usr/share/blackbox/styles)
[end]
[workspaces] (Workspaces)
[sep]
[reconfig] (Reconfigure)
[restart] (Restart)
[exit] (Exit)
[end]
[end]

Otherwise, you can always start using a copy of the default one:

cp /etc/X11/blackbox/blackbox-menu ~/.blackbox/blackbox-menu

Here you go! Enjoy! 😉

Raspberry Pi Emulator on Ubuntu 12.04 LTS

You have two options:

  1. Use a Ubuntu Desktop version with Gnome environment already preinstalled (do you really need all that crap?!)
  2. Install a brand new Ubuntu server 12.04 x64 LTS, basic, without Gnome or any super fancy packages… just a basic installation with SSH (suggested but not required). And after, just follow the post here to install a “Minimal X server”.If you want to change a bit the look of the login screen, you can have a look to this post.
    This is what I’ve done 🙂

Please note that a graphic environment is REQUIRED for this emulator to work.

Compile and install QEMU

Packages:

sudo apt-get install git zlib1g-dev libsdl1.2-dev libpixman-1-dev

Working directory:

mkdir ~/raspidev && cd ~/raspidev/
git clone git://git.qemu-project.org/qemu.git

It will take a while

Once done:

cd qemu
./configure --help

Read the output carefully (options of interest highlighted):

Usage: configure [options]
Options: [defaults in brackets after descriptions]

Standard options:
--help                   print this message
<span style="color: #0000ff;">--prefix=PREFIX          install in PREFIX [/usr/local]</span>
--interp-prefix=PREFIX   where to find shared libraries, etc.
use %M for cpu name [/usr/gnemul/qemu-%M]
<span style="color: #0000ff;">--target-list=LIST       set target list (default: build everything)</span>
Available targets: i386-softmmu x86_64-softmmu
<span style="color: #0000ff;">arm-softmmu</span> cris-softmmu lm32-softmmu m68k-softmmu
microblaze-softmmu microblazeel-softmmu mips-softmmu
mipsel-softmmu mips64-softmmu mips64el-softmmu
ppc-softmmu ppcemb-softmmu ppc64-softmmu sh4-softmmu
sh4eb-softmmu sparc-softmmu sparc64-softmmu
s390x-softmmu i386-linux-user x86_64-linux-user
alpha-linux-user <span style="color: #0000ff;">arm-linux-user</span> armeb-linux-user
cris-linux-user m68k-linux-user
microblaze-linux-user microblazeel-linux-user
mips-linux-user mipsel-linux-user ppc-linux-user
ppc64-linux-user ppc64abi32-linux-user
sh4-linux-user sh4eb-linux-user sparc-linux-user
sparc64-linux-user sparc32plus-linux-user
unicore32-linux-user s390x-linux-user

Advanced options (experts only):
--source-path=PATH       path of source code [/home/shift/openembedded/qemu]
--cross-prefix=PREFIX    use PREFIX for compile tools []
--cc=CC                  use C compiler CC [gcc]
--host-cc=CC             use C compiler CC [gcc] for code run at
build time
--extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
--extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
--make=MAKE              use specified make [make]
--install=INSTALL        use specified install [install]
--python=PYTHON          use specified python [python]
--static                 enable static build [no]
--mandir=PATH            install man pages in PATH
--datadir=PATH           install firmware in PATH
--docdir=PATH            install documentation in PATH
--bindir=PATH            install binaries in PATH
--sysconfdir=PATH        install config in PATH/qemu
--enable-debug-tcg       enable TCG debugging
--disable-debug-tcg      disable TCG debugging (default)
--enable-debug           enable common debug build options
--enable-sparse          enable sparse checker
--disable-sparse         disable sparse checker (default)
--disable-strip          disable stripping binaries
--disable-werror         disable compilation abort on warning
--disable-sdl            disable SDL
<span style="color: #0000ff;">--enable-sdl             enable SDL</span>
--disable-vnc            disable VNC
--enable-vnc             enable VNC
--enable-cocoa           enable COCOA (Mac OS X only)
--audio-drv-list=LIST    set audio drivers list:
Available drivers: oss alsa sdl esd pa fmod
--audio-card-list=LIST   set list of emulated audio cards [ac97 es1370 sb16 hda]
Available cards: ac97 es1370 sb16 cs4231a adlib gus hda
--block-drv-whitelist=L  set block driver whitelist
(affects only QEMU, not qemu-img)
--enable-mixemu          enable mixer emulation
--disable-xen            disable xen backend driver support
--enable-xen             enable xen backend driver support
--disable-brlapi         disable BrlAPI
--enable-brlapi          enable BrlAPI
--disable-vnc-tls        disable TLS encryption for VNC server
--enable-vnc-tls         enable TLS encryption for VNC server
--disable-vnc-sasl       disable SASL encryption for VNC server
--enable-vnc-sasl        enable SASL encryption for VNC server
--disable-vnc-jpeg       disable JPEG lossy compression for VNC server
--enable-vnc-jpeg        enable JPEG lossy compression for VNC server
--disable-vnc-png        disable PNG compression for VNC server (default)
--enable-vnc-png         enable PNG compression for VNC server
--disable-vnc-thread     disable threaded VNC server
--enable-vnc-thread      enable threaded VNC server
--disable-curses         disable curses output
--enable-curses          enable curses output
--disable-curl           disable curl connectivity
--enable-curl            enable curl connectivity
--disable-fdt            disable fdt device tree
--enable-fdt             enable fdt device tree
--disable-check-utests   disable check unit-tests
--enable-check-utests    enable check unit-tests
--disable-bluez          disable bluez stack connectivity
--enable-bluez           enable bluez stack connectivity
--disable-slirp          disable SLIRP userspace network connectivity
--disable-kvm            disable KVM acceleration support
--enable-kvm             enable KVM acceleration support
--disable-nptl           disable usermode NPTL support
--enable-nptl            enable usermode NPTL support
--enable-system          enable all system emulation targets
--disable-system         disable all system emulation targets
--enable-user            enable supported user emulation targets
--disable-user           disable all user emulation targets
--enable-linux-user      enable all linux usermode emulation targets
--disable-linux-user     disable all linux usermode emulation targets
--enable-darwin-user     enable all darwin usermode emulation targets
--disable-darwin-user    disable all darwin usermode emulation targets
--enable-bsd-user        enable all BSD usermode emulation targets
--disable-bsd-user       disable all BSD usermode emulation targets
--enable-guest-base      enable GUEST_BASE support for usermode
emulation targets
--disable-guest-base     disable GUEST_BASE support
--enable-user-pie        build usermode emulation targets as PIE
--disable-user-pie       do not build usermode emulation targets as PIE
--fmod-lib               path to FMOD library
--fmod-inc               path to FMOD includes
--oss-lib                path to OSS library
--enable-uname-release=R Return R for uname -r in usermode emulation
--sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9
--disable-uuid           disable uuid support
--enable-uuid            enable uuid support
--disable-vde            disable support for vde network
--enable-vde             enable support for vde network
--disable-linux-aio      disable Linux AIO support
--enable-linux-aio       enable Linux AIO support
--disable-attr           disables attr and xattr support
--enable-attr            enable attr and xattr support
--enable-io-thread       enable IO thread
--disable-blobs          disable installing provided firmware blobs
--enable-docs            enable documentation build
--disable-docs           disable documentation build
--disable-vhost-net      disable vhost-net acceleration support
--enable-vhost-net       enable vhost-net acceleration support
--enable-trace-backend=B Set trace backend
Available backends: nop simple stderr ust dtrace
--with-trace-file=NAME   Full PATH,NAME of file to store traces
Default:trace-<pid>
--disable-spice          disable spice
--enable-spice           enable spice
--enable-rbd             enable building the rados block device (rbd)
--disable-smartcard      disable smartcard support
--enable-smartcard       enable smartcard support
--disable-smartcard-nss  disable smartcard nss support
--enable-smartcard-nss   enable smartcard nss support
--disable-usb-redir      disable usb network redirection support
--enable-usb-redir       enable usb network redirection support
--disable-guest-agent    disable building of the QEMU Guest Agent
--enable-guest-agent     enable building of the QEMU Guest Agent

NOTE: The object files are built at the place where configure is launched

Easiest way:

./configure --help | egrep -i "PREFIX|everything|arm-softmmu|arm-linux-user|SDL"

Then, compile and install:

make
sudo make install

Check that all is fine:

qemu-system-arm -cpu ?

The output should contain ‘arm1176‘. If all is good, go to the next steps. 😉

 

Create the emulation environment

cd ~
mkdir raspemu && cd raspemu

Get the linux kernel:

wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu

Download a raw image of Raspberry Pi from here and save in the same folder

wget http://downloads.raspberrypi.org/raspbian_latest

If you want to play a bit with it, you might need to pre-expand the file size, in order to have some extra space (by default you have only 200 Mb free on the current image).
For this, you can use the following commands, to add 2GB to the image:

dd if=/dev/zero bs=1M count=2048 >> path/your_image.img

Then, launch your qemu, and inside the console, try to useraspi-config script to automatically expand the filesystem.
Otherwise, try the following to do it manually (not tested):

PART_START=$(parted /dev/sda -ms unit s p |grep “^2? | cut -f 2 -d:)
echo $PART_START # (to be sure that it’s not empty).
fdisk /dev/sda <<EOF
p
d
2
n
p
2
$PART_START
p
w
EOF

Then reboot and launch resize2fs /dev/root
Now, you’re ready for the first boot.
Create a script called first_boot.sh with the following:

qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -hda <strong>$1</strong>

Remember to setchmod +xto this file and do not try to use more than 256 MB of RAM, the value is hard-coded in and QEMU will not work correctly.

After you can easily use this syntax to start your image:

./first_boot.sh path/your_image.img

Comment the line/usr/lib/arm-linux-gnueabihf/libcofi_rpi.soin the file/etc/ld.so.preloadand reboot.
Alternatively create a file/etc/udev/rules.d/90-qemu.ruleswith the following content:

KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"

The kernel sees the disk as /dev/sda, while a real pi sees /dev/mmcblk0. This will create symlinks to be more consistent with the real pi.

Once done, you can create a new script called start.sh with the following content:

qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda <strong>$1</strong>

And now, finally, we can run our image of Raspberry Pi running:

./start.sh path/your_image.img

NOTE: use first_boot.sh script ONLY with a brand new image. If you’re using a copy of your Pi, maybe made using dd command, just use start.sh script.

Sources:

http://xecdesign.com/compiling-qemu/
http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/