Skip to content

Instantly share code, notes, and snippets.

@aachyee
aachyee / auto-ovpn.sh
Created October 1, 2021 13:57 — forked from lowstz/auto-ovpn.sh
Linux openvpn auto reconnect script
#!/bin/bash
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
### Thanks Xream's Work XD
# if you don't have several vpn servers to select, you can comment following line
# and use your openvpn config file name to replace "${host}.ovpn" in while loop.
read -p "Select the host: " host
@aachyee
aachyee / EBIあり
Created January 12, 2022 01:19 — forked from mmasaki/EBIあり
緊急地震速報の電文サンプル
37 03 00 110415233453 C11
110415233416
ND20110415233435 NCN005 JD////////////// JN///
251 N370 E1408 010 66 6+ RK66324 RT01/// RC13///
EBI 251 S6+6- ////// 11 300 S5+5- ////// 11 250 S5+5- ////// 11
310 S0404 ////// 11 311 S0404 ////// 11 252 S0404 ////// 11
301 S0404 ////// 11 221 S0404 ////// 01 340 S0404 ////// 01
341 S0404 ////// 01 321 S0404 233455 00 331 S0404 233457 10
350 S0404 233501 00 360 S0404 233508 00 243 S0403 ////// 01
330 S0403 233454 00 222 S0403 233455 00
@aachyee
aachyee / vpngate_api.bash
Last active February 12, 2024 22:50 — forked from Hayao0819/vpngate_api
VPN Gateのサーバリストを取得してBashの配列にするスクリプト
#!/usr/bin/env bash
# 設定
API="http://www.vpngate.net/api/iphone/"
msg_info(){ echo -e "${*}"; }
# APIで取得したリストを読み込み
#msg_info "Loading the list of server ..."
CSV="$(curl -sL "${API}" | tr -d '\r')"
# インストールのやり方はこちらのサイトを参考にしました。
# http://blog.csdn.net/shile/article/details/54602768
### まずはbashdbのインストール
# osのバージョンを確認
[vagrant@daily bashdb-code]$ cat /etc/redhat-release
CentOS release 6.7 (Final)
# アーキテクチャ(OSが32bit, 64bitどちらなのか)を確認
@aachyee
aachyee / parse-options.sh
Created November 10, 2024 19:51 — forked from cosimo/parse-options.sh
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
@aachyee
aachyee / getopts-ba.sh
Created November 10, 2024 19:54 — forked from pablordoricaw/getopts-ba.sh
Code example using getopts in bash with short options and a subcommand with it's own short options
#!/bin/bash
###
# This is a code example showing how to use getops to parse short options and a
# subcommand with short options of it's own. Based on Kevin Sookocheff's post:
# https://sookocheff.com/post/bash/parsing-bash-script-arguments-with-shopts/
#
# Please feel free to use it and modify it as you see fit. Any questions and/or
# recommendations are more than welcome.
###
@aachyee
aachyee / getopt-example.sh
Last active November 10, 2024 19:55 — forked from drmalex07/getopt-example.sh
A small example on Bash getopts. #bash #getopt #getopts
#!/bin/bash
#
# Example using getopt (vs builtin getopts) that can also handle long options.
# Another clean example can be found at:
# http://www.bahmanm.com/blogs/command-line-options-how-to-parse-in-bash-using-getopt
#
aflag=n
bflag=n
@aachyee
aachyee / Bash getopts template
Last active November 10, 2024 20:03 — forked from magnetikonline/README.md
Bash getopts template.
# Bash `getopts` template
- [Example](#example)
- [Reference](#reference)
```sh
#!/bin/bash -e
function usage {
cat <<EOF >&2
@aachyee
aachyee / script-with-options.sh
Created November 10, 2024 20:00 — forked from dgoguerra/script-with-options.sh
Manual alternative to getopt in bash scripts, supporting short and long options
#!/usr/bin/env bash
# File name
readonly PROGNAME=$(basename $0)
# File name, without the extension
readonly PROGBASENAME=${PROGNAME%.*}
# File directory
readonly PROGDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# Arguments
readonly ARGS="$@"
@aachyee
aachyee / study_getopt.sh
Created November 10, 2024 20:01 — forked from i97506051502/study_getopt.sh
いまいちよく分かっていない getopt に関するメモ.環境変数 GETOPT_COMPATIBLE がセットされている場合どんな動きになるのか? メリット・デメリットは? などなど.書きかけ
#!/bin/bash
# 下記,よくできた bash マニュアルだと思っていたら,JP1/Advanced Shell というもののマニュアルだった... bash のマニュアルを確認していないので以下はデタラメかもです.
#
# 参考
#
# getoptコマンド(コマンドラインのオプションを解析する) : JP1/Advanced Shell http://itdoc.hitachi.co.jp/manuals/3021/3021313330/JPAS0337.HTM
# 形式1