1. Installation

2. Configuration

2.1. Installation of Samba Server

sudo apt-get install cifs-utils samba smbclient
sudo cp -a /etc/samba/smb.conf /etc/samba/smb.conf.org
sudo smbpasswd -a root
# Use the root password in upper case for security reasons.
sudo smbpasswd -a smru"
# Use the same password as the normal smru account.
sudo service nmbd restart" and press *Enter*.
sudo service smbd restart" and press *Enter*.

2.1.1. Configuration of tbhf-anc-mrm Samba Server

sudo mkdir -p /home/bin
sudo mkdir -p /home/Other
sudo chown delta:delta -R /home/bin
sudo chown delta:delta -R /home/Other
  • Append the following lines to the /etc/samba/smb.conf file.

[Bin$]
  acl allow execute always = True
  browseable = yes
  comment = Bin
  create mask = 0644
  directory mask = 0755
  path = /home/bin
  printable = no
  public = yes
  read list = guest
  writable = yes

[Other$]
  acl allow execute always = True
  browseable = yes
  comment = Other
  create mask = 0644
  directory mask = 0755
  path = /home/Other
  printable = no
  public = no
  read list = guest
  writable = yes
  • Append the "delaycompress" line after the "compress" lines in the /etc/logrotate.d/samba file.

  • Append the "delaycompress" line after the "compress" line in the /etc/logrotate.d/winbind file.

sudo service nmbd restart
sudo service smbd restart

smbclient -L //tbhf-anc-mrm
  • Type the samba smru password.

2.2. SMRU Repository

2.2.1. Uninstallation of SMRU package repository

sudo apt-get remove smru-archive-keyring
sudo dpkg --remove smru-repository
sudo rm /var/www/html/debian/smru/smru-archive-keyring_*-1_all.deb
exit

2.2.2. Installation of SMRU package repository

# cat /proc/sys/kernel/random/entropy_avail
sudo dpkg -i /var/www/html/debian/smru/smru-repository_1.1-1_all.deb
sudo dpkg -i /var/www/html/debian/smru/smru-repository_2.0.0-1_all.deb
  • Wait for enough entropy to be generated.

  • Press Alt+F2 to switch to other console to generate more entropy.

ls -alR /               # Generate more entropy
exit
  • Press Alt+F1 to return to previous console.

vdir /var/www/html/debian
vdir /var/www/html/debian/smru | grep key
smru-archive-keyring_YYYY-MM-DD-1_all.deb
cd /var/www/html/debian
sudo make clean
sudo make
vdir /var/www/html/debian/smru
exit

2.2.3. Update of SMRU package repository

cd /var/www/html/debian
sudo make clean
sudo make
exit

2.3. Network configuration

cat /etc/hosts
192.168.25.2    tbhf-anc-mkt.smru.shoklo-unit.com       tbhf-anc-mkt
192.168.25.6    smru-pms-mkt.smru.shoklo-unit.com       smru-pms-mkt
192.168.25.170  smru-efw-mkt.smru.shoklo-unit.com       smru-efw-mkt

192.168.26.2    tbhf-anc-mla.smru.shoklo-unit.com       tbhf-anc-mla
192.168.26.6    smru-pms-mla.smru.shoklo-unit.com       smru-pms-mla
192.168.26.170  smru-efw-mla.smru.shoklo-unit.com       smru-efw-mla

192.168.27.2    tbhf-anc-wpa.smru.shoklo-unit.com       tbhf-anc-wpa
192.168.27.6    smru-pms-wpa.smru.shoklo-unit.com       smru-pms-wpa
192.168.27.170  smru-efw-wpa.smru.shoklo-unit.com       smru-efw-wpa

2.4. Munin

2.4.1. Uninstallation of Munin

sudo apt-get purge munin munin-node
sudo apt-get autoremove"
sudo rm -rf /etc/munin
sudo rm -rf /etc/apache2/conf-available/munin.conf
sudo rm -rf /etc/apache2/conf-enabled/munin.conf
sudo /etc/init.d/apache2 restart"

2.4.2. Installation and configuration of Munin

sudo apt-get install munin munin-node
sudo cp -a /etc/munin/apache24.conf /etc/munin/apache24.conf.org
  • Change the "Require local" lines into "Require all granted" in the /etc/munin/apache24.conf file.

  • Change the "Options None" line into "Options FollowSymLinks SymLinksIfOwnerMatch" in the "<Directory>" section of the /etc/munin/apache24.conf file.

sudo ls -al /etc/apache2/conf-enabled
drwxr-xr-x 2 root root 4096 Sep 21 11:15 .
drwxr-xr-x 8 root root 4096 Sep 18 15:41 ..
lrwxrwxrwx 1 root root   30 Sep 18 15:41 charset.conf -> ../conf-available/charset.conf
lrwxrwxrwx 1 root root   44 Sep 18 15:41 localized-error-pages.conf -> ../conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root   28 Sep 21 11:15 munin.conf -> ../conf-available/munin.conf
lrwxrwxrwx 1 root root   46 Sep 18 15:41 other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root   31 Sep 18 15:41 security.conf -> ../conf-available/security.conf
lrwxrwxrwx 1 root root   36 Sep 18 15:41 serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf
sudo ls -al /etc/apache2/conf-available
drwxr-xr-x 2 root root 4096 Sep 21 11:15 .
drwxr-xr-x 8 root root 4096 Sep 18 15:41 ..
-rw-r--r-- 1 root root  315 Aug  8 04:33 charset.conf
-rw-r--r-- 1 root root 3224 Aug  8 04:33 localized-error-pages.conf
lrwxrwxrwx 1 root root   25 Sep 21 11:15 munin.conf -> ../../munin/apache24.conf
-rw-r--r-- 1 root root  189 Aug  8 04:33 other-vhosts-access-log.conf
-rw-r--r-- 1 root root 2190 Aug 28 04:03 security.conf
-rw-r--r-- 1 root root  455 Aug  8 04:33 serve-cgi-bin.conf
sudo cp -a /etc/munin/munin.conf /etc/munin/munin.conf.org
sudo cp -a /etc/munin/munin-node.conf /etc/munin/munin-node.conf.org
  • Append the "delaycompress" line after the "compress" line in the /etc/logrotate.d/munin-node file.

  • Append the following lines to the /etc/munin/munin.conf file.

[tbhf-anc-mkt.smru.shoklo-unit.com]
    address 192.168.25.2
    use_node_name yes

[tbhf-anc-mla.smru.shoklo-unit.com]
    address 192.168.26.2
    use_node_name yes

[tbhf-anc-wpa.smru.shoklo-unit.com]
    address 192.168.27.2
    use_node_name yes
sudo apachectl -t -D DUMP_MODULES"
sudo a2enmod cgi" to enable graphs zooming
sudo apachectl -t -D DUMP_MODULES

sudo /etc/init.d/munin-node restart
sudo /etc/init.d/apache2 restart
exit

2.4.3. Debugging of Munin

  • Log in as smru.

sudo /etc/init.d/munin-node status
sudo tail -f /var/log/munin/munin-node.log

ls -al /etc/apache2/conf-enabled/munin.conf
ls -al /etc/apache2/conf-available/munin.conf
vi /etc/apache2/conf-available/munin.conf
vi /etc/munin/apache24.conf
vdir /var/cache/munin/www/index.html

# Add the --debug option to the munin-cron cmd in the /etc/cron.d/munin file.
sudo tail -f /var/log/munin/munin-update.log
# Press Ctrl+C to exit the tail command.
sudo tail -f /var/log/munin/munin-update.log | grep -i 'fatal error'
# Press Ctrl+C to exit the tail command.
exit

2.5. Email

2.5.1. Configuration of exim4 mail transfer agent

sudo cp -a /etc/aliases /etc/aliases.org
sudo cp -a /etc/exim4/update-exim4.conf.conf /etc/exim4/update-exim4.conf.conf.org
sudo dpkg-reconfigure exim4-config
# Select "mail sent by smarthost; received via SMTP or fetchmail" and press Enter.
# Type "tbhf-anc-mrm.smru.shoklo-unit.com" for system mail name and press Enter.
# Type "" for IP addresses to listen on for incoming SMTP connections and press Enter.
# Type "" for other destinations for which email is accepted and press Enter.
# Type "" for machines to relay email for and press Enter.
# Type "10.10.1.170" for IP address of the outgoing smarthost and press Enter.
# Select "Yes" to hide local mail name in outgoing mail and press Enter.
# Type "shoklo-unit.com" for visible domain name for local users and press Enter.
# Select "No" to skip keeping number of DNS-queries minimal and press Enter.
# Select "mbox format in /var/mail/" and press Enter.
# Select "No" to skip splitting configuration into small files and press Enter.
sudo /etc/init.d/exim4 restart
exit

2.5.2. Debugging of exim4 mail transfer agent

echo "Test message" | mail -s "Test Message." root
sudo vi /var/log/exim4/mainlog
exit

2.6. Configuration of SMRU shares

sudo apt-get install samba-common
sudo apt-get install smbclient cifs-utils
  • Contents of the ~root/.smbcred-Teams file.

username=itadmin
password=********
domain=SMRU
  • Contents of the ~root/.smbcred-ANC file.

username=ancupload
password=********
domain=SMRU
  • Contents of the ~root/.smbcred-PMS file.

username=pmsupload
password=********
domain=SMRU
  • Contents of the ~root/.smbcred-Lab file.

username=ancaccess
password=********
domain=SMRU
sudo chmod 600 ~root/.smbcred-Teams
sudo chmod 600 ~root/.smbcred-ANC
sudo chmod 600 ~root/.smbcred-PMS
sudo chmod 600 ~root/.smbcred-Lab

sudo vdir ~root/.smbcred-Teams
sudo vdir ~root/.smbcred-ANC
sudo vdir ~root/.smbcred-PMS
sudo vdir ~root/.smbcred-Lab

sudo smbclient --authentication-file ~root/.smbcred-Teams //smru-srv/Teams$
dir
exit
sudo smbclient --authentication-file ~root/.smbcred-ANC //smru-srv/ANC$
dir
exit
sudo smbclient --authentication-file ~root/.smbcred-PMS //smru-srv/PMS$
dir
exit
#sudo smbclient --authentication-file ~root/.smbcred-Lab //smru-srv/Hematologylab$
#dir
#exit
#sudo smbclient --authentication-file ~root/.smbcred-Lab //smru-srv/MicrobiologyLaboratoryDatabase$
#dir
#exit

sudo mkdir /media/Teams
sudo mkdir /media/ANC
sudo mkdir /media/PMS
#sudo mkdir /media/Haema
#sudo mkdir /media/Micro

sudo mount -o credentials=/root/.smbcred-Teams,vers=3.0 -t cifs //smru-srv/Teams$ /mnt
sudo umount /mnt
sudo mount -o credentials=/root/.smbcred-ANC,vers=3.0 -t cifs //smru-srv/ANC$ /mnt
sudo umount /mnt
sudo mount -o credentials=/root/.smbcred-PMS,vers=3.0 -t cifs //smru-srv/PMS$ /mnt
sudo umount /mnt
#sudo mount -o credentials=/root/.smbcred-Lab,vers=3.0 -t cifs //smru-srv/Hematologylab$ /mnt
#sudo umount /mnt
#sudo mount -o credentials=/root/.smbcred-Lab,vers=3.0 -t cifs //smru-srv/MicrobiologyLaboratoryDatabase$ /mnt
#sudo umount /mnt

sudo cp -a /etc/fstab /etc/fstab.org
  • Append the following lines to the /etc/fstab file.

# <file system>                                 <mount point>   <type>  <options>                                       <dump>  <pass>

# SMRU File Server shares.
//smru-srv/Teams$                               /media/Teams    cifs    credentials=/root/.smbcred-Teams,vers=3.0       0       0
//smru-srv/ANC$                                 /media/ANC      cifs    credentials=/root/.smbcred-ANC,vers=3.0 0       0
//smru-srv/PMS$                                 /media/PMS      cifs    credentials=/root/.smbcred-PMS,vers=3.0 0       0
#//smru-srv/Hematologylab$                      /media/Haema    cifs    credentials=/root/.smbcred-Lab,vers=3.0 0       0
#//smru-srv/MicrobiologyLaboratoryDatabase$     /media/Micro    cifs    credentials=/root/.smbcred-Lab,vers=3.0 0       0
sudo mount -a
vdir /media/Teams
vdir /media/ANC
vdir /media/PMS
#vdir /media/Haema
#vdir /media/Micro
exit

2.7. ANC Application

2.7.1. Configuration of Python

  • Log in as smru.

sudo apt-get install python-pip
sudo pip install tabulate               <????>
sudo pip uninstall tabulate             <????>
sudo apt-get install python-tabulate    <????>
exit

2.7.2. Configuration of SMRU repository

  • Log in as smru.

  • Append the following lines to the /etc/apt/sources.list file.

# SMRU repository.
deb http://tbhf-anc-mrm/debian smru/
sudo apt-get update
sudo apt-get install smru-archive-keyring               # Fix the GPG error

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo grep -Ei --color 'crit|erro|fail|warn' /var/log/apt/term.log
exit

2.7.3. Uninstallation of SMRU packages

sudo apt-get remove smru-server
sudo apt-get remove smru-clinic
sudo apt-get autoremove"
sudo dpkg -l | grep -i smru
  • Delete all Apache folders.

ls -al /var/www/html
sudo rm -rf /var/www/html/anc-*
  • Delete all anc databases.

psql --list
dropdb <database>
psql --dbname postgres --command '\du+'
sudo su - postgres -c 'dropuser anc'
  • Remove SMRU-MAGIC-COOKIE lines from the PostgreSQL configuration files.

sudo grep -ir 'SMRU-MAGIC-COOKIE' /etc/postgresql
exit

2.7.4. Installation of SMRU packages

sudo apt-get update
sudo apt-get install smru-server
sudo apt-get install smru-clinic
psql --dbname postgres --command '\du+'
  • Ignore the psql: FATAL: role "smru" does not exist error message.

sudo su - postgres -c 'createuser --createdb --inherit --login --no-createrole --pwprompt --superuser smru'
# Type the level l2 password for the new role.
# Type the level l2 password for the new role.
sudo su - postgres -c 'createuser --no-superuser --no-createdb --no-createrole --login --no-inherit --pwprompt anc'
# Type the level l2 password for the new role.
# Type the level l2 password for the new role.
# Type "psql --dbname postgres --command '\du+'
// sudo smru-clinic-setup anc-master MST
psql --list
exit

2.7.5. Configuration of PHP5

sudo apt-get install php-ssh2
exit

2.7.6. Generation of SSH keys

cd ~delta
rm ~delta/.ssh/known_hosts
ssh-keygen
# Type "" for default /home/delta/.ssh/id_rsa file and press Enter.
# Type "y" to overwrite and press Enter.
# Type "" for the passphrase and press Enter.
# Type "" for the passphrase and press Enter.
sudo mkdir -p /home/www-data/.ssh
sudo cp -a ~delta/.ssh/id_rsa /home/www-data/.ssh
sudo cp -a ~delta/.ssh/id_rsa.pub /home/www-data/.ssh
sudo chown www-data:www-data -R /home/www-data
cat ~delta/.ssh/authorized_keys
cat ~delta/.ssh/id_rsa.pub >> ~delta/.ssh/authorized_keys
cat ~delta/.ssh/authorized_keys
exit

2.7.7. Prevent "Allowed memory size of 134217728 bytes exhausted" PostgreSQL errors

  • Add the following line to the /etc/php5/apache2/conf.d/smru-php.ini file.

memory_limit = 512M

2.7.8. Installation of SMRU updates

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove
exit

2.7.9. Configuration of ANC Application

  • Log in as smru.

  • Replace the asterisks by the level l2 password in the ~root/.pgpass file.

  • Contents of the ~delta/anc-db.ini file.

[database]
pass = "********"

[debug]
pass = "********"

[demo]
pass = "********"

[desktop]
pass = "********"

[laptop]
pass = "********"
  • Replace the asterisks in the [database] section by the level l2 password in the ~delta/anc-db.ini file.

  • Replace the asterisks in the other sections by the appropriate passwords in the ~delta/anc-db.ini file.

vdir ~delta/anc-db.ini
chmod 640 ~delta/anc-db.ini
sudo chown delta:www-data ~delta/anc-db.ini
vdir ~delta/anc-db.ini
// sudo smru-clinic-config anc-master
psql --list
  • Contents of the ~delta/anc-db.sql file.

UPDATE "Users" SET active = 1, password = MD5('********') WHERE name = 'Guest';
UPDATE "Users" SET active = 1, password = MD5('********') WHERE name = 'SMRU';
UPDATE "Users" SET active = 1, password = MD5('********') WHERE name = 'PP';
UPDATE "Users" SET active = 1, password = MD5('********') WHERE name = 'Administrator';
UPDATE "Users" SET active = 1, password = MD5('********') WHERE name = 'IT';
UPDATE "Users" SET active = 1, password = MD5('********') WHERE name = 'Lab';
UPDATE "Users" SET active = 1, password = MD5('********') WHERE name = 'Doctor';
  • Replace the asterisks by the appropriate passwords in the ~delta/anc-db.sql file.

chmod 600 ~delta/anc-db.sql
vdir ~delta/anc-db.sql

PSQLOPTIONS="--no-psqlrc --pset pager=off --quiet --set ON_ERROR_STOP=1 --single-transaction"
psql $PSQLOPTIONS --dbname anc-mkt --file ~delta/anc-db.sql     <????>
psql $PSQLOPTIONS --dbname anc-mla --file ~delta/anc-db.sql     <????>
psql $PSQLOPTIONS --dbname anc-mlc --file ~delta/anc-db.sql     <????>
psql $PSQLOPTIONS --dbname anc-ppl --file ~delta/anc-db.sql     <????>
psql $PSQLOPTIONS --dbname anc-wal --file ~delta/anc-db.sql     <????>
psql $PSQLOPTIONS --dbname anc-wpa --file ~delta/anc-db.sql     <????>
exit

2.7.10. Deletion of all anc databases

/usr/local/bin/smru-db-delete anc-mkt
/usr/local/bin/smru-db-delete anc-mla
/usr/local/bin/smru-db-delete anc-mlc
/usr/local/bin/smru-db-delete anc-ppl
/usr/local/bin/smru-db-delete anc-wal
/usr/local/bin/smru-db-delete anc-wpa

/usr/local/bin/smru-db-delete anc-mkt-active
/usr/local/bin/smru-db-delete anc-mla-active
/usr/local/bin/smru-db-delete anc-wpa-active

/usr/local/bin/smru-db-delete anc-active
/usr/local/bin/smru-db-delete anc-closed

2.7.11. Restoration of the databases with the closed anc records

  • Note: Use yesterday’s date.

// /usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-maesot-anc-mkt.bak anc-mkt
// /usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-maesot-anc-mla.bak anc-mla
// /usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-maesot-anc-mlc.bak anc-mlc
// /usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-maesot-anc-ppl.bak anc-ppl
// /usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-maesot-anc-wal.bak anc-wal
// /usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-maesot-anc-wpa.bak anc-wpa
/usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-tbhf-anc-mrm-anc-mkt.bak anc-mkt
/usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-tbhf-anc-mrm-anc-mla.bak anc-mla
/usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-tbhf-anc-mrm-anc-mlc.bak anc-mlc
/usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-tbhf-anc-mrm-anc-ppl.bak anc-ppl
/usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-tbhf-anc-mrm-anc-wal.bak anc-wal
/usr/local/sbin/smru-database-restore /media/ANC/YYYY-MM-DD-tbhf-anc-mrm-anc-wpa.bak anc-wpa

2.7.12. Restoration of the databases with the active anc records

su - smru -c "smru-db-create anc-mkt-active"
su - smru -c "smru-db-create anc-mla-active"
su - smru -c "smru-db-create anc-wpa-active"
/usr/local/sbin/smru-db-clinic-restore /media/ANC tbhf-anc-mkt anc-mkt
/usr/local/sbin/smru-db-clinic-restore /media/ANC tbhf-anc-mla anc-mla
/usr/local/sbin/smru-db-clinic-restore /media/ANC tbhf-anc-wpa anc-wpa

2.7.13. Creation of the anc-active database

su - smru -c "/usr/local/bin/smru-db-make anc-active"
/usr/local/sbin/smru-db-import anc-active anc-mkt-active
/usr/local/sbin/smru-db-import anc-active anc-mla-active
/usr/local/sbin/smru-db-import anc-active anc-wpa-active

2.7.14. Creation of the anc-closed database

su - smru -c "/usr/local/bin/smru-db-make anc-closed"
/usr/local/sbin/smru-db-import anc-closed anc-mkt
/usr/local/sbin/smru-db-import anc-closed anc-mla
/usr/local/sbin/smru-db-import anc-closed anc-mlc
/usr/local/sbin/smru-db-import anc-closed anc-pp
/usr/local/sbin/smru-db-import anc-closed anc-wal
/usr/local/sbin/smru-db-import anc-closed anc-wpa"

2.7.15. Creation of Apache folders

cd /var/www/html
vdir

sudo cp -a anc-app anc-mkt-active
sudo cp -a anc-app anc-mla-active
sudo cp -a anc-app anc-wpa-active
sudo cp -a anc-app anc-active
sudo cp -a anc-app anc-closed
sudo cp -a anc-app anc-mkt
sudo cp -a anc-app anc-mla
sudo cp -a anc-app anc-mlc
sudo cp -a anc-app anc-ppl
sudo cp -a anc-app anc-wal
sudo cp -a anc-app anc-wpa
  • Set the dbname to anc-mkt-active in the /var/www/html/anc-mkt-active/config/db.ini file.

  • Set the dbname to anc-mla-active in the /var/www/html/anc-mla-active/config/db.ini file.

  • Set the dbname to anc-wpa-active in the /var/www/html/anc-wpa-active/config/db.ini file.

  • Set the dbname to anc-active in the /var/www/html/anc-active/config/db.ini file.

  • Set the dbname to anc-closed in the /var/www/html/anc-closed/config/db.ini file.

  • Set the dbname to anc-mkt in the /var/www/html/anc-mkt/config/db.ini file.

  • Set the dbname to anc-mla in the /var/www/html/anc-mla/config/db.ini file.

  • Set the dbname to anc-mlc in the /var/www/html/anc-mlc/config/db.ini file.

  • Set the dbname to anc-ppl in the /var/www/html/anc-ppl/config/db.ini file.

  • Set the dbname to anc-wal in the /var/www/html/anc-wal/config/db.ini file.

  • Set the dbname to anc-wpa in the /var/www/html/anc-wpa/config/db.ini file.

grep -i '^dsn = ' /var/www/html/anc-*/config/db.ini
vdir

2.7.16. Configuration of Apache

sudo touch /var/www/html/favicon.ico
exit

2.7.17. Configuration of SSL

sudo apache2ctl -M | grep -i ssl
sudo a2enmod ssl
sudo service apache2 restart
sudo apache2ctl -M | grep -i ssl

2.7.18. Configuration of PostgreSQL

cd /etc/postgresql/9.4/main
sudo cp -a pg_hba.conf pg_hba.conf.org
sudo cp -a postgresql.conf postgresql.conf.org
  • Add the following line to the /etc/postgresql/9.4/main/pg_hba.conf file.

host    all             all             10.10.1.0/24            md5 # SMRU-MAGIC-COOKIE for LAN tbhf-anc-mrm server
  • Change the "ssl = true" line into "ssl = false" in the /etc/postgresql/9.4/main/postgresql.conf file.

  • Change the "#checkpoint_segments = 3" line into "checkpoint_segments = 10" in the /etc/postgresql/9.4/main/postgresql.conf file.

sudo /etc/init.d/postgresql restart
exit

psql anc-mkt -c 'SHOW search_path'
psql anc-mkt -c 'ALTER USER smru SET search_path TO "$user", public, active'
psql anc-mkt -c 'ALTER USER smru SET search_path TO "$user", public, closed'
psql anc-mkt -c 'ALTER USER smru SET search_path TO "$user", public'
psql anc-mkt -c 'SHOW search_path'

psql anc-mkt -c 'ALTER TABLE public."tblG6PD" OWNER TO anc'
psql anc-mkt-active -c 'ALTER TABLE public."tblG6PD" OWNER TO anc'

2.8. Configuration of cron jobs

sudo crontab -e
  • Append the following lines to the crontab file.

# 2015-09-23 Douwe: Check every hour connection with clinic servers.
00 * * * * /usr/local/sbin/smru-vpn-chk

# 2015-09-23 Douwe: Make backups of databases at clinics.
00 01 * * * /usr/local/sbin/smru-db-clinic-backup /media/ANC tbhf-anc-mkt anc-mkt
00 01 * * * /usr/local/sbin/smru-db-clinic-backup /media/ANC tbhf-anc-mla anc-mla
00 01 * * * /usr/local/sbin/smru-db-clinic-backup /media/ANC tbhf-anc-wpa anc-wpa

# 2015-09-23 Douwe: Restore databases from latest non-zero backup file.
00 04 * * * /usr/local/sbin/smru-db-clinic-restore /media/ANC tbhf-anc-mkt anc-mkt
05 04 * * * /usr/local/sbin/smru-db-clinic-restore /media/ANC tbhf-anc-mla anc-mla
10 04 * * * /usr/local/sbin/smru-db-clinic-restore /media/ANC tbhf-anc-wpa anc-wpa

# 2015-09-23 Douwe: Run database maintenance.
30 04 * * * /usr/local/sbin/smru-maintenance anc-mkt-active
35 04 * * * /usr/local/sbin/smru-maintenance anc-mla-active
40 04 * * * /usr/local/sbin/smru-maintenance anc-wpa-active

# 2015-09-23 Douwe: Import databases into anc-active database.
00 05 * * * su - smru -c "/usr/local/bin/smru-db-make anc-active"
05 05 * * * /usr/local/sbin/smru-db-import anc-active anc-mkt-active
10 05 * * * /usr/local/sbin/smru-db-import anc-active anc-mla-active
30 05 * * * /usr/local/sbin/smru-db-import anc-active anc-wpa-active

# 2015-09-23 Douwe: Make backup of anc-active database.
00 06 * * * /usr/local/sbin/smru-db-clinic-backup /media/ANC tbhf-anc-mrm anc-active

# 2016-06-30 Douwe: Import databases into anc-closed database.
00 07 * * * su - smru -c "/usr/local/bin/smru-db-make anc-closed"
05 07 * * * /usr/local/sbin/smru-db-import anc-closed anc-mkt
10 07 * * * /usr/local/sbin/smru-db-import anc-closed anc-mla
15 07 * * * /usr/local/sbin/smru-db-import anc-closed anc-mlc
20 07 * * * /usr/local/sbin/smru-db-import anc-closed anc-ppl
25 07 * * * /usr/local/sbin/smru-db-import anc-closed anc-wal
30 07 * * * /usr/local/sbin/smru-db-import anc-closed anc-wpa

# 2016-06-30 Douwe: Make backup of anc-closed database.
00 08 * * * /usr/local/sbin/smru-db-clinic-backup /media/ANC tbhf-anc-mrm anc-closed

# 2015-09-23 Douwe: Make backup of closed databases at Mae Sot office.
00 23 * * * /usr/local/sbin/smru-database-backup /media/ANC anc-mkt
02 23 * * * /usr/local/sbin/smru-database-backup /media/ANC anc-mla
04 23 * * * /usr/local/sbin/smru-database-backup /media/ANC anc-mlc
06 23 * * * /usr/local/sbin/smru-database-backup /media/ANC anc-ppl
08 23 * * * /usr/local/sbin/smru-database-backup /media/ANC anc-wal
10 23 * * * /usr/local/sbin/smru-database-backup /media/ANC anc-wpa
:wq
exit

2.9. Installation of Webmin

  • Log in as smru.

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.780_all.deb
sudo apt-get install apt-show-versions
sudo apt-get install libauthen-pam-perl
sudo apt-get install libio-pty-perl
sudo apt-get install libnet-ssleay-perl
sudo dpkg -i webmin_1.780_all.deb

2.10. Maintenance

2.10.1. Installation of updates

sudo apt-get update
sudo apt-get -d dist-upgrade
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove

sudo grep -Ei --color 'crit|erro|fail|warn' /var/log/apt/term.log

2.10.2. Check for bad sectors

sudo badblocks -s -v /dev/sda
sudo badblocks -s -v /dev/sdb
sudo smartctl -a /dev/sda
exit

2.10.3. Backup of a PostgreSQL database

  • Log in as smru.

# pg_dump --encoding UTF8 --file /tmp/anc-mkt.bak --format custom --no-acl anc-mkt
pg_dump --encoding UTF8 --file /tmp/anc-mkt.bak --format custom anc-mkt
exit

2.10.4. Restore of a PostgreSQL database

  • Log in as smru.

smru-db-delete anc-mkt
smru-db-create anc-mkt
// # pg_restore --dbname anc-mkt --schema public --single-transaction /tmp/anc-mkt.bak
pg_restore --dbname anc-mkt --single-transaction /tmp/anc-mkt.bak
exit