Postingan

How To make sure any file or folder created in /var/www/html gets automatically owned by www-data

Automatically Set Ownership to www-data Using incron If you want to ensure that any file or folder created inside /var/www/html is automatically owned by www-data , you can use incron . Incron works similarly to cron, but instead of running based on time schedules, it monitors filesystem events such as: File or directory creation File modifications Attribute changes File deletions Step 1 — Install incron Install incron using: sudo apt-get install incron Step 2 — Allow Root to Use incron By default, not all users are allowed to use incron. You must explicitly grant permission. Open the file: sudo vim /etc/incron.allow Add the following line: root Save and exit. Step 3 — Configure incrontab Edit the incrontab for root: sudo incrontab -u root -e Add this line: /var/www/html IN_CREATE /bin/chown -R www-data:www-data /var/www/html/ Save and exit. How It Works With this configuration, whenever a new file is created inside /var/www/html , its ownership will auto...

How to install terragrunt

Terragrunt is a thin wrapper that provides extra tools for keeping your configurations DRY, working with multiple Terraform modules, and managing remote state. https://terragrunt.gruntwork.io / Steps to install terragrunt command: 1. Download from releases page   https://github.com/gruntwork-io/terragrunt/releases 2. Download the binary for your OS: e.g., On Linux wget https://github.com/gruntwork-io/terragrunt/releases/download/v0.37.1/terragrunt_linux_amd64  3. Add execute permissions to the binary. E.g., On Linux chmod u+x terragrunt_linux_amd64 4. Put the binary somewhere on your PATH. E.g., On Linux  mv  terragrunt_linux_amd64  /usr/local/bin/terragrunt 5. Check installation terragrunt --version

Cara install Python dan virtualenv

 Install Python contoh install python 3.7, python3-distutils python3-pip, python3-virtualenv. Update paket sudo apt update Install Common Dependencies sudo apt install software-properties-common Menambahkan repository  https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa sudo add-apt-repository ppa:deadsnakes/ppa Install Python sudo apt install python3.7 untuk versi python lain bisa sesuikan saja misal python3.8, python3.9 Install module python3.7-disutils dan  Python3-pip sudo apt-get install python3.7-distutils python3-pip python3-virtualenv Dibawah contoh script ansible dengan case menginstall module proxmoxer untuk manage server proxmox: --- - name: Setup Proxmoxer   hosts: server1   become: yes   tasks:     - name: Add repository       apt_repository: repo="ppa:deadsnakes/ppa"     - name: Install Python packages       apt:         pkg:           - software-p...

Parsing Json in Golang

Concept: []Json array ---->[]Byte array ----> Struct Syntax: func Unmarshal(data []byte, v interface{}) error Code: // Golang program to illustrate the // concept of parsing JSON to an array package main import (     "encoding/json"     "fmt" ) // declaring a struct type Competitors struct {     // defining struct variables     Username string     School   string     Online   bool     Score     int } // main function func main () {     // defining a struct instance     var competitors []Competitors     // JSON array to be decoded     // to an array in golang     Data := [] byte ( `     [         {"username": "competitor1", "school": "SMK Swasta 1", "online": true, "score": 987},         {"username": "competitor2", "school": "SMK Negeri 7", "online": false, "score": 432},    ...

Parse JSON using Python Programming

Gambar
Berikut adalah contoh bagian-bagian dari struktur file Json, dengan mengetahui bagian-bagian tersebut mempermudah untuk memahami dan memilah data. Sebelumnya sudah pernah juga menulis tentang parsing file json ini menggunakan perintah linux jq , jika tertarik ini link nya  https://nciptandani.blogspot.com/2021/11/cara-parsing-file-json-dengan-jq.html Pada dasarnya file json terdiri dari key dan value, key berupa string. Satu object file Json bisa terdiri dari berbagai tipe data, seperti string, object, array, int, null, boolean sebagai value nya.   https://docs.exivity.com/data-pipelines/extract/parslets Cara membaca file Json di Python https://pynative.com/python-json-load-and-loads-to-parse-json/ https://www.freecodecamp.org/news/python-read-json-file-how-to-load-json-from-a-file-and-parse-dumps/ https://python.plainenglish.io/data-extraction-parse-a-3-nested-json-object-23cb978b66ad File Json berikut terdiri dari key competitors terdapat value berupa array yang berisi usern...

Cara parsing file JSON dengan jq

Gambar
File json banyak ditemui dalam kegiatan sehari-hari baik programmer, system/network engineer, dll. File Json mempunyai struktur, pada tutorial ini hanya akan membahas bagaimana memparsing/mengurai file Json, misalnya hanya mengambil bagian data-data yang dibutuhkan saja.  Disini menggunakan command jq, sebelum menggunakan perintah ini bisa menginstall terlebih dahulu, disini menggunakan linux, #sudo apt install jq Gambar dibawah ini bagus memperlihatkan bagaimana format file json, isi file json pada dasarnya berisi data type pada umumnya. https://www.shapediver.com/blog/json-objects-explained Contoh ada file json dibawah ini: score.json {   "eventname": "Lomba Siswa",   "modulename": "Linux Project",   "competitors": [     {       "username": "competitor1",       "score": "98",       "institution": "SMK Negeri 4"     },     {       "username": "competitor2",...

Note install Docker and Docker compose Centos

Purpose: Practice, POC Update to get the latest packages and security  sudo yum update    sudo yum upgrade  sudo reboot Install yum-utils    sudo yum install -y yum-utils Install Repository  sudo yum-config-manager \     --add-repo \     https://download.docker.com/linux/centos/docker-ce.repo Install Docker packages  sudo yum install docker-ce docker-ce-cli containerd.io Start Docker services  sudo systemctl start docker Enable Docker process on boot  sudo systemctl enable docker Testing   sudo docker run hello-world Install Docker-compose sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose How to use docker compose  https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-o...