Category Archives: howto

Postgres on podman

Steps to getting PostgreSQL running on Endeavor via Podman.

Install Podman:

sudo pacman -S podman podman-docker

Create the PostgreSQL container:


sudo podman run -d --rm -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=dapassword -e PGDATA=/opt/pgdata --volume /opt/postgres:/opt/pgdata postgres

Copy the backup to the container:

sudo podman cp /home/steven/Downloads/kapowey.tar kapoweypg:/tmp/

Run bash on the container and create the database as the postgres user

sudo podman exec -it 396 /bin/bash
su - postgres
createdb kapowey

Restore the backup on the container:

sudo podman exec -i 396 pg_restore -U postgres -c -v -d kapowey "/tmp/kapowey.tar"

Setup user on database:

CREATE user kapowey with encrypted password 'dapassword';

ALTER database kapowey OWNER to kapowey;

GRANT CONNECT ON DATABASE kapowey TO kapowey;

GRANT all privileges on database kapowey to kapowey;

GRANT all privileges on all tables in schema public to kapowey;

GoAccess working with Centos 7

I use Nginx as a proxy for my dotnet core application and with that I wanted to get some reporting so I installed GoAccess, which generates a nice HTML report.

Set this up in your root crontab via a “crontab -e” as root:

0 * * * * /bin/bash /opt/generate_report.sh

~

Note the extra blank line, you will go crazy trying to get this to work if you don’t add the blank line at the end.

Then edit your generate_report.sh file like this:

#!/bin/sh
/usr/bin/zcat -f /var/log/nginx/*.log* | /usr/bin/goaccess --log-format=COMBINED -o /var/www/logreport.html -

Note the extra “-” at the end of the command line without it the cron execute does not work.

Enjoy!

CentOS First Steps

First security steps when setting up any new internet facing linux server:

  • Create a new user account
    • # adduser username
    • # passwd username
    • # usermod -aG wheel username
  • Send SSH key
    • scp id_rsa.pub username@hostname:/home/username/id_rsa.pub
    • $ mkdir ~/.ssh
    • $ cat id_rsa.pub >> ~/.ssh/authorized_keys
    • $ chmod 700 ~/.ssh
    • $ chmod 600 ~/.ssh/authorized_keys
  • Ensure SSH key authentication works
    • Disconnect and then reconnect, you should get prompted for your private key password not your server password (you did provide a password for your private key, right?!)
    • Do not disable “PasswordAuthentication” option below unless you are positive you are authentication SSH via keys – you will be locked out of your server and no longer able to SSH in.
  • Disable Root SSH, Set Protocol 2 and Password SSH
    • $ sudo yum install -y nano
    • $ sudo nano /etc/ssh/sshd_config
      • PermitRootLogin no
      • Protocol 2
      • PasswordAuthentication no
    • $ sudo service sshd restart
    • Ensure you can still SSH back into the box using your key only.
  • Update packages
    • $ sudo yum upgrade
  • Reboot
    • $ sudo reboot

Three Letter Acronyms (TLA) Every Developer Should Know

Here is a list of Three Letter Acronyms I think every developer (and those professionals involved with software development) should know, at least be familiar with:

1NF First Normal Form
2NF Second Normal Form
3NF Third Normal Form
ALM Application Lifecycle Management
API Application Programming Interface
BDD Behavior Driven Development
BRD Business Requirements Document
CBS Cost Breakdown Structure
CMS Content Management System
CRM Customer Relationship Management
CTM Close To Metal
CTS Clear To Send
CUA Common User Access
DDD Domain Driven Development
DDL Data Definition Language
DML Document Object Model
DRY Don't Repeat Yourself
DTD Document Type Definition
EOD End Of Day
EOF End Of File
EOL End Of Line
EOM End Of Message
ERD Entity Relationship Diagram
ERM Entity Relationship Model
ESB Enterprise Service Bus
ETA Estimated Time Of Arrival
ETL Extract, Transform, Load
FDD Feature Driven Development
FTP File Transfer Protocol
FTW For The Win
FUD Fear Uncertainty (and) Doubt
FYI For Your Information
GUI Graphical User Interface
IDE Integrated Development Environment
IPS Instructions Per Second
IRC Internet Relay Chat
ISO Internet Organization for Standardization
JIT Just In Time
KVM Keyboard, Video, Mouse
LOC Lines Of Code
LOE Level Of Effort
LSB Least Significant Bit
LTR Left To Right
LUN Logical Unit Number
MDA Mail Delivery Agent
MDA Model Driven Architecture
MDI Multiple Document Interface
MIS Management Information Systems
MOM Message Oriented Middleware
MSB Most Significant Bit
MUA Mail User Agent
MVC Model View Controller
NCQ Native Command Queuing
NDA Non Disclosure Agreement
NFS Network File System
NIC Network Interface Controller
NOC Network Operations Center
NTP Network Time Protocol
NaN Not A Number
OID Object Identifier
OLE Object Linking (and) Embedding
OOE Out (of) Order Execution
OOM Out Of Memory
OOO Out Of Office
OOT Out Of Town
ORM Object Relational Mapping
OSS Open Source Software
POC Proof Of Concept
QOS Quality Of Service
RAD Rapid Application Design/Development
RFC Request For Comments
RFP Request For Proposal
RFQ Request For Quote
RIA Rich Internet Application
RLE Run Length Encoding
ROI Return On Investment
ROM Rough Order Of Magnitude
RTC Real Time Clock
RTL Right To Left
RTS Ready To Send
SCM Source Code Management
SDI Single Document Interface
SDK Software Development Kit
SMT Simultaneous Multi-Threading
SOA Service Oriented Architecture
SLA Service Level Agreement
SPA Single Page Application
SQL Structured Query Language
SSO Single Single On
SSL Secure Socket Layer
TCP Transmission Control Protocol
TDD Test Driven Development
TLA Three Letter Acronym
TLS Transport Layer Security
TTF True Type Font
UAC User Account Control
UAT User Acceptance Testing
UDP User Datagram Protocol
UML Unified Modeling Language
UPS Uninterruptible Power Supply
URI Uniform Resource Identifier
URL Uniform Resource Locator
URN Uniform Resource Name
UTC Coordinated Universal Time
UTF Unicode Transformation Format
VFS Virtual File System
VPN Virtual Private Network
W3C World Wide Web Consortium
WAI Web Accessibility Initiative
WET We Enjoy Typing or Write Everything Twice
WFH Working From Home
WFI Wait For Interrupt
XML eXtensible Markup Language
XSD XML Schema Definition
XSL eXtensible Stylesheet Language
XSS Cross Site Scripting
YTD Year To Date

Creating a full MariaDB backup

For some reason I have had a time finding succinct information on creating a simple full (and by full I mean a file you can use to bare metal recover a database) backup with MariaDB.

1. Make a ~/.my.conf file:

[mysqldump]
user=<your_database>
password=<your_password>

2. Run this:

mysqldump --add-drop-table -h server_ip database_name  | pv | gzip -9 > /tmp/backup.sql.tar.gz

3. Copy your newly created backup file to a secondary storage point.

4. Enjoy!

Splitting CUE/Log Flac Files

I ran across some old FLAC files I ripped and for some unknown reason I decided at the time that a the FLAC LOG/CUE format was the way to go. I dunno perhaps I was intoxicated at the time.

At any rate is what I used to split the single FLAC out into files.

Install the necessary tools (this is Pacman which I use on my Manjaro box):

# pacman -S cuetools shntool flac mutagen

Split out the giant FLAC file into smaller track FLAC files:

$ shnsplit -f cue_file.cue -t "%n %t" -o "flac flac -s -8 -o %f -" flac_file.flac

Then this populates the id3 tags in the newly split out FLAC files from the CUE file:

$ cuetag.sh cue_file.cue *.flac

Enjoy!

Setting up WordPress FavIcon

I wanted something a bit more custom looking than the stock WordPress Icon so I decided to take my avatar and make a favIcon from that.

I went to Favicon-Generator it does a nice job of resizing and making the “ico” file, which is pain to create, and gives you several varying sizes of your uploaded image:

favicon_generated_set

It also does a nice job of creating the html to include in your header. I only used a subset from the generated html:

<link rel="icon" type="image/png" sizes="192x192"  href="/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">

I created a child theme in Word Press then edited the header to include the above in the <head> block.

Enjoy!

ASP.NET MVC 5 Preview

Managed to get ASP.NET 5 preview up and working via Visual Studio 2015 RC in a Docker container hosted on my local Ubuntu server (read; not an Azure hosted server). All in Oracle VirtualBox Virtual Machines.

ASP.NET 5 Preview Running on a Local Docker Ubuntu VM
ASP.NET 5 Preview

My VirtualBox host is a Windows 8.1 box and I used two VMs: a Windows 7 Development Box (I tried Windows 8.1 in a VM and the performance was terrible) and a Ubuntu Server 14.04.2.

For the most part it was pretty much documented here. My only hiccup was that I had to do a “Restore Packages” to get Grunt to install its packages, this didn’t happen with a “Rebuild” as I would expect. I set my “Custom Docker Host” settings like this:

Custom Docker Settings For Publishing To Docker Server
Custom Docker Settings

After publishing from Visual Studio I was able to get a list of the images on the Docker server and it now included the new published app:

{
    Created: 1432561734,
    Id: "0ad5302ad774376604042790713f79ffa98fceca9826159bcd93b1e20dfce552",
    Labels: {},
    ParentId: "becb4b73fe255ab7284cfdcf3f5768520736317cd5f0456bf169bb9f441763d3",
    RepoDigests: [],
    RepoTags: [
        "helloworldweb1:latest"
    ],
    Size: 0,
    VirtualSize: 756665995
},

So the next challange is to get MongoDB setup running in a Dockerized instance on my Ubuntu server then create a ASP.NET MVC application consuming that server and publish that via Docker and see how performance and maintenance plays out.

 

ASP.NET 5 on Ubuntu on VirtualBox

I figured out the magic sauce for getting ASP.NET 5 running on Ubuntu 14.04 in a VirtualBox VM.

asp_6_on_ubuntu_vm

I followed this mostly for the setup but your Dockerfile should look like this:

FROM microsoft/aspnet

COPY project.json /app/

WORKDIR /app

RUN ["dnu", "restore"]

COPY . /app

EXPOSE 5004

ENTRYPOINT ["dnx", "project.json", "kestrel"]

Be sure and set your VirtualBox setting to “Bridged” so you can hit the IP from your workstation.

Enjoy!