Thursday, August 11, 2022

Setup autostart services in Linux with SELinux


1) Create your start / stop script in a predefined directory (e.g. /development/service-script/ )

  • /development/service-script/start-cmd
  • /development/service-script/stop-cmd

2) Allow SELinux to execute binaries in the predefined directory /development/service-script/ (!! important for SELinux)

    chcon -R -t bin_t /development/service-script/


3) Create abc.service in /etc/systemd/system/

    # Systemd unit file for ABC service

    [Unit]
 
    Description=ABC service
    After=syslog.target network.target

    [Service]
    Type=forking

    ExecStart=/development/service-script/start-cmd
    ExecStop=/development/service-script/stop-cmd

    User=service_owner
    Group=service_owner
    UMask=0007
    RestartSec=10
    Restart=always

    [Install]
    WantedBy=multi-user.target


4) Reload systemd

    systemctl daemon-reload

5) Start ABC service

    systemctl start abc


6) If ABC service is working, then we can enabled it for autostart

    systemctl enable abc



Wednesday, August 10, 2022

NO_PUBKEY when updating QGIS in Linux / Ubuntu (2022)

Update the key file (qgis-archive.gpg) by:


wget  -qO  -  https://qgis.org/downloads/qgis-2022.gpg.key  |  gpg  --no-default-keyring  --keyring  gnupg-ring:/etc/apt/trusted.gpg.d/qgis-archive.gpg  --import


The NO_PUBKEY error message will be gone for 'apt update'


Sync multiple git repo at once

Use the following command in Linux will do the job:  ls -d RepoNames* | xargs -I{} git -C {} pull