Skip to content

Instantly share code, notes, and snippets.

@geo-stanciu
Last active May 26, 2018 15:40
Show Gist options
  • Select an option

  • Save geo-stanciu/d3e190444b0650e0fab7f4cb56fa2a25 to your computer and use it in GitHub Desktop.

Select an option

Save geo-stanciu/d3e190444b0650e0fab7f4cb56fa2a25 to your computer and use it in GitHub Desktop.
setup ubuntu-server
# get iso
wget http://releases.ubuntu.com/16.04.4/ubuntu-16.04.4-server-amd64.iso
# create vm path
mkdir -p /backup/virtual_machines/LicensePlates/Snapshots
cd /backup/virtual_machines/LicensePlates
# VM name
VM='LicensePlates'
# hdd 160 GB
VBoxManage createhd --filename $VM.vdi --size 163840
VBoxManage createvm --name $VM --ostype "Ubuntu_64" --register
VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium $VM.vdi
VBoxManage storagectl $VM --name "IDE Controller" --add ide
VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium /home/oracle/ubuntu-16.04.4-server-amd64.iso
VBoxManage modifyvm $VM --ioapic on
VBoxManage modifyvm $VM --boot1 dvd --boot2 disk --boot3 none --boot4 none
# 4 GB RAM - 128 MB video
VBoxManage modifyvm $VM --memory 4096 --vram 128
# brdige adapter (change em1 with your card name: ex: eth0)
# to identify the network adapter run: ifconfig
VBoxManage modifyvm $VM --nic1 bridged --bridgeadapter1 em1
# setup 4 cores
VBoxManage modifyvm $VM --cpuhotplug on
VBoxManage modifyvm $VM --cpus 4
################################################################################
# start VM
# you will need acces to the host server(ex via UltraVNC) or need to search ubuntu command line install scripts
# make sure you only install ssh server role, the rest will be installed following the commands from this guide
################################################################################
# once you finished the install, stop the machine and remove DVD
VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium none
# start the machine again
################################################################################
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install openssh-server
sudo apt-get install unzip
################################################################################
# put static IP
sudo nano /etc/network/interfaces
# comment the following line
iface enp0s3 inet dhcp
# add static config (change with appropriate values)
iface enp0s3 inet static
address 192.168.18.169
netmask 255.255.255.0
network 192.168.18.0
broadcast 192.168.18.255
gateway 192.168.18.1
dns-nameservers 192.168.18.1 8.8.8.8 8.8.4.4
# CTRL+x and type y to save and exit
# restart network
sudo /etc/init.d/networking restart
# open /etc/resolv.conf and check if your nameservers are present
nameserver 192.168.18.1
nameserver 8.8.8.8
nameserver 8.8.4.4
################################################################################
# install PostgreSQL 10
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
################################################################################
sudo mkdir -p /home/ubuntu/backup/devel/archivelog
sudo chown postgres:postgres -R /home/geo/backup
################################################################################
sudo su - postgres
psql
# set postgres password
\password
# enter password again
################################################################################
ALTER SYSTEM SET
max_connections = '100';
ALTER SYSTEM SET
shared_buffers = '1GB';
ALTER SYSTEM SET
effective_cache_size = '3GB';
ALTER SYSTEM SET
maintenance_work_mem = '256MB';
ALTER SYSTEM SET
min_wal_size = '1GB';
ALTER SYSTEM SET
max_wal_size = '2GB';
ALTER SYSTEM SET
checkpoint_completion_target = '0.7';
ALTER SYSTEM SET
wal_buffers = '16MB';
ALTER SYSTEM SET
default_statistics_target = '100';
ALTER SYSTEM SET
random_page_cost = '4';
ALTER SYSTEM SET
effective_io_concurrency = '2';
ALTER SYSTEM SET
max_worker_processes = '4';
ALTER SYSTEM SET
max_parallel_workers_per_gather = '2';
ALTER SYSTEM SET
max_parallel_workers = '4';
ALTER SYSTEM SET
work_mem = '5242kB';
ALTER SYSTEM SET wal_level = 'logical';
ALTER SYSTEM SET wal_log_hints = 'on';
ALTER SYSTEM SET archive_mode = 'on';
ALTER SYSTEM SET wal_compression='on';
ALTER SYSTEM SET max_wal_senders = '8';
ALTER SYSTEM SET wal_keep_segments='24';
ALTER SYSTEM SET max_parallel_workers_per_gather = '4';
ALTER SYSTEM SET max_worker_processes = '12';
ALTER SYSTEM SET archive_command = 'test ! -f /home/ubuntu/backup/devel/archivelog/%f && cp %p /home/ubuntu/backup/devel/archivelog/%f';
################################################################################
postgres=# show hba_file;
hba_file
-------------------------------------
/etc/postgresql/10/main/pg_hba.conf
(1 row)
CREATE USER ubuntu WITH
LOGIN
NOSUPERUSER
INHERIT
CREATEDB
CREATEROLE
REPLICATION;
\password ubuntu
# enter password again
CREATE DATABASE devel
WITH
OWNER = ubuntu
ENCODING = 'UTF8'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;
\q
exit
################################################################################
sudo apt-get update && sudo apt-get install -y openalpr openalpr-daemon openalpr-utils libopenalpr-dev
################################################################################
# open alprd config and change the following:
sudo nano /etc/openalpr/alprd.conf
country = eu
site_id = your_unique_site_name
stream = http://your_mjpeg_stream_here/stream.mjpeg
store_plates = 1
store_plates_location = /var/lib/openalpr/plateimages/
upload_data = 1
uload_address = http://localhost:9080/store-plate/
################################################################################
Download https://www.adrive.com/public/JrGyFF/LPReceiver_v0.0.2.0.zip
Connect with WinSCP and copy the archive on the server.
mkdir /home/ubuntu/LPReceiver
unzip LPReceiver_v0.0.2.0.zip -d /home/ubuntu/LPReceiver
# set as executable
chmod u+x /home/ubuntu/LPReceiver/stoplpreceiver.sh
# change the user, password and host in the database config section.
nano /home/ubuntu/LPReceiver/app.config
psql -d devel -U ubuntu -f /home/ubuntu/LPReceiver/scripts/PostgreSQL/CreTab.sql -o /home/ubuntu/LPReceiver/update0.0.2.0.txt
# Review /home/ubuntu/LPReceiver/update0.0.2.0.txt logfile for any errors
################################################################################
# Autostart LPReceiver
sudo nano /etc/systemd/system/dlpreceiver.service
[Unit]
Description=LPReceiver Service
After=network.target
[Service]
User=ubuntu
Restart=on-failure
Type=simple
WorkingDirectory=/home/ubuntu/LPReceiver
ExecStart=/home/ubuntu/LPReceiver/lpreceiver
ExecStop=/home/ubuntu/LPReceiver/stoplpreceiver.sh
[Install]
WantedBy=multi-user.target
################################################################################
sudo systemctl daemon-reload
sudo systemctl enable dlpreceiver.service
sudo systemctl start dlpreceiver.service
################################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment