Skip to content

Instantly share code, notes, and snippets.

# --zero-speed=1000000000 for 1000Mbps
# --zero-speed=100000000 for 100Mbps
cfgmaker --snmp-options=:::::2 --global "WorkDir: /usr/local/www/data/html/mrtg/172.16.1.1" --global "Options[_]: growright, bits" --global "Language: big5" --global 'AddHead[_]:<script type="text/javascript" src="//jal.tw/google_analytics.js"></script>' --zero-speed=1000000000 --show-op-down --if-filter='$if_type!=1 && $if_type!=53 && $if_type!=24 && $if_type!=131 && $if_type!=135 && $if_type!=136 && $if_type!=137 && $if_type!=142 && $if_type!=150 && $if_type!=217 && $if_type!=218 && $if_type!=222 && $if_type!=223' community_readonly@172.16.1.1 --output=172.16.1.1.cfg
# -i in-place edit, only work for GNU sed, not portable.(直接改原始檔案,僅支援 GNU sed,跨平台有可能會失效)
/usr/bin/sed -i '' -e 's/iso-8859-15/big5/g' */*/index.html
/usr/bin/sed -i '' -e '/Command line/d' */*/index.html
/usr/bin/sed -i '' -e '/Command-Line/d' */*/index.html
/usr/bin/sed -i '' -e '/commandline/d' */*/index.html
/usr/bin/sed -i '' -e '/HTTP-EQUIV="Expires"/d' */*/index
@jal-tw
jal-tw / shell-script_with_lock_and_pid.sh
Created December 19, 2017 10:33
C shell script, lock file, pid, check process alive
#!/bin/sh
name="shell-script"
now=`/bin/date`
echo "Starting at ${now}."
LOCKFILE="/var/run/${name}.lock"
if [ -f ${LOCKFILE} ]
then
Suite for nginx, apache2.4, dovecot, postfix
Tips:
Understand Cipher String Format
https://msdn.microsoft.com/en-us/library/windows/desktop/aa374757%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
ALL:!DH:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@STRENGTH
Apache 2.4
/* jal.180308 */
參考資料: https://www.cloudflare.com/dns/dnssec/ecdsa-and-dnssec/
curl -s http://www.internic.net/domain/root.zone | awk '$4 == "DS" { print $6}' | sort -n | uniq -c
63 5 (RSA/SHA-1)
525 7 (RSASHA1-NSEC3-SHA1)
2150 8 (RSA/SHA-256)
38 10 (RSA/SHA-512)
curl -s http://www.internic.net/domain/root.zone | awk '$4 == "DS" { print $1, $5, $6}' | uniq | awk '{print $3}' | sort | uniq -c
@jal-tw
jal-tw / Update_FreeBSD_Old_Version.txt
Last active April 13, 2018 09:20
How to Update Really Old FreeBSD Version
// This document showing how to upgrade some really old version's FreeBSD to latest via Internet.
// ================================================
// Part 0: Before you start anything
// ================================================
# reboot
// Make sure your server's OS and hardware are both fine.
// ================================================
// Part 1: Reversion from stable to release version
#!/bin/sh
DATE=`/bin/date +%Y%m%d`
TIME=`/bin/date "+%Y-%m-%d %H:%M:%S"`
DDIR=`/usr/bin/readlink /home/hosts/www/jal.tw/html`
SDIR="/home/hosts/www/jal.tw"
BDIR="/root/shell/dump"
PASS="PleaseTellMe"
TITLE="jal.tw"
EMAIL="jal@jal"
#!/bin/sh
DATE=`/bin/date +%Y%m%d`
TIME=`/bin/date "+%Y-%m-%d %H:%M:%S"`
SDIR="/usr/local/etc"
DDIR="namedb"
BDIR="/home/backup"
PASS="IWISHYOUCANTELLME"
TITLE="jal.tw dns"
EMAIL="jal@jal"
Apache process size 1
ps -ylC httpd --sort:rss | awk '{sum+=$8; ++n} END {print "Tot="sum"("n")";print "Avg="sum"/"n"="sum/n/1024"MB"}'
Apache process size 2
wget https://raw.githubusercontent.com/pixelb/ps_mem/master/ps_mem.py
sudo python ps_mem.py
1. Convert PEM to PKCS12
openssl pkcs12 -export -out jal.tw.pfx -name tomcat -inkey jal.tw.key -in jal.tw.crt -CAfile jal.tw.CA.bundle -caname root
2. Import private key and certificate into keystore
# "changeit" is the password, you can modify it as your wish and make sure server.xml also too.
# keystoreFile="jal.tw.jks" keystorePass="changeit"
# deststorepass and destkeypass must be same.
# On Tomcat/Coyote don't chanege alias(tomcat), let tomcat can find it correctly.
keytool -importkeystore -deststorepass changeit -destkeypass changeit -destkeystore jal.tw.pkcs12.jks -srckeystore jal.tw.pfx -srcstoretype PKCS12 -srcstorepass changeit -alias tomcat -deststoretype PKCS12
@jal-tw
jal-tw / convert_nss_db_to_pem.sh
Last active February 12, 2020 07:00
Convert NSS Root CA DB file to PEM format
# This script is bundle in curl source code
# download scritp from https://github.com/curl/curl/tree/master/lib
wget https://raw.githubusercontent.com/curl/curl/master/lib/mk-ca-bundle.pl
chmod 700 mk-ca-bundle.pl
# Make sure system have perl
./mk-ca-bundle.pl
# You will get ca-bundle.crt that content all Root CA in pem format