Kamis, 15 Agustus 2024

Access postgresql on host from your container

Make sure that you can access your postgresql using: 
psql -U postgres -h localhost -W 

Docker
Install Docker (skip if you have installed docker before)
- sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" (I'm using arm processor)
- sudo apt update
- sudo apt install docker-ce
- sudo systemctl status docker (make sure status is active)
- sudo usermod -aG docker ${USER}
- su - ${USER}
- id -nG

o ifconfig docker0 check your host ip on docker
example:
ifconfig docker0 docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:54:c5:b2:d1 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
o Running PostgreSQL in Docker
docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres


o on your container do some migration (if you are using laravel)
docker exec -it <your-laravel-container> bash
php artisan migrate

Create swap partition

lsblk to check your hdd

sudo fdisk /dev/sdX

Replace /dev/sdX with the correct device name. Inside the fdisk utility:

  • Press n to create a new partition.
  • Choose the partition number, default is usually fine.
  • Press Enter to accept the default starting and ending sectors.
  • Press t to change the partition type.
  • Enter 82 to set the partition type to "Linux swap".
  • Press w to write the changes to the disk.
sudo mkswap /dev/sdX1
sudo vim /etc/fstab
add /dev/sdX1 none swap sw 0 0
verify swap sudo swapon --show

Selasa, 13 Agustus 2024

Create secret for SSL Certificate on Ingress

 kubectl create secret  tls wildcard-secret \

--cert=wildcard.crt \

--key=wildcard.key \

-n your-app-namespace --output yaml > tls.yml


apply the configuration file
kubectl apply -f tls.yml

Install NGINX Ingress Controller

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx

helm repo update

helm install nginx-ingress ingress-nginx/ingress-nginx \

--namespace ingress-nginx \

--create-namespace

verify your installation

kubectl get pods -n ingress-nginx

kubectl get svc -n ingress-nginx


If you want to put static IP on your ingress controller

helm install nginx-ingress ingress-nginx/ingress-nginx \

--namespace ingress-nginx \

--set controller.service.loadBalancerIP=your-ip-public \

--create-namespace

Jumat, 10 September 2021

openldap and pgadmin authentication in Ubuntu

 install postgresql:

  • sudo apt update
  • sudo apt -y install vim bash-completion wget
  • wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
  • echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt
  • /sources.list.d/pgdg.list
  • sudo apt update
  • sudo apt -y install postgresql-12 postgresql-client-12
  • systemctl status postgresql.service
  • systemctl status postgresql@12-main.service
  • sudo su - postgres
  • psql -c "alter user postgres with password 'StrongAdminP@ssw0rd'"
  • psql

source: https://computingforgeeks.com/install-postgresql-12-on-ubuntu/

Minggu, 05 Agustus 2018

Screen on Linux

screen linux command
ex:  screen scp -r -P 22 somefolders doni@host-destination:/home/doni

detached screen
ctrl + a + d

display screen list
screen -ls

resume detached process
doni@bisnistoday:~$ screen -ls
There are screens on:
26608.pts-0.bisnistoday (08/05/18 02:21:38) (Detached)
26600.pts-0.bisnistoday (08/05/18 02:19:47) (Detached)
2 Sockets in /var/run/screen/S-doni.
doni@bisnistoday:~$ screen -r 27714.pts-0.bisnistoday

Source: https://askubuntu.com/questions/124897/how-do-i-detach-a-screen-session-from-a-terminal

Backup & Restore Database on Postgresql

backup
pg_dump -U username dbname > filebackup.sql

restore
psql dbname < filebackup.sql

Kamis, 15 Februari 2018

Firebird isql shell command in Linux

- vim yourshellsql.sh

#!/bin/sh/usr/bin/isql-fb -user YOURUSERNAME -password YOURPASSWORD -database -x '/path/DATABASE.GDB' <<EOF

CONNECT /path/DATABASE.GDB;

SELECT * FROM YOURTABLE;

UPDATE YOURTABLE SET NAME = '';

COMMIT WORK;

go

QUIT

EXIT

EOF


- ./yourshellsql.sh


source:

- https://it.toolbox.com/question/how-to-invoke-sybase-commands-in-a-shell-script-040411

- https://www.unix.com/shell-programming-and-scripting/45212-isql-query-unix-shell-script.html

Rabu, 14 Februari 2018

SSL certificate problem: unable to get local issuer certificate

- config php.ini
- enable curl.cainfo=
- edit curl.cainfo= to curl.cainfo=/your/path/cacert.pem (i download from https://curl.haxx.se/ca/cacert.pem, <my development>)

install curl in Windows 10

- run Command Prompt as Administrator
- paste @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
choco install curl

Source: https://chocolatey.org/install#installing-chocolatey

Rabu, 07 Februari 2018

virtual environment python in Windows

- pip install virtualenv
- pip install virtualenvwrapper-win
- mkvirtualenv virtualpython3

result:
C:\Users\webDev\Envs is not a directory, creating
Using base prefix 'c:\\python36'
New python executable in C:\Users\webDev\Envs\virtualpython3\Scripts\python.exe
Installing setuptools, pip, wheel...done.
(virtualpython3) webDev@WEBDEV-PC E:\doni\

source:
- https://virtualenv.pypa.io/en/stable/userguide/
- http://timmyreilly.azurewebsites.net/python-pip-virtualenv-installation-on-windows/
- https://stackoverflow.com/questions/46869528/install-python-3-6-3-in-virtualenv-using-pip-in-windows-10

Kamis, 01 Februari 2018

remote AWS using terminal on Mac OSX

- Convert .ppk to .pem

  • puttygen server.ppk -O private-openssh -o server.pem (if puttygen not installed, brew install putty)

- chmod go-rw server.pem
- ssh -i server.pem user@hostname

Source:

  • https://stackoverflow.com/questions/33273180/create-a-pem-from-a-ppk-file
  • https://www.ssh.com/ssh/putty/mac/
  • https://www.youtube.com/watch?v=q6Hm-JIzjT8

Selasa, 30 Januari 2018

MC (Midnight Commander) keyboard shortcut for Mac OSX

----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
Open same working directory in the inactive panel: Esc + i
Open parent working directory in the inactive panel: Esc + o
Go to top of directory in active pane: Esc + v / Esc + g
Go to bottom of directory in active pane: Esc + j / Ctrl + c
Go to previous directory: Esc + y
Search pop-up: Esc + ?
----- Ctrl -----
Refresh active panel: Ctrl + r
Selecting files and directories: Ctrl + t
Switch active <-> inactive panels: Ctrl + i
Switch active <-> inactive panels content: Ctrl + u
Execute command / Open a directory: Ctrl + j
----- F -----
F1: help
F2: user menu
F3: read file / open directory
F4: edit file
F5: copy file or direcotry
F6: move file or directory
F7: create directory
F8: delete file / directory
F9: open menu bar
F10: exit MC

Copied from: http://pastebin.com/i9kfVKT9

Source: https://gist.github.com/sgergely/3793166