Tuesday, December 25, 2018

Image Rotation in Bulk

We have been having problems with rotating images.  All the software so far rotate correctly on our system or at least it seems so but they all leave the metadata intact.  Here is how I rotated in bulk with the assumption that i grouped all the wrong ones that needed rotation of the same orientation.

Use exiftool to accomplish this task
Navigate to the directory of all the wrong images that needed rotation
cd needRotate90CW
# Remove all metadata from the images
exiftool -all= *.jpg# Rotate them 90 degrees counter clockwise and overwrite
exiftool -orientation="Rotate 90 CW" -overwrite_original *.jpg

The above seemed to work but did not change the metadata to the width and height.  It only rotated.

SOLUTION! 
I found the easiest method is to use Nautilus file manager and 
Nautilus Image Converter

Monday, December 10, 2018

Find Differences Between Two Files Using Bash

grep -v -F -x -f file1 file2
The problem with the above command is that you dont know which way is the differences.  Here is a better way to accomplish this.  I have a directory of ID cards named MASTER_ID and is mounted remotely.  I host a local MYSQL database with all the accounts.  The problem we are trying to solve is move all the ID cards that are no longer in the database to the !Graveyard directory for consideration of permanently removal by a human.

if [[ $EUID -ne 0 ]]; then
 echo "This script must be run as root"
 exit 1
fi

MASTER_ID_DIR="/home/projects/mount_directory/srvr-file/SchoolPhotos/MASTER_ID/"
MASTER_ID_LST="/tmp/master_id.lst"
CAS_LST="/tmp/cas.lst"

# Generate list of all users within CAS by ID
if [ -f $CAS_LST ]; then
 rm $CAS_LST
fi
mysql -u cas_god -p <dbpasswd> -D cas -e "select id_number from cardinfo_cardinfo into outfile '/tmp/cas.lst'"

# Get listing of MASTER_ID regardless of the file extension case
echo "" > $MASTER_ID_LST
for x in `ls $MASTER_ID_DIR`; do
 echo $(basename $x .[Jj][Pp][Gg]) >> $MASTER_ID_LST
done

# Find extras in MASTER_ID that is NOT in CAS
for y in `cat $MASTER_ID_LST`; do
 if [ `grep $y $CAS_LST|wc -l` -eq 0 ]; then
   echo mv $MASTER_ID_DIR${y}.* $MASTER_ID_DIR!Graveyard/${y}_delete.jpg
   mv $MASTER_ID_DIR${y}.* $MASTER_ID_DIR!Graveyard/${y}_delete.jpg
 fi
done

Monday, December 3, 2018

Find Digit in Filename & Bulk Rename

Extracted from StackOverflow: https://stackoverflow.com/questions/428109/extract-substring-in-bash
Generic solution where the number can be anywhere in the filename, using the first of such sequences:
number=$(echo $filename | egrep -o '[[:digit:]]{5}' | head -n1)
Another solution to extract exactly a part of a variable:
number=${filename:offset:length}
If your filename always have the format stuff_digits_... you can use awk:
number=$(echo $filename | awk -F _ '{ print $2 }')
Yet another solution to remove everything except digits, use
number=$(echo $filename | tr -cd '[[:digit:]]')
I need to loop through the directory and take the filename and crop off the name assuming that the first 6 numbers are the ID number then change it to the final form.  I had to ignore all the spacing and junk after the number and just made the assumption that all I needed was the numbers in front of the file.

find . -print0 | while read -d $'\0' file; do number=$(echo $file | egrep -o '[[:digit:]]{6}' | head -n1); mv ${number}* ${number}.jpg ; done

I had some problems with files with the hyphen.

ls > /tmp/list

I needed to export a list of file then manipulate with VIM, keeping only the first work in each line then use the file list to iterate through

:1,$s/\(\s*\w\+\).*/\1/g

for x in `cat /tmp/list`; do  number=$(echo $x | egrep -o '[[:digit:]]{6}' | head -n1); mv ${number}* ${number}.jpg; done 



Sunday, December 2, 2018

Bulk Rename of Filename

Bulk change of file extension.  For an example, change the JPG to jpg

for x in `ls *JPG`; do mv $x $(basename $x .JPG).jpg; done

To find all basename case insensitive

$(basename $x .[Jj][Pp][Gg])

Friday, November 2, 2018

Linux Must Have Applications

Must Have for My Need


  1. TimeShift
    System backup with snapshots for easy rollback
    Other backup solution Grsync and Back in Time
  2. Graphics Software
    Inkscape, Gimp, Krita, 
  3. Web Browser
    Google Chrome, Mozilla Firefox
  4. Productivity Suite
    LibreOffice, Google Apps
  5. Audio & Video Editing
    Audacity, KdenLive
  6. VLC Media Player
    Obviously VLC has dominated the market with the codec compatibility, but more importantly for me was the ease of creating your own theme.  I have a killer theme customized for me so I love using it and provide me with some pride and accomplishment.  "Self pad on the back so to speak"
  7. Veracrypt
    Disk encryption software
  8. KeepassXC
    Password manager to help manage your hundreds if not thousands of passwords
  9. FontBase
    There are literally thousands of fonts in the world and will be in the millions soon so it's important to have a font manager to help in the graphics designing.  The most important is that you dont need to install the font onto your system which in turn will help with performance overall since the system does not need to preload all those fonts.

Nice to Have


  1. PlayOnLinux
    Install Windows application using Wine with ease 
  2. Windows Games
    Lutris.net has tweeked Wine and uses things like forStarcraft II  uses DX9 to OpenGL - 64 bit - Wine Staging + Esync.  Other games will have other dependencies to optimize that particular game.
  3. Thunar Bulk Rename
    Just like the name suggested, it gives you the ability to rename filenames in bulk based on patterns 
  4. Konsole
    Terminal with the special ability to clone your commands from one session to another.
  5. BeyondCompare
    Find and merge differences in files
This list is not complete.  I will be updating throughout the next month as I see the regular use of some of these tools.

Wednesday, October 24, 2018

Hierarchy Tree in MySQL

Extracted from : https://explainextended.com/2009/07/20/hierarchical-data-in-mysql-parents-and-children-in-one-query/

Create the table to store the tree

CREATE TABLE t_hierarchy (
        id int(10) unsigned NOT NULL AUTO_INCREMENT,
        parent int(10) unsigned NOT NULL,
        PRIMARY KEY (id),
        KEY ix_hierarchy_parent (parent, id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DELIMITER $$
CREATE PROCEDURE prc_fill_hierarchy (level INT, fill INT)
BEGIN
        DECLARE _level INT;
        DECLARE _fill INT;
        INSERT
        INTO    t_hierarchy (id, parent)
        VALUES  (1, 0);
        SET _fill = 0;
        WHILE _fill < fill DO
                INSERT
                INTO    t_hierarchy (parent)
                VALUES  (1);
                SET _fill = _fill + 1;
        END WHILE;
        SET _fill = 1;
        SET _level = 0;
        WHILE _level < level DO
                INSERT
                INTO    t_hierarchy (parent)
                SELECT  hn.id
                FROM    t_hierarchy ho, t_hierarchy hn
                WHERE   ho.parent = 1
                        AND hn.id > _fill;
                SET _level = _level + 1;
                SET _fill = _fill + POWER(fill, _level);
        END WHILE;
END
$$
DELIMITER ;

DROP FUNCTION IF EXISTS hierarchy_connect_by_parent_eq_prior_id;

DELIMITER $$

CREATE FUNCTION hierarchy_connect_by_parent_eq_prior_id(value INT) RETURNS INT
NOT DETERMINISTIC
READS SQL DATA
BEGIN
        DECLARE _id INT;
        DECLARE _parent INT;
        DECLARE _next INT;
        DECLARE CONTINUE HANDLER FOR NOT FOUND SET @id = NULL;

        SET _parent = @id;
        SET _id = -1;

        IF @id IS NULL THEN
                RETURN NULL;
        END IF;

        LOOP
                SELECT  MIN(id)
                INTO    @id
                FROM    t_hierarchy
                WHERE   parent = _parent
                        AND id > _id;
                IF @id IS NOT NULL OR _parent = @start_with THEN
                        SET @level = @level + 1;
                        RETURN @id;
                END IF;
                SET @level := @level - 1;
                SELECT  id, parent
                INTO    _id, _parent
                FROM    t_hierarchy
                WHERE   id = _parent;
        END LOOP;       
END
$$

DELIMITER ;

START TRANSACTION;
CALL prc_fill_hierarchy(6, 5);
COMMIT;


Select statement to retrieve tree

SELECT  CONCAT(REPEAT('    ', level - 1), CAST(id AS CHAR)),
        parent,
        level
FROM    (
        SELECT  id, parent, IF(ancestry, @cl := @cl + 1, level + @cl) AS level
        FROM    (
                SELECT  TRUE AS ancestry, _id AS id, parent, level
                FROM    (
                        SELECT  @r AS _id,
                                (
                                SELECT  @r := parent
                                FROM    t_hierarchy
                                WHERE   id = _id
                                ) AS parent,
                                @l := @l + 1 AS level
                        FROM    (
                                SELECT  @r := 1218,
                                        @l := 0,
                                        @cl := 0
                                ) vars,
                                t_hierarchy h
                        WHERE   @r <> 0
                        ORDER BY
                                level DESC
                        ) qi
                UNION ALL
                SELECT  FALSE, hi.id, parent, level
                FROM    (
                        SELECT  hierarchy_connect_by_parent_eq_prior_id(id) AS id, @level AS level
                        FROM    (
                                SELECT  @start_with := 1218,
                                        @id := @start_with,
                                        @level := 0
                                ) vars, t_hierarchy
                        WHERE   @id IS NOT NULL
                        ) ho
                JOIN    t_hierarchy hi
                ON      hi.id = ho.id
                ) q
        ) q2



Tuesday, October 23, 2018

Wednesday, September 26, 2018

Oracle SQL Convert Seconds to TIme Format

SELECT TO_CHAR(TRUNC(x/3600),'FM9900')|| chr(58) || TO_CHAR(TRUNC(MOD(x,3600)/60),'FM00')|| chr(58) || TO_CHAR(MOD(x,60),'FM00') FROM DUAL Note: where x is the time field such as departuretime

Thursday, August 30, 2018

Camel Case in SQL

Below is a query to help make the Camel Case in the LAST_NAME. The first name has already been Camel Cased so I left it alone. SELECT concat(first_name,' ', concat(UPPER(LEFT(LAST_NAME,1)),'',LOWER(SUBSTRING(LAST_NAME,2,60)))) name FROM table;

Below is just a query of all the fields I needed then export the resultset into a file name email3.txt SELECT concat(first_name,' ', concat(UPPER(LEFT(LAST_NAME,1)),'',LOWER(SUBSTRING(LAST_NAME,2,60)))) name, email, 'Saigon South International School' school, job_title FROM cardinfo_cardinfo where email <> '' and is_leaving_teacher = 0 and job_title <> '' into outfile '/tmp/email3.txt';

Monday, June 25, 2018

Attractive Email Signature

Here is my email signature design for SSIS. Vinh Vong made it happen with his code and was able to push out using Active Directory sync to Google. I've added the first div to show the background color was white for our Google G Suite is by default white. Change it to make it fit to your theme. Also all the images are png transparency.
John Nguyen
+84 28 5413 0901 ext 13173
System Administrator
jnguyen@ssis.edu.vn
Saigon South International School
78 Nguyen Duc Canh, Tan Phong, D7, HCMC, VN
+84 28 5413 0901
info@ssis.edu.vn
Stay Connected! Follow Us!

Friday, June 15, 2018

PowerSchool: Add Slide In Page for Custom Contact

Credit goes out to Sheldon from PSUG

Page fragment to add the button:

<script>
  jQuery(document).ready(function() {
    var url_string = window.location.href;
    console.log(url_string);
    var pStart = url_string.indexOf("contactid=", url_string.indexOf("#?")) + 10;
    var pEnd = url_string.indexOf("&", pStart);
    var contactID = 0;
    if (pEnd > 0)
      contactID = url_string.substring(pStart, pEnd);
    else
      contactID = url_string.substring(pStart);
    console.log(contactID);
    if (contactID != 0) {
      var html = '<div id="extensionfields-div"><label for="extensionfields-input">Extension Fields</label><a href="edit_extensionfields.html?id='+contactID+'" class="button dialogC dockedDialog" id="extensionfields-input" title="Extension Fields">Display</a></div>';
      jQuery("#suffix-div").after(html);
    }
  });
</script>

It looks like this:


The slide out page that has the input boxes (edit_extensionfields.html):
<script>
var existing = false;
jQuery.getJSON("edit_extensionfields.json?id=~(gpv.id)", function(data) {
  if (data.length > 1) {
    jQuery("#myfield1").val(data[0].myfield1);
    jQuery("#myfield2").val(data[0].myfield2);
    jQuery("#lastupdate").html(data[0].lastupdate);
    existing = true;
  }
});
function submitSave() {
  if (!existing) {
    jQuery.ajax({
      url: "/ws/schema/table/u_def_ext_person",
      async: false,
      method: "POST",
      contentType: "application/json",
      data: JSON.stringify({
        "tables":{
          "u_def_ext_person":{
            "personid":"~(gpv.id)",
            "myfield1":jQuery("#myfield1").val(),
            "myfield2":jQuery("#myfield2").val()
          }
        }
      }),
      complete: function(xhr, textStatus) {
        if (xhr.status == 200) {
          jQuery("#save-error").hide();
          jQuery("#save-complete").show();
        } else {
          jQuery("#save-complete").hide();
          jQuery("#save-error").show();
        }
      },
      error: function(result) {
        jQuery("#save-complete").hide();
        jQuery("#save-error").show();
      }
    });
  } else {
    jQuery.ajax({
      url: "/ws/schema/table/u_def_ext_person/~(gpv.id)",
      async: false,
      method: "PUT",
      contentType: "application/json",
      data: JSON.stringify({
        "tables":{
          "u_def_ext_person":{
            "myfield1":jQuery("#myfield1").val(),
            "myfield2":jQuery("#myfield2").val()
          }
        }
      }),
      complete: function(xhr, textStatus) {
        if (xhr.status == 200) {
          jQuery("#save-error").hide();
          jQuery("#save-complete").show();
        } else {
          jQuery("#save-complete").hide();
          jQuery("#save-error").show();
        }
      },
      error: function(result) {
        jQuery("#save-complete").hide();
        jQuery("#save-error").show();
      }
    });
  }
}
</script>
<div class="feedback-confirm" id="save-complete" style="display:none;">Record saved</div>
<div class="feedback-error" id="save-error" style="display:none;">There was a problem saving the record, please try again later</div>
<div class="box-round">
  <form action="edit.html" method="POST" id="saveForm">
  <table class="linkDescList">
    <tr>
      <td class="bold" style="width:180px;">My field 1</td>
      <td>
        <input type="text" name="myfield1" id="myfield1" value="">
      </td>
    </tr>
    <tr>
      <td class="bold">My field 2</td>
      <td>
        <input type="text" name="myfield2" id="myfield2" value="">
      </td>
    </tr>
    <tr>
      <td class="bold">Last Updated</td>
      <td>
        <span id="lastupdate"></span>
      </td>
    </tr>
  </table>
  </form>
</div>
<div class="button-row">
  <button type="button" onclick="submitSave()">Save</button>
</div>
Looks like this:


There's also a JSON (edit_extensionfields.json) that gets the existing values into slide in page:

[
~[tlist_sql;
select
myfield1,
myfield2,
nvl(whenmodified,whencreated) as lastupdate
from u_def_ext_person
where
personid = '~(gpv.id)'
;]
  {
    "myfield1":"~(myfield1;json)",
    "myfield2":"~(myfield2;json)",
    "lastupdate":"~(lastupdate;json)"
  },
[/tlist_sql]
  {}
]
And lastly, you'll need to install a plugin that gives permission to the slide in page to make the insert and update API calls (attached).  You'll need to edit the files inside to include your extension tables/fields.

Download: Contact Extension Plugin

Delete Custom Field From PowerSchool

Summary

This article explains how to properly delete a custom field.
  • Note: To avoid data loss, custom fields should only be deleted outside of regular business hours when other users are not editing PowerSchool information. 
  • Note: Deleting a custom field that has data in it can result in unexpected behaviour.  Before deleting it, always clear the custom field of any data (including for non-active students) by using Student Field Value.

Process

  1. Log in to PowerSchool Admin
  2. Select the District Office
  3. Search for all active and inactive students or staff (Search for /)
  4. From the Functions dropdown, select Student Field Value or Staff Field Value
  5. Click the Fields link to select the field you would like to delete, or type it in.
  6. Check Clear Field Value
  7. Click Submit
  8. Confirm the change by clicking Submit at the preview screen.
  9. Start >System > Page and Data Management > Manage Database Extensions
  10. Database table to extend = Students 
  11. Workflow type = Advanced Extension > Next
  12. Select extension name > Next
  13. Select table name > Next
  14. Find Field name and click on delete button then submit
  • Note: Depending on how much data is related to the custom field being deleted, it may only take a few minutes to remove the field, or in larger districts, an hour or more.
  • Note: PowerSchool may need to be restarted for the custom fields to be cleared from the cache.

Removal from Oracle

ATTENTION! If the field still shows in the search field, go delete the record out of FIELDSTABLE from Oracle.

delete from fieldstable where name = 'fieldname';

PowerSchool Customization Tips


Page fragment to add the button:

<script>
  jQuery(document).ready(
function() {
    var url_string = window.location.href;
    console.log(url_string);
    var pStart = url_string.indexOf("contactid=
", url_string.indexOf("#?")) + 10;
    var pEnd = url_string.indexOf("&", pStart);
    var contactID = 0;
    if (pEnd > 0)
      contactID = url_string.substring(pStart, pEnd);
    else
      contactID = url_string.substring(pStart);
    console.log(contactID);
 
    if (contactID != 0) {
      var html = '<div id="extensionfields-div"><
label for="extensionfields-input">Extension Fields</label><a href="edit_extensionfields.html?id='+contactID+'" class="button dialogC dockedDialog" id="extensionfields-input" title="Extension Fields">Display</a></div>';
      jQuery("#suffix-div").after(
html);
    }
  });
</script>

It looks like this:

The slide out page that has the input boxes (edit_extensionfields.html):

<script>
var existing = false;

jQuery.getJSON("edit_
extensionfields.json?id=~(gpv.id)", function(data) {
  if (data.length > 1) {
    jQuery("#myfield1").val(data[
0].myfield1);
    jQuery("#myfield2").val(data[
0].myfield2);
    jQuery("#lastupdate").html(
data[0].lastupdate);
    existing = true;
  }
});

function submitSave() {
  if (!existing) {
    jQuery.ajax({
      url: "/ws/schema/table/u_def_ext_
person",
      async: false,
      method: "POST",
      contentType: "application/json",
      data: JSON.stringify({
        "tables":{
          "u_def_ext_person":{
            "personid":"~(gpv.id)",
            "myfield1":jQuery("#myfield1")
.val(),
            "myfield2":jQuery("#myfield2")
.val()
          }
        }
      }),
      complete: function(xhr, textStatus) {
        if (xhr.status == 200) {
          jQuery("#save-error").hide();
          jQuery("#save-complete").show(
);
        } else {
          jQuery("#save-complete").hide(
);
          jQuery("#save-error").show();
        }
      },
      error: function(result) {
        jQuery("#save-complete").hide(
);
        jQuery("#save-error").show();
      }
    });

  } else {
    jQuery.ajax({
      url: "/ws/schema/table/u_def_ext_
person/~(gpv.id)",
      async: false,
      method: "PUT",
      contentType: "application/json",
      data: JSON.stringify({
        "tables":{
          "u_def_ext_person":{
            "myfield1":jQuery("#myfield1")
.val(),
            "myfield2":jQuery("#myfield2")
.val()
          }
        }
      }),
      complete: function(xhr, textStatus) {
        if (xhr.status == 200) {
          jQuery("#save-error").hide();
          jQuery("#save-complete").show(
);
        } else {
          jQuery("#save-complete").hide(
);
          jQuery("#save-error").show();
        }
      },
      error: function(result) {
        jQuery("#save-complete").hide(
);
        jQuery("#save-error").show();
      }
    });
  }

}
</script>

<div class="feedback-confirm" id="save-complete" style="display:none;">Record saved</div>
<div class="feedback-error" id="save-error" style="display:none;">There was a problem saving the record, please try again later</div>

<div class="box-round">
  <form action="edit.html" method="POST" id="saveForm">
  <table class="linkDescList">
    <tr>
      <td class="bold" style="width:180px;">My field 1</td>
      <td>
        <input type="text" name="myfield1" id="myfield1" value="">
      </td>
    </tr>
    <tr>
      <td class="bold">My field 2</td>
      <td>
        <input type="text" name="myfield2" id="myfield2" value="">
      </td>
    </tr>
    <tr>
      <td class="bold">Last Updated</td>
      <td>
        <span id="lastupdate"></span>
      </td>
    </tr>
  </table>
  </form>
</div>
<div class="button-row">
  <button type="button" onclick="submitSave()">Save</
button>
</div>

Looks like this:

There's also a JSON (edit_extensionfields.json) that gets the existing values into slide in page:

[
~[tlist_sql;
select
myfield1,
myfield2,
nvl(whenmodified,whencreated) as lastupdate

from u_def_ext_person
where
personid = '~(gpv.id)'
;]
  {
    "myfield1":"~(myfield1;json)",
    "myfield2":"~(myfield2;json)",
    "lastupdate":"~(lastupdate;
json)"
  },
[/tlist_sql]
  {}
]

And lastly, you'll need to install a plugin that gives permission to the slide in page to make the insert and update API calls (attached).  You'll need to edit the files inside to include your extension tables/fields.
Download: Contact Extension Plugin

Wednesday, May 9, 2018

VLC Skin Spaceship Air Carrier

There weren't any VLC skins that satisfied me so I created one based on an existing one.  Fell free to use it and make modifications as you feel fit.

Download VLC Skin - Spaceship Air Carrier

Plex Media Server

Implementation: We are using local storage for our Plex media.  Should we ever want to have a separate NAS, consider other options such as FreeNAS.

Ubuntu OS Installation

Install Ubuntu Server 18.04 with only OpenSSH packages

Dependencies
sudo su -
apt-get update; apt-get upgrade -y
apt-get install curl samba cifs-utils
Samba Configuration
mkdir /plex
chmod 777 /plex
vi /etc/samba/smb.conf
workgroup = ssis.edu.vn security = user winds support = yes
dns proxy = no
name resolve order = lmhost host winds bcast
... add to end of file ...
[PLEX Media]
comment = PLEX Media
path = /plex
browseable = yes
read only = no
guest ok = yes

Plex Media Server Installation

Download from https://www.plex.tv/downloads/ and
dpkg -i plexmediaserver_<version>.deb
systemctl enable plexmediaserver
systemctl start plexmediaserver

Start/Stop/Status Services

service plexmediaserver start
service plexmediaserver stop
service plexmediaserver status

Access Plex

On one terminal
ssh user@srvr-uplex.ssis.edu.vn -L 8888:localhost:32400
Then use web browser: http://localhost:8888/web

Network Settings

We disabled https for performance and there is no need for a secure connection since we only allow our internal network to access Plex.

Settings > Server > Network
Reference: https://support.plex.tv/articles/200430283-network/

Secure connections

Choose how your Plex Media Server handles secure connections.

Disabled – Don’t allow Plex apps to connect securely and instead force all communication over regular HTTP.

Advanced Settings

Custom server access URLs

A comma-separated list of URLs (either HTTP or HTTPS), which will be published to plex.tv for server discovery. This can be very useful in a few cases: if you’re using a VPN to get back home, if you’re using a reverse proxy in front of the media server, or if your networking configuration is otherwise unique. For instance, if you have your own custom domain with subdomain, you might add:

http://plex.ssis.edu.vn:32400

List of IP addresses and networks that are allowed without auth

The list of IP addresses or networks that can connect to Plex Media Server without authorization. Enter a comma-separated (no spaces or tabs!) list of IP addresses or specify a range using IP/netmask entries. This can be useful if you have an old, legacy, unsupported app (such as LG’s MediaLink or SmartShare apps) that you wish to use.

172.20.0.0/16,172.16.0.0/16,172.17.0.0/16,172.18.0.0/16

Thursday, February 22, 2018

OpenVAS Installation

How to Install OpenVAS Vulnerability Scanner on Ubuntu 16.04


Introduction

OpenVAS is an open source suite that can be used for vulnerability scanning and vulnerability management. It stands for Open Vulnerability Assessment System. OpenVAS is an excellent alternative to commercial security scanners such as Nessus, QualysGuard, etc. OpenVAS is divided into three parts: OpenVAS Scanner, OpenVAS Manager, and OpenVAS CLI.
In this tutorial, I will explain how to install OpenVAS Vulnerability Scanner on Ubuntu 16.04.

Prerequisites

  • A newly deployed Ubuntu 16.04 server instance.
  • A non-root user with sudo privileges setup on your server [sysad]
  • A static IP address of 172.23.11.101 configured on [srvr-uopenvas.ssis.edu.vn].
  • The rsync package must be installed

Step 1: Update the system

First, update your system to the latest stable version by running the following commands:
sudo apt-get update -y
sudo apt-get upgrade -y
sudo reboot

Step 2: Install required dependencies

Before installing OpenVAS, you will need to install its required dependencies. To install them, run the following command:
sudo apt-get install python-software-properties
Next, you will also need to install SQLite for OpenVAS manager:
sudo apt-get install sqlite3

Step 3: Install OpenVAS

By default, the OpenVAS package is not available in the Ubuntu 16.04 repository, so you will need to add OpenVAS PPA to your system's repository list.
Add the OpenVAS PPA.
sudo add-apt-repository ppa:mrazavi/openvas
Update the repository.
sudo apt-get update
Finally, install OpenVAS.
sudo apt-get install openvas
Once OpenVAS has finished installing, start the OpenVAS service with the following commands:
sudo systemctl start openvas-scanner
sudo systemctl start openvas-manager
sudo systemctl start openvas-gsa
sudo systemctl enable openvas-scanner
sudo systemctl enable openvas-manager
sudo systemctl enable openvas-gsa

Step 4: Allow OpenVAS through the system firewall

By default, OpenVAS runs on port 443, so you will need to allow this port through the UFW firewall.
sudo ufw allow https

Step 5: Access OpenVAS web interface

Before accessing OpenVAS, you will need to update its vulnerability database. [You can do the update feed from the administration tab portion of the GUI]
sudo openvas-nvt-sync
Once the database is up-to-date, open your web browser and type the URL https://172.23.11.101. On the login page, provide the default username(admin) and password (admin). After logging in, you will be presented with the OpenVAS dashboard.
If you want to change the admin user's password from command line, run the following command:
sudo openvasmd --user=admin --new-password=<new-password>
Congratulations! You have successfully installed OpenVAS on your Ubuntu 16.04 server.

Step 6: Creating Super Admin Users (DANGEROUS but necessary!)

service openvas-scanner stop
openvasmd --create-user=<username> --role="Super Admin"
openvasmd --user=<username> --new-password=<password>
service openvas-scanner start

NVT, CVE, CPE List

In order to update the NVT, CVE and CPE database listing, you need to have the SCAP feed updated.  You can perform this from the GUI or 
sudo openvas-scapdata-sync


503 - Service temporarily down

The issue started when i trying to figure out why scan result isn't working for me. I accidentally updated the cert and everything just go down hill from there. Hence, the only way is to figure out what happen. And the following solution seems to work for me.  I also had to recreate the admin user.
openvas-mkcert-client -n om -i
openvas-nvt-sync --wget
service openvas-scanner stop; service openvas-manager stop;
openvassd
rm /var/lib/openvas/mgr/tasks.db
openvasmd --progress --rebuild -v
openvasmd --create-user=admin --role=Admin
openvasmd --user=admin --new-password=admin
service openvas-scanner start; service openvas-manager start;
What this does is to remove ALL your task. And rebuild it again. It seems that somehow when we refresh the cert, all the task that bind with the old cert can't seems to perform a handshake with the new cert that i have generated. Hence, removing everything and redo it again seems to solve this problem.