Thursday, September 7, 2023

Script install nodejs v18 di Debian 11

#!/bin/sh

# howto install nodejs v18
# require debian 11
sudo apt-get update -y
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings

# cek nodejs
pkgs='nodejs'
if ! dpkg -s $pkgs >/dev/null 2>&1; then
   # cek gpg sudah ada apa blum
   FILE=/etc/apt/keyrings/nodesource.gpg
   if [ -f "$FILE" ]; then
      echo "$FILE exist!"
      else
      curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
      fi
   NODE_MAJOR=18
   echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
   sudo apt-get update -y
   sudo apt-get install nodejs -y
fi

nodejs -v
echo "NodeJS telah terinstall!"

Friday, March 10, 2023

Recovery ZFS Frebsd

# zpool status
  pool: zroot
 state: DEGRADED
status: One or more devices could not be opened.  Sufficient replicas exist for
        the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-2Q
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       DEGRADED     0     0     0
          mirror-0  DEGRADED     0     0     0
            ada0p3  ONLINE       0     0     0
            ada1p3  UNAVAIL      0     0     0  cannot open

errors: No known data errors`

# zpool detach zroot ada1p3
# zpool status
  pool: zroot
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          ada0p3    ONLINE       0     0     0

errors: No known data errors
# gpart create -s GPT ada1
ada1 created
root@:/home/rahox # gpart show
=>      40  33554352  ada0  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064       984        - free -  (492K)
      2048   4194304     2  freebsd-swap  (2.0G)
   4196352  29356032     3  freebsd-zfs  (14G)
  33552384      2008        - free -  (1.0M)

=>      40  33554352  ada1  GPT  (16G)
        40  33554352        - free -  (16G)
 # gpart bootcode -b /boot/pmbr ada1
bootcode written to ada1
# gpart add -t freebsd-boot -s 512K ada1
ada1p1 added

 # gpart show
=>      40  33554352  ada0  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064       984        - free -  (492K)
      2048   4194304     2  freebsd-swap  (2.0G)
   4196352  29356032     3  freebsd-zfs  (14G)
  33552384      2008        - free -  (1.0M)

=>      40  33554352  ada1  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064  33553328        - free -  (16G)
root@:/home/rahox # gpart bootcode -p /boot/gptboot -i 1 ada1
partcode written to ada1p1
root@:/home/rahox # gpart add -t freebsd-swap -s 2G ada1
ada1p2 added
root@:/home/rahox # gpart show
=>      40  33554352  ada0  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064       984        - free -  (492K)
      2048   4194304     2  freebsd-swap  (2.0G)
   4196352  29356032     3  freebsd-zfs  (14G)
  33552384      2008        - free -  (1.0M)

=>      40  33554352  ada1  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064   4194304     2  freebsd-swap  (2.0G)
   4195368  29359024        - free -  (14G)
root@:/home/rahox # gpart add -t freebsd-zfs ada1
ada1p3 added
root@:/home/rahox # newfs -Uj /dev/ada1p3
/dev/ada1p3: 14335.5MB (29359024 sectors) block size 32768, fragment size 4096
        using 23 cylinder groups of 625.22MB, 20007 blks, 80128 inodes.
        with soft updates
super-block backups (for fsck_ffs -b #) at:
 192, 1280640, 2561088, 3841536, 5121984, 6402432, 7682880, 8963328, 10243776,
 11524224, 12804672, 14085120, 15365568, 16646016, 17926464, 19206912, 20487360,
 21767808, 23048256, 24328704, 25609152, 26889600, 28170048
Using inode 4 in cg 0 for 33554432 byte journal
newfs: soft updates journaling set
root@:/home/rahox # gpart show
=>      40  33554352  ada0  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064       984        - free -  (492K)
      2048   4194304     2  freebsd-swap  (2.0G)
   4196352  29356032     3  freebsd-zfs  (14G)
  33552384      2008        - free -  (1.0M)

=>      40  33554352  ada1  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064   4194304     2  freebsd-swap  (2.0G)
   4195368  29359024     3  freebsd-zfs  (14G)
root@:/home/rahox # zpool attach zroot ada0p3 ada1p3
root@:/home/rahox # zpool status
  pool: zroot
 state: ONLINE
  scan: resilvered 762M in 00:00:08 with 0 errors on Sat Mar 11 03:31:29 2023
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            ada0p3  ONLINE       0     0     0
            ada1p3  ONLINE       0     0     0

errors: No known data errors

Wednesday, January 11, 2023

Script Cek GGC Pada Mikrotik

/tool fetch url="https://redirector.gvt1.com/report_mapping\?di=no" http-method=get output=file dst-path=ggc

:delay 1

# baca isi file
:local info [/file get ggc contents]

# Jika masih blum dapet content GGC Domestik
#/log warning message=[:pick $info 0 [:find $info ": router"]]

# Jika sudah dapet content GGC Domestik
/log warning message=[:pick $info 0 [:find $info "("]]

Cara Limit Bandwidth Vlan dalam Port Switch Huawei

#
traffic classifier VLAN234 type or
 if-match vlan 234
#
traffic behavior LIMIT-VLAN234
 statistics enable
 car cir 512000 kbps pir 512000 kbps
#
traffic policy VLAN234
 classifier VLAN234 behavior LIMIT-VLAN234 precedence 5
#
interface Eth-Trunk15
 description Po15
 port link-type bla bla bla... sesuaikan wae kondisine pie
 traffic-policy VLAN234 inbound 
 traffic-policy VLAN234 outbound 
#