Ubuntu Auto Upgrade


Configure Ubuntu Auto Upgrade in terminal

  • Install dependencies
  •         sudo apt install unattended-upgrades
          
  • Edit /etc/apt/apt.conf.d/50unattended-upgrades and change the following:
  •         # Enable this setting in Unattended-Upgrade::Allowed-Origins
            "${distro_id}:${distro_codename}-updates";
          
  • To keep /boot folder small
  •         Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
            Unattended-Upgrade::Remove-Unused-Dependencies "true";
          
  • Optional:
  •         # Replace email address with administrator address and insure that email can be sent from cli
            Unattended-Upgrade::Mail "you@some.site";
    
            # Enable auto reboot
            Unattended-Upgrade::Automatic-Reboot "true";
            Unattended-Upgrade::Automatic-Reboot-Time "02:38";
            # For non-critical servers, add this:
            Unattended-Upgrade::Automatic-Reboot-WithUsers "true";
          
  • Edit /etc/apt/apt.conf.d/20auto-upgrades and change the following:
  •         # Some of these settings may already be active
            APT::Periodic::Update-Package-Lists "1";
            APT::Periodic::Download-Upgradeable-Packages "1";
            APT::Periodic::AutocleanInterval "7";
            APT::Periodic::Unattended-Upgrade "1";
          
  • Check if it works:
  •         sudo unattended-upgrades --dry-run --debug
          

References


SVN instructions


Create a branch

  • Navigate to a temporary folder
  • Get the trunk URL of the project (e.g. https://www.softco.co.za/svn/trunk/projects/test/ – with trailing slash)
  • Replace trunk with branches/branch-name (e.g. https://www.softco.co.za/svn/branches/v1.1/test/)
  • Execute the following command:
  •         svn copy --parents "https://www.softco.co.za/svn/trunk/projects/test/" "https://www.softco.co.za/svn/branches/v1.1/test/"
          


Snap Security



Snap Security

Snap security

Snap packages are sandboxed and therefore they are not by default allowed to access the password service.
For example: When you choose “Store in keychain” MySQLWorkbench is blocked by AppArmor. To fix
this, you need to execute a command similar to the following (which is to allow MySQLWorkbench access
to the password manager service)

    sudo snap connect mysql-workbench-community:password-manager-service :password-manager-service
  

References:


Sane Network Scanning


Sane network scanning

  • Installing requirements
  •     # Basic requirements
        sudo apt install sane sane-utils xsane
    
        # XSane might need the following libraries
        # (start xsane net:10.0.0.123 from cli to see if libcanberra is missing)
        sudo apt install libcanberra-gtk-module libcanberra-gtk3-module
    
        # Copy systemd files
        sudo cp /usr/lib/systemd/system/saned* /etc/systemd/system
    
        # Set RUN=yes in /etc/default/saned
    
        # Enable Sane socket
        sudo systemctl enable saned.socket
      
  • Service configuration
  •     # Find USB vendor ID
        # (Vendor (VVVV) and device (DDDD) in "ID VVVV:DDDD")
        sudo lsusb
    
        # Change udev rules to use specific device group
        # (Change VVVV for Vendor ID)
        echo '"SUBSYSTEM=="usb", ATTRS{idVendor}=="VVVV", MODE="0660", GROUP="scanner", ENV{libsane_matched}="yes"' > cat /etc/udev/rules.d/55-libsane.rules
    
        # Edit /etc/saned.d/saned.conf and add access lists as follows
        192.168.0.0/24
        10.0.0.0/24
        127.0.0.1
        localhost
        
        # Add scanner group to users
        sudo usermod -a -G scanner [your-user-name]
    
        # Enable Sane socket
        sudo systemctl enable saned.socket
        sudo systemctl start saned.socket
    
        # If scanner is still not listed, edit /etc/systemd/system/saned@.service and 
      
  • Client configuration
  •     # Enable net module
        # Edit /etc/saned.d/dll.conf and uncomment line containing net
        # Edit /etc/saned.d/net.conf and add server ip addresses as follows:
        localhost
        10.0.0.100
      
  • Trouble shooting
  •     # If no scanners are listed on the client, you might want to run saned as root:
        # Edit /etc/default/saned and uncomment RUN_AS_USER
        # Edit /etc/systemd/system/saned.socket and uncomment RUN_AS_USER
        # Edit /etc/systemd/system/saned@.service and uncomment both User and Group
    
        # You can enable logging on the server by uncommenting Environment=SANE_CONFIG_DIR=/etc/sane.d SANE_DEBUG_DLL=255
        # To view debugging information:
        tail -f /var/log/syslog
        # Now search for scanners on client:
        scanimage -L
    
        # You might want to enable data port ranges in /etc/saned.d/saned.conf
        data_portrange = 10000 - 10010
      


Resize Linux Partition


Reduce the size of a partition containing an volume

  • BE SURE TO MAKE A BACKUP
  • Either resizing or moving the physical partition may cause the raid superblock to be lost

  • Check the filesystem on mdadm raid volume
          e2fsck -f /dev/md0
          
  • Reduce the filesystem on mdadm raid volume (change volume and reduced size)
          resize2fs /dev/md0 120G
          
  • Resize the mdadm raid volume (use a size slightly larger than the filesystem)
  •       mdadm --grow /dev/md0 --size=122G
          
  • Check the filesystem on mdadm raid volume
          e2fsck -f /dev/md0
          
  • Stop the raid device
  •       mdadm /dev/md0 --stop
          
  • Resize the physical partition (use GParted to do that)
  • You may need to boot from a Live CD to do this – to use parted, you may not have to reboot to a live image
    You can also use the parted command line tool as follows:

            # apt install parted
            parted /dev/sda
            (parted) print
    
            # IMPORTANT: The END is NOT the new size - you have to add sizes of partitions before it
            (parted) resizepart
            Partition number? # Select partition number to resize
            End [10G]?        # Enter the new end of partition in bytes (remember to add sizes of partitions before it)
                              # Also, double check in GParted to make sure the size is what you expect it to be, since
                              # the parted size does not correspond to GParted size
    
            # The short sintax is (assuming partition number is 2 and you need it to resize to 125G):
            (parted) resizepart 2 125G
    
            # To continue to the next drive, use select
            (parted) select /dev/sdb
          
  • https://www.tecmint.com/parted-command-to-create-resize-rescue-linux-disk-partitions/
  • Start the raid device
  •         mdadm --examine --scan
            mdadm --assemble --scan
            #mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1
          

    In case of a raid 1 device not starting up, you might mount one of the raid partitions as a standard partition, then
    create a new raid one drive using the second partition. If that works, you can sync from the standard device to the
    new raid device and afterwords add the second partition to the raid, which will cause the raid to recover.

            # Assume /dev/sda3 and /dev/sdb3 was devices of the raid 1 array that is now broken
            mkdir /mnt/sdb3
            mount /dev/sdb3 /mnt/sdb3  # Assuming sdb3 was a raid 1 device and filesystem is still in tact.
            mdadm --create --verbose --force /dev/md1 --level=mirror --raid-devices=1 /dev/sda3
            rsync -avz /mnt/sdb3/* /mnt/md0/
            mdadm --manage /dev/md0 --add /dev/sda3
            cat /proc/mdstat
          

References


Postgres


To list installed server libraries, execute the following SQL: show shared_preload_libraries. To configure
libraries to be preloaded, edit postgres.conf. On an Ubuntu apt installation, it would typically be found in
/etc/postgresql/9.0/main.

To see the default dynamic library search path, execute the following SQL: show dynamic_library_path

$libdir is configured during compile time. On an Ubuntu installation which is done using an Ubuntu package,
$libdir will typically point to /usr/lib/postgresql/9.0/lib. Plug-in library files should typically
be put in /usr/lib/postgresql/9.0/lib/plugins on an Ubuntu system.

To automatically create objects when a new database is created, create the objects in template1. (template0 is
barebone template from which template1 is created)

To install the PL/PGSQL debugger in an Ubuntu postgres server which has been installed using apt, you might want to do
a one-click install from Enterprise DB on a Linux VM
(see Enterprise DB downloads) and do the following:
Copy /opt/PostgreSQL/9.0/lib/postgresql/plugins/plugin_debugger.so to $libdir/plugins on the Ubuntu installation.
Copy /opt/PostgreSQL/9.0/lib/postgresql/pldbgapi.so to $libdir on the Ubuntu installation.
Copy /opt/PostgreSQL/9.0/lib/postgresql/targetinfo.so to $libdir on the Ubuntu installation.
Copy /opt/PostgreSQL/9.0/share/postgresql/contrib/pldbgapi.sql to /usr/share/postgresql/9.0/contrib. on the Ubuntu installation.
Now edit postgres.conf and change the following setting:
shared_preload_libraries = ‘$libdir/plugins/plugin_debugger.so’
Now restart the postgres server and apply
You can also download the latest version of edb-debugger from
PgFoundry
and compile it to get plugin_debugger.so and pldbgapi.sql.