Compare commits
76 Commits
19f72612cd
...
main
Author | SHA1 | Date | |
---|---|---|---|
987ac44575 | |||
e8159fc8cb | |||
cc1463b166 | |||
14c72fe080 | |||
2922806e9c | |||
06e5111309 | |||
b04b9e9205 | |||
cad7792fa1 | |||
fd553b3442 | |||
9b849897e2 | |||
05f461f8c1 | |||
1cee89cd0a | |||
203138947b | |||
3d2e0e33af | |||
e11dc60438 | |||
7123fa1147 | |||
f1fd1aaff5 | |||
2dec392e50 | |||
6cb768a05e | |||
a0f8f49b27 | |||
09d63b6630 | |||
44ef429d5a | |||
de6d1d47c8 | |||
b335f61c72 | |||
c61686065e | |||
9a001021b1 | |||
6080fe48c1 | |||
36a18e870f | |||
40e14b5cc7 | |||
a96f533f8f | |||
b36c0b6939 | |||
7e68bbb891 | |||
21f481076c | |||
fc60587252 | |||
d1afa8e0ad | |||
09f73bb770 | |||
ed631e97c2 | |||
f5c9f65fe7 | |||
999b8d977d | |||
c6cb2cf281 | |||
d6784fa70c | |||
52dccb1787 | |||
dbc0c638fd | |||
1931445c13 | |||
816b07306f | |||
88a5898f8c | |||
6523b0eac0 | |||
cf91fbd224 | |||
c8be4e5d2c | |||
578e1ba496 | |||
2a78030816 | |||
459e3bc59b | |||
7b07df0ec0 | |||
d4f132eebd | |||
b5d13cdf5b | |||
9d07b32e46 | |||
d2fd9a6a25 | |||
5e821cf08c | |||
5eff1f0ac7 | |||
37e4634213 | |||
af558f33f9 | |||
d7fccd74b9 | |||
773e2552ac | |||
59cb3622f4 | |||
90aea333fd | |||
20813a992f | |||
9b97d42f31 | |||
42ec2ca2b7 | |||
1168fa1d36 | |||
62a7fa644a | |||
4958bed672 | |||
22da887f77 | |||
4c15418d6f | |||
9e7424efe2 | |||
eca21bb3d0 | |||
ddbb77c59e |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
alert/bark/option.json
|
28
alert/bark/ciphertxt.sh
Normal file
28
alert/bark/ciphertxt.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Documentation: https://bark.day.app/#/encryption
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# bark key
|
||||||
|
deviceKey='R5BU8VnMn3ufSFjMnwSmd6'
|
||||||
|
# push payload
|
||||||
|
# json='{"body": "test", "sound": "birdsong"}'
|
||||||
|
json=`cat /opt/scripts/alert/bark/option.json`
|
||||||
|
|
||||||
|
# 必须32位
|
||||||
|
key='sqCT9wE25eS2kMYu6BCGN4f9ymx2Fsmj'
|
||||||
|
# IV可以是随机生成的,但如果是随机的就需要放在 iv 参数里传递。
|
||||||
|
iv='QA475QXtg4YaGQzc'
|
||||||
|
|
||||||
|
# OpenSSL 要求输入的 Key 和 IV 需使用十六进制编码。
|
||||||
|
key=$(printf $key | xxd -ps -c 200)
|
||||||
|
iv=$(printf $iv | xxd -ps -c 200)
|
||||||
|
|
||||||
|
ciphertext=$(echo -n $json | openssl enc -aes-256-cbc -K $key -iv $iv | base64)
|
||||||
|
|
||||||
|
# 删除密文中的空格
|
||||||
|
ciphertext=`echo $ciphertext | tr -d ' '`
|
||||||
|
|
||||||
|
# 密文可能有特殊字符,所以记得 URL 编码一下。
|
||||||
|
curl --data-urlencode "ciphertext=$ciphertext" --data-urlencode "iv=QA475QXtg4YaGQzc" https://bark.rustle.cc/$deviceKey
|
70
alert/bark/msgsend.py
Normal file
70
alert/bark/msgsend.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
|
def usage():
|
||||||
|
pformat = "%-7s%-7s%-10s%-10s%-10s%-10s%-10s"
|
||||||
|
sformat = "%-23s%-18s%-16s%-14s%-14s%-12s%-12s"
|
||||||
|
print(pformat % ('must', 'must', 'optional', 'optional', 'optional', 'optional', 'optional'))
|
||||||
|
print(pformat % ('title', 'body', 'sound', 'icon', 'group', 'badge', 'isArchive'))
|
||||||
|
print(pformat % ('-', '-', '2.0-alarm', '-', 'default', '-', '1'))
|
||||||
|
print(pformat % ('-', '-', '1.4-bell', '-', 'docker', '-', '1'))
|
||||||
|
print(pformat % ('-', '-', '1.6-bloom', '-', 'frp', '-', '1'))
|
||||||
|
print("\nThe 'sound' parameter also accepts the following as its value:")
|
||||||
|
print(sformat % ("1.8-healthnotification", "2.6-typewriters", "2.9-newsflash", "1.5-mailsent", "1.5-tiptoes", "4.5-update", "2.9-spell"))
|
||||||
|
print(sformat % ("2.2-multiwayinvitation", "4.5-anticipate", "1.2-telegraph", "0.9-calypso", "1.5-newmail", "1.7-glass", "2.2-choo"))
|
||||||
|
print(sformat % ("1.4-paymentsuccess", "1.5-electronic", "0.7-birdsong", "1.9-descent", "1.3-ladder", "4.5-chime", "1.5-horn"))
|
||||||
|
print(sformat % ("4.7-sherwoodforest", "3.0-gotosleep", "4.2-suspense", "1.5-fanfare", "7.0-minuet", "0.6-shake", "1.9-noir"))
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
def getParams(
|
||||||
|
title='test',
|
||||||
|
body='hello...',
|
||||||
|
sound='',
|
||||||
|
icon='',
|
||||||
|
group='default',
|
||||||
|
badge='1',
|
||||||
|
isarchive=1,
|
||||||
|
):
|
||||||
|
|
||||||
|
params_dict = {'title': title, 'body': body, 'sound': sound, 'icon': icon, 'group': group, 'badge': '1', 'isarchive': '1'}
|
||||||
|
params_json = json.dumps(params_dict)
|
||||||
|
with open('/opt/scripts/alert/bark/option.json', 'w') as obj_option:
|
||||||
|
obj_option.write(params_json)
|
||||||
|
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/alert/bark/ciphertxt.sh')
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) < 5:
|
||||||
|
usage()
|
||||||
|
parser = argparse.ArgumentParser(description='Prepare arguements for bark')
|
||||||
|
parser.add_argument('--title', help='标题,必要参数', required=True)
|
||||||
|
parser.add_argument('--body', help='主题内容,必要参数', required=True)
|
||||||
|
parser.add_argument('--sound', help='提示音,非必要参数,有默认值', default='alarm')
|
||||||
|
parser.add_argument('--icon', help='图标,非必要参数,有默认值', default='0')
|
||||||
|
parser.add_argument('--group', help='群组,非必要参数,有默认值', default='default')
|
||||||
|
parser.add_argument('--badge', help='角标,非必要参数,有默认值', default='1')
|
||||||
|
parser.add_argument('--isarchive', help='是否自动归档,非必要参数,有默认值', default='1')
|
||||||
|
# if len(sys.argv) == 1:
|
||||||
|
# print('Need at least 2 parameters, and most can have 7 parameters, exiting...')
|
||||||
|
# usage()
|
||||||
|
args = parser.parse_args()
|
||||||
|
title = args.title
|
||||||
|
body = args.body
|
||||||
|
sound = args.sound
|
||||||
|
icon = 'https://www.rustle.cc/assets/img/logos/' + str(args.icon) + '.jpg'
|
||||||
|
group = args.group
|
||||||
|
badge = args.badge
|
||||||
|
isarchive = args.isarchive
|
||||||
|
getParams(title, body, sound, icon, group, badge, isarchive)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
> /tmp/docker_alarm.log
|
> /tmp/docker_alarm.log
|
||||||
docker ps -a --format "table {{.Names}}\t{{.Status}}" > /opt/logs/docker_status.log
|
docker ps -a --format "table {{.Names}}\t{{.Status}}" > /opt/logs/docker_status.log
|
||||||
while read line; do
|
while read line; do
|
||||||
echo $line | grep -q 'Exited'
|
echo $line | grep -v 'v2raya' | grep -q 'Exited'
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
name=`echo $line | awk '{print $1}'`
|
name=`echo $line | awk '{print $1}'`
|
||||||
echo "Docker Alarm - $name: Container $name has been off line, please check ASAP." >> /tmp/docker_alarm.log
|
echo "Docker Alarm - $name: Container $name has been off line, please check ASAP." >> /tmp/docker_alarm.log
|
||||||
@ -12,6 +12,6 @@ done < /opt/logs/docker_status.log
|
|||||||
|
|
||||||
if [[ -s /tmp/docker_alarm.log ]]; then
|
if [[ -s /tmp/docker_alarm.log ]]; then
|
||||||
alarm=`cat /tmp/docker_alarm.log`
|
alarm=`cat /tmp/docker_alarm.log`
|
||||||
python3 /opt/scripts/alert/sendmail.py "Docker Alarms" "$alarm"
|
python3 /opt/git/scripts/alert/sendmail.py "Docker Alarms" "$alarm"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
# 脚本接收两个及以上的参数
|
||||||
|
# 第一个参数:邮件主题
|
||||||
|
# 第二个参数:邮件文本内容
|
||||||
|
# 其他参数:邮件附件
|
||||||
|
|
||||||
|
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.image import MIMEImage
|
from email.mime.image import MIMEImage
|
||||||
@ -9,7 +14,7 @@ import sys
|
|||||||
# Mail basic information
|
# Mail basic information
|
||||||
mail_host = "smtp.163.com"
|
mail_host = "smtp.163.com"
|
||||||
from_mail = 'xgdfmf@163.com'
|
from_mail = 'xgdfmf@163.com'
|
||||||
from_mail_password = 'SATTGHVFIJEGZMFP'
|
from_mail_password = 'PSIKFDYLMGBPSEPJ'
|
||||||
receiver_to = ['mffan0922@163.com']
|
receiver_to = ['mffan0922@163.com']
|
||||||
receiver_cc = []
|
receiver_cc = []
|
||||||
to_mail = receiver_to + receiver_cc
|
to_mail = receiver_to + receiver_cc
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# 设置图片数量和输出文件名
|
# 设置图片数量和输出文件名
|
||||||
IMAGE_NUM_ALL=`ls /opt/apps/localcr/A_dashboard/local/icons | wc -l`
|
IMAGE_NUM_ALL=`ls /opt/apps/localcr/A_dashboard/local/icons/*.jpg | wc -l`
|
||||||
IMAGE_NUM_NEEDED=`cat /opt/apps/localcr/A_dashboard/local/config/services.yaml | grep -E '[0-9]{1,3}.jpg' | wc -l`
|
IMAGE_NUM_NEEDED=`cat /opt/apps/localcr/A_dashboard/local/config/services.yaml | grep -E '[0-9]{1,3}.jpg' | wc -l`
|
||||||
if [[ $IMAGE_NUM_NEEDED -gt $IMAGE_NUM_ALL ]]; then
|
if [[ $IMAGE_NUM_NEEDED -gt $IMAGE_NUM_ALL ]]; then
|
||||||
alarm='Dashboard:\nThere is NOT enough logos to use, please check ASAP.'
|
alarm='Dashboard:\nThere is NOT enough logos to use, please check ASAP.'
|
@ -16,7 +16,7 @@ for num4 in `seq 200 254`; do
|
|||||||
[[ $? -ne 0 ]] && break
|
[[ $? -ne 0 ]] && break
|
||||||
done
|
done
|
||||||
|
|
||||||
ip link add main2wrt link enp1s0 type macvlan mode bridge
|
ip link add main2wrt link enp1s0 type macvlan mode bridge
|
||||||
ip addr add $IP dev main2wrt
|
ip addr add $IP dev main2wrt
|
||||||
ip link set main2wrt up
|
ip link set main2wrt up
|
||||||
ip route add 192.168.10.123 dev main2wrt
|
ip route add 192.168.10.123 dev main2wrt
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
# 设置图片数量和输出文件名
|
# 设置图片数量和输出文件名
|
||||||
IMAGE_NUM_ALL=`ls /opt/websites/nav/assets/images/logos | wc -l`
|
IMAGE_NUM_ALL=`ls /opt/websites/nav/assets/images/logos | wc -l`
|
||||||
|
# there are 221 logos in total, and index are from 0, so the max index is 220
|
||||||
|
# whhereas there has an avatar.jpg file in this dir, so need to subtract one
|
||||||
|
let IMAGE_NUM_ALL=IMAGE_NUM_ALL-1
|
||||||
IMAGE_NUM_NEEDED=`cat /opt/websites/nav/index.html | grep -E '[0-9]{1,3}.jpg' | wc -l`
|
IMAGE_NUM_NEEDED=`cat /opt/websites/nav/index.html | grep -E '[0-9]{1,3}.jpg' | wc -l`
|
||||||
if [[ $IMAGE_NUM_NEEDED -gt $IMAGE_NUM_ALL ]]; then
|
if [[ $IMAGE_NUM_NEEDED -gt $IMAGE_NUM_ALL ]]; then
|
||||||
alarm='Navigation:\nThere is NOT enough logos to use, please check ASAP.'
|
alarm='Navigation:\nThere is NOT enough logos to use, please check ASAP.'
|
9
old/nc_rsync.sh
Normal file
9
old/nc_rsync.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
src_dir='/opt/apps/syncthing/data/common'
|
||||||
|
dst_dir='/opt/apps/localcr/K_nextcloud/local/nextcloud/data/nextcloud/files/'
|
||||||
|
rsync --delete-after -avz $src_dir $dst_dir
|
||||||
|
|
||||||
|
docker exec -u www-data nextcloud php /var/www/html/occ files:scan --all
|
||||||
|
|
||||||
|
|
@ -136,7 +136,8 @@ apt install lrzsz unzip vim gcc g++ make automake curl wget gnupg2 aria2 jq apt-
|
|||||||
python3-pip python3-dev golang net-tools ethtool tcpflow lshw rsync parallel rclone pigz pbzip2 \
|
python3-pip python3-dev golang net-tools ethtool tcpflow lshw rsync parallel rclone pigz pbzip2 \
|
||||||
pixz neofetch mlocate ncdu dstat fzf tldr nscd inotify-hookable inotify-tools vsftpd mtr bridge-utils \
|
pixz neofetch mlocate ncdu dstat fzf tldr nscd inotify-hookable inotify-tools vsftpd mtr bridge-utils \
|
||||||
socat dos2unix samba libldap2-dev libsasl2-dev smartmontools parted libpcre3 libpcre3-dev openssl \
|
socat dos2unix samba libldap2-dev libsasl2-dev smartmontools parted libpcre3 libpcre3-dev openssl \
|
||||||
libssl-dev zlib1g-dev libgeoip-dev libncurses-dev libpython3-dev fwupd virtualenv wpasupplicant -y
|
libssl-dev zlib1g-dev libgeoip-dev libncurses-dev libpython3-dev fwupd virtualenv wpasupplicant \
|
||||||
|
jpegoptim optipng -y
|
||||||
|
|
||||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
|
||||||
# fwupdmgr get-updates && fwupdmgr update
|
# fwupdmgr get-updates && fwupdmgr update
|
178
old/utool.py
Executable file
178
old/utool.py
Executable file
@ -0,0 +1,178 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
# coding: utf-8
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
c_title = '\033[1;4;31;42m' # title color
|
||||||
|
c_br = '\033[1;31m' # bold red
|
||||||
|
c_bg = '\033[1;32m' # bold green
|
||||||
|
c_by = '\033[1;33m' # bold yellow
|
||||||
|
c_bb = '\033[1;34m' # bold blue
|
||||||
|
c_bp = '\033[1;35m' # bold purple
|
||||||
|
c_bc = '\033[1;36m' # bold cyan
|
||||||
|
c_bir= '\033[1;3;31m' # * bold italic red
|
||||||
|
c_bib = '\033[1;3;34m' # * bold italic cyan
|
||||||
|
c_bic = '\033[1;3;36m' # bold italic cyan
|
||||||
|
c_e = '\033[0m' # reset
|
||||||
|
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
opt_1 = sys.argv[1]
|
||||||
|
opt_rest = None
|
||||||
|
elif len(sys.argv) > 2:
|
||||||
|
opt_1 = sys.argv[1]
|
||||||
|
opt_rest = sys.argv[2:]
|
||||||
|
else:
|
||||||
|
opt_1 = None
|
||||||
|
opt_rest = None
|
||||||
|
|
||||||
|
opt_index = ['-do_not_use_this', '-a', '-b', '-c', '-d', '-e', '-f', '-g', '-h', '-i', '-j', '-k', '-l', '-m',
|
||||||
|
'-n', '-o', '-p', '-q', '-r', '-s', '-t', '-u', '-v', '-w', '-x', '-y', '-z']
|
||||||
|
|
||||||
|
if opt_1 not in opt_index:
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/usage.sh')
|
||||||
|
exit(100)
|
||||||
|
|
||||||
|
if opt_1 == '-a':
|
||||||
|
if opt_rest != None:
|
||||||
|
print(f"This option({opt_1}) will print all ports of now using for local, and accept NO parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh port')
|
||||||
|
|
||||||
|
elif opt_1 == '-b':
|
||||||
|
if opt_rest != None:
|
||||||
|
print(f"This option({opt_1}) will generate a two-factor auth-key for github login, and accept NO parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
os.system("/usr/bin/oathtool -b --totp 'G3NHHFO2L2LZ5W2R'")
|
||||||
|
|
||||||
|
elif opt_1 == '-c':
|
||||||
|
if opt_rest != None:
|
||||||
|
print(f"This option({opt_1}) will print all intranet IP using in docker, and accept NO parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh ip')
|
||||||
|
|
||||||
|
elif opt_1 == '-d':
|
||||||
|
if opt_rest != None:
|
||||||
|
print(f"This option({opt_1}) will return the current IP of local machine, and accept NO parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
os.system("/usr/bin/python3 /opt/scripts/roll_api/get_self_ip.py")
|
||||||
|
|
||||||
|
elif opt_1 == '-e':
|
||||||
|
if opt_rest == None:
|
||||||
|
print(f"This option({opt_1}) will return the IP info, and accept at least one IP parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
for opt_2 in opt_rest:
|
||||||
|
os.environ['opt_2'] = opt_2
|
||||||
|
os.system('/usr/bin/python3 /opt/scripts/roll_api/get_ip.py $opt_2')
|
||||||
|
|
||||||
|
elif opt_1 == '-f':
|
||||||
|
if len(sys.argv) < 3:
|
||||||
|
print(f"{c_br}需要至少一个字符串作为输入,退出...{c_e}\n")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
param=''
|
||||||
|
for item in sys.argv[2:]:
|
||||||
|
param += item
|
||||||
|
|
||||||
|
os.environ['param'] = param
|
||||||
|
print(f"{c_by}Warning: 输入字符串中间的任何空白符将会被删除,要保留的话,需手动将字符串用单引号括起来{c_e}")
|
||||||
|
print(f"本次计算MD5值的字符串为 - {param}\n本次计算得到的MD5的值为 - ", end='')
|
||||||
|
# print(f"本次计算得到的MD5的值为 - ", end='')
|
||||||
|
os.system('echo -n $param | md5sum | cut -d " " -f 1')
|
||||||
|
|
||||||
|
elif opt_1 == '-g':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-h':
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/usage.sh')
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-i':
|
||||||
|
if opt_rest == None:
|
||||||
|
print(f"This option({opt_1}) will return the domain registration info, and accept at least one domain parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
for opt_2 in opt_rest:
|
||||||
|
os.environ['opt_2'] = opt_2
|
||||||
|
os.system('/usr/bin/python3 /opt/scripts/roll_api/domain_reg_check.py $opt_2')
|
||||||
|
|
||||||
|
elif opt_1 == '-j':
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
print(f"{c_br}-j选项:将十进制或者十六进制数字作为入参,转换成标准时间格式,只接收第一个参数,其他参数将被丢弃,有歧义时,使用'0x'或者'0X'来区分十进制和十六进制,退出...{c_e}\n")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
os.environ['param'] = sys.argv[2]
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/number2d.sh $param')
|
||||||
|
|
||||||
|
elif opt_1 == '-k':
|
||||||
|
if len(sys.argv) < 3:
|
||||||
|
print(f"{c_br}-k选项:将输入的时间转换成十进制和十六进制,需要一个字符串格式的时间作为输入,退出...{c_e}\n")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
param=''
|
||||||
|
for item in sys.argv[2:]:
|
||||||
|
param += item + ' '
|
||||||
|
|
||||||
|
os.environ['param'] = param
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/date2n.sh $param')
|
||||||
|
|
||||||
|
elif opt_1 == '-l':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-m':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-n':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-o':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-p':
|
||||||
|
if opt_rest == None:
|
||||||
|
opt_rest = ['',]
|
||||||
|
|
||||||
|
opt_2 = opt_rest[0]
|
||||||
|
os.environ['opt_2'] = opt_2
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/genpw.sh $opt_2')
|
||||||
|
|
||||||
|
elif opt_1 == '-q':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-r':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-s':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-t':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-u':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-v':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-w':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-x':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-y':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-z':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
else:
|
||||||
|
print("This line SHOULD NOT be executed, please check carefully.")
|
||||||
|
exit(255)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@ cp -rf /var/spool/cron/crontabs/ /opt/configs/
|
|||||||
cp -rf /usr/local/nginx/conf/nginx.conf /opt/configs/nginx/nginx.conf
|
cp -rf /usr/local/nginx/conf/nginx.conf /opt/configs/nginx/nginx.conf
|
||||||
cp -rf /usr/local/nginx/conf/domain_confs/ /opt/configs/nginx/
|
cp -rf /usr/local/nginx/conf/domain_confs/ /opt/configs/nginx/
|
||||||
cp -rf /etc/docker/daemon.json /opt/configs/conf/
|
cp -rf /etc/docker/daemon.json /opt/configs/conf/
|
||||||
cp -rf /etc/sysctl.conf /opt/configs/conf/
|
cp -rf /etc/netdata/ /opt/configs/
|
||||||
cp -rf /etc/pip.conf /opt/configs/conf/
|
cp -rf /etc/pip.conf /opt/configs/conf/
|
||||||
cp -rf /etc/apt/sources.list /opt/configs/conf/
|
cp -rf /etc/apt/sources.list /opt/configs/conf/
|
||||||
cp -rf /etc/ssh/sshd_config /opt/configs/conf/
|
cp -rf /etc/ssh/sshd_config /opt/configs/conf/
|
||||||
@ -16,16 +16,17 @@ cp -rf /root/.bashrc /opt/configs/conf/bashrc
|
|||||||
cp -rf /root/.vim_runtime/my_configs.vim /opt/configs/conf/
|
cp -rf /root/.vim_runtime/my_configs.vim /opt/configs/conf/
|
||||||
cp -rf /root/.ssh/config /opt/configs/conf/
|
cp -rf /root/.ssh/config /opt/configs/conf/
|
||||||
cp -rf /etc/samba/smb.conf /opt/configs/conf/
|
cp -rf /etc/samba/smb.conf /opt/configs/conf/
|
||||||
|
cp -rf /etc/network/interfaces /opt/configs/conf/
|
||||||
cp -rf /root/.acme.sh/*ecc /opt/configs/acme/
|
cp -rf /root/.acme.sh/*ecc /opt/configs/acme/
|
||||||
cp -rf /opt/scripts/update/restore.sh /opt/apps/syncthing/data/common/F-Backup/Linux/
|
cp -rf /root/.acme.sh/rustle.cc_ecc/rustle.cc.{key,cer} /opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/
|
||||||
scp -r /opt/configs/certs/ arm1:/opt/ > /dev/null &
|
cp -rf /opt/apps/syncthing/data/common/A_Program/FRP/* /opt/apps/frp/frpc-xtcp-visitor/
|
||||||
scp -r /opt/configs/certs/ arm2:/opt/ > /dev/null &
|
cp -rf /etc/systemd/network /opt/configs/conf/
|
||||||
scp -r /opt/configs/certs/ amd:/opt/ > /dev/null &
|
cp -rf /etc/modprobe.d/pcspkr-blacklist.conf /opt/configs/conf/
|
||||||
wait
|
cp -rf /lib/firmware/intel/ ibt-0040-1050* /opt/configs/conf/intel/
|
||||||
|
|
||||||
cd /opt && t=`date +%Y%m%dT%H%M%S`
|
cd /opt && t=`date +%Y%m%dT%H%M%S`
|
||||||
rsync --delete-after -avz apps configs logs scripts websites wd/72-Backups/VPS/ > /opt/logs/rsync/rsync_${t}.log
|
# rsync --delete-after -avz --exclude=apps/localcr/B_koel/local/music apps configs logs scripts websites wd/72-Backups/VPS/ > /opt/logs/rsync/rsync_${t}.log
|
||||||
rsync --delete-after -avz /opt/apps/syncthing/data/* wd/72-Backups/Syncthing/ > /opt/logs/rsync/rsync_${t}.log
|
rsync --delete-after -avz --exclude=apps/syncthing apps configs logs git websites wd/72-Backups/VPS/ > /opt/logs/rsync/rsync_${t}.log
|
||||||
cd /opt/logs/rsync/
|
cd /opt/logs/rsync/
|
||||||
let count=`ls | wc -l`
|
let count=`ls | wc -l`
|
||||||
if [[ $count -gt 10 ]]; then
|
if [[ $count -gt 10 ]]; then
|
||||||
@ -41,8 +42,18 @@ fi
|
|||||||
|
|
||||||
# on 1st of every month, do a compress
|
# on 1st of every month, do a compress
|
||||||
if [[ `date +%d` == '01' ]]; then
|
if [[ `date +%d` == '01' ]]; then
|
||||||
t=`date +%Y%m%d%H%M%S`
|
t=`date +%Y%m%d%H%M%S` && cd /opt/wd/72-Backups/
|
||||||
tar -I pixz -cf /opt/wd/72-Backups/vps-${t}.tar.gz /opt/wd/72-Backups/VPS > /dev/null 2>&1
|
|
||||||
|
tar -I pigz -cf vps-${t}.tar.gz \
|
||||||
|
--exclude=VPS/apps/localcr/I_cloudreve/local/cloudreve/uploads \
|
||||||
|
--exclude=VPS/apps/syncthing/data \
|
||||||
|
VPS/ > /dev/null 2>&1
|
||||||
|
# tar -I unpigz -xf vps-20231101162641.tar.gz
|
||||||
|
|
||||||
|
scp -r /opt/configs/certs/ arm1:/opt/ > /dev/null 2>&1 &
|
||||||
|
scp -r /opt/configs/certs/ arm2:/opt/ > /dev/null 2>&1 &
|
||||||
|
scp -r /opt/configs/certs/ amd:/opt/ > /dev/null 2>&1 &
|
||||||
|
wait
|
||||||
fi
|
fi
|
||||||
set +x
|
set +x
|
||||||
echo End Time: `date`
|
echo End Time: `date`
|
||||||
|
41
update/chatbot_suqian.sh
Normal file
41
update/chatbot_suqian.sh
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function sendMsg() {
|
||||||
|
|
||||||
|
# 个人测试
|
||||||
|
# curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=ddea3f5f-fbfc-4c21-994a-71e9fc50e4ef' \
|
||||||
|
# -H 'Content-Type: application/json' \
|
||||||
|
# -d '
|
||||||
|
# {
|
||||||
|
# "msgtype": "markdown",
|
||||||
|
# "markdown": {
|
||||||
|
# "content": "**'"$alarmTitle"'**\n
|
||||||
|
# > <font color=\"warning\">'"$alarmInfo"'</font>"
|
||||||
|
# }
|
||||||
|
# }' > /dev/null 2>&1
|
||||||
|
|
||||||
|
# 群hook
|
||||||
|
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=924c62e3-1bb8-4d17-84b1-e543eb27ba1e' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '
|
||||||
|
{
|
||||||
|
"msgtype": "text",
|
||||||
|
"text": {
|
||||||
|
"content": "'"$alarmTitle"':\n'"$alarmInfo"'",
|
||||||
|
"mentioned_list":["@all"]
|
||||||
|
}
|
||||||
|
}' > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
isFriday=$(date +%A)
|
||||||
|
time_opt=$1
|
||||||
|
alarmTitle="每日/周工作记录提醒"
|
||||||
|
|
||||||
|
if [[ $isFriday == 'Friday' ]]; then
|
||||||
|
alarmInfo='周五了[庆祝][庆祝][庆祝],请各位及时填写周报,感谢大家本周的辛苦付出,别忘了还有今日工作内容安排记录,以及问题进展跟新~~~'
|
||||||
|
else
|
||||||
|
alarmInfo='大家记得写每日工作内容安排,上午10点之前写完,工作期间可以补充内容,下班前17点左右完善一下,争取日事日毕~[拳头][拳头][拳头]\n有事没事找找客户经理,发个信息啥的也可~~\n客户走访记录,问题解决以及客户经理需求记录,也要记得跟进更新闭环~~~'
|
||||||
|
fi
|
||||||
|
|
||||||
|
sendMsg $alarmTitle $alarmInfo
|
@ -2,17 +2,18 @@
|
|||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
/usr/bin/qbittorrent-nox --webui-port=10005 -d
|
/usr/bin/qbittorrent-nox --webui-port=10005 -d
|
||||||
/usr/bin/bash /opt/scripts/update/calibre.sh
|
|
||||||
mv /opt/wd/99-Temp/shutdown /opt/wd/99-Temp/shutdown.old
|
mv /opt/wd/99-Temp/shutdown /opt/wd/99-Temp/shutdown.old
|
||||||
#==============================================================================
|
mv /opt/wd/99-Temp/reboot /opt/wd/99-Temp/reboot.old
|
||||||
ip link set enp1s0 promisc on
|
|
||||||
ip link set enp2s0 promisc on
|
|
||||||
ip link set wlx90de80ca01ec promisc on
|
|
||||||
#==============================================================================
|
|
||||||
sleep 20
|
sleep 20
|
||||||
/usr/bin/bash /opt/scripts/update/macvlan.sh
|
ifconfig > /opt/wd/99-Temp/ifconfig.txt
|
||||||
|
#==============================================================================
|
||||||
|
# ip link set enp1s0 promisc on
|
||||||
|
# ip link set enp2s0 promisc on
|
||||||
|
# ip link set wlx90de80ca01ec promisc on
|
||||||
|
#==============================================================================
|
||||||
|
# sleep 20
|
||||||
|
# /usr/bin/bash /opt/git/scripts/update/macvlan.sh
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
/usr/bin/bash /opt/scripts/update/jekyll_update.sh
|
|
||||||
# /usr/bin/mount -t ext4 -w UUID="b7c2c4b8-bfde-479b-80bb-655432a433b8" /opt/wd
|
# /usr/bin/mount -t ext4 -w UUID="b7c2c4b8-bfde-479b-80bb-655432a433b8" /opt/wd
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# get latest hosts for accelerate github visiting
|
# get latest hosts for accelerate github visiting
|
||||||
curl https://raw.hellogithub.com/hosts >> /opt/logs/hosts
|
# curl https://raw.hellogithub.com/hosts >> /opt/logs/hosts
|
||||||
|
|
||||||
# renew images.json file for background picture of homepage
|
# renew images.json file for background picture of homepage
|
||||||
cd /opt/websites/homepage/
|
cd /opt/websites/homepage/
|
||||||
node assets/js/bing.js > /dev/null 2>&1
|
node assets/js/bing.js > /dev/null 2>&1
|
||||||
|
|
||||||
if [[ `date +%d` == '01' ]]; then
|
if [[ `date +%d` == '01' ]]; then
|
||||||
# random logo for navigation
|
|
||||||
bash /opt/scripts/update/nav_rand_logo.sh
|
|
||||||
|
|
||||||
# random logo for dash
|
# random logo for dash
|
||||||
bash /opt/scripts/update/dash_rand_logo.sh
|
# bash /opt/git/scripts/update/dash_rand_logo.sh
|
||||||
|
cp /root/.acme/rustle.cc_ecc/fullchain.cer '/opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/'
|
||||||
|
cp /root/.acme/rustle.cc_ecc/rustle.cc.key '/opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# logo renew
|
# logo renew
|
||||||
let numOfAvatar=`ls /opt/websites/nav/assets/images/logos/ | wc -l`
|
let numOfAvatar=`ls /opt/websites/homepage/assets/img/logos | wc -l`
|
||||||
let randNumber=$RANDOM%$numOfAvatar
|
let randNumber=$RANDOM%$numOfAvatar
|
||||||
cp /opt/websites/nav/assets/images/logos/${randNumber}.jpg /opt/websites/nav/assets/images/logos/avatar.jpg
|
cp /opt/websites/homepage/assets/img/logos/${randNumber}.jpg /opt/websites/homepage/assets/img/logo.jpg
|
||||||
cp /opt/websites/nav/assets/images/logos/${randNumber}.jpg /opt/websites/homepage/assets/img/logo.jpg
|
|
||||||
cp /opt/websites/nav/assets/images/logos/${randNumber}.jpg /opt/apps/blog/img/avatar.jpg
|
|
||||||
|
|
||||||
|
# docker exec -u www-data nextcloud php /var/www/html/occ files:scan --all
|
||||||
|
16
update/restart_frpc.sh
Normal file
16
update/restart_frpc.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rss=$(ps aux | grep frpc.toml | grep -v grep | awk '{print $6}')
|
||||||
|
if [[ $rss == '' ]]; then
|
||||||
|
python3 /opt/git/scripts/alert/bark/msgsend.py --title "FRPC Warning" --body "Seems like FRPC Service has been down, need to check ASAP." --group 'frp' --icon 8
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
|
|
||||||
|
rss=$((rss/1024))
|
||||||
|
|
||||||
|
if [[ $rss -gt 500 ]]; then
|
||||||
|
systemctl restart frpc.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
16
update/restart_frps.sh
Normal file
16
update/restart_frps.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rss=$(ps aux | grep frps.toml | grep -v grep | awk '{print $6}')
|
||||||
|
if [[ $rss == '' ]]; then
|
||||||
|
ssh -o ConnectTimeout=60 beelink 'python3 /opt/scripts/alert/bark/msgsend.py --title "FRPS Warning" --body "Seems like FRPS Service has been down, need to check ASAP." --group "frp" --icon 8'
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
|
|
||||||
|
rss=$((rss/1024))
|
||||||
|
|
||||||
|
if [[ $rss -gt 500 ]]; then
|
||||||
|
systemctl restart frps.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
if [[ -f "/opt/wd/99-Temp/shutdown" ]]; then
|
if [[ -f "/opt/wd/99-Temp/shutdown" ]]; then
|
||||||
poweroff
|
poweroff
|
||||||
|
elif [[ -f "/opt/wd/99-Temp/reboot" ]]; then
|
||||||
|
reboot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -25,6 +25,7 @@ elif [[ $number =~ ^[0-9a-fA-F]{1,9}$ ]]; then
|
|||||||
hex=`printf "%d" '0x'$number`
|
hex=`printf "%d" '0x'$number`
|
||||||
date -d@$hex +'%Y-%m-%d %H:%M:%S'
|
date -d@$hex +'%Y-%m-%d %H:%M:%S'
|
||||||
else
|
else
|
||||||
|
echo -e "${c_bb}-j选项:将十进制或者十六进制数字作为入参,转换成标准时间格式,只接收第一个参数,其他参数将被丢弃,有歧义时,使用'0x'或者'0X'来区分十进制和十六进制,退出...${c_e}\n"
|
||||||
echo -e "${c_br}请输入正确的十进制--11位以内,或者十六进制数字--9位以内:${c_e}"
|
echo -e "${c_br}请输入正确的十进制--11位以内,或者十六进制数字--9位以内:${c_e}"
|
||||||
echo -e " 十进制的时间戳 - 1678523385"
|
echo -e " 十进制的时间戳 - 1678523385"
|
||||||
echo -e " 十六进制时间戳 - 0x640c3bf9/0X640C3BF9/0x640C3bf9/640c3bf9"
|
echo -e " 十六进制时间戳 - 0x640c3bf9/0X640C3BF9/0x640C3bf9/640c3bf9"
|
||||||
|
18
utool/pid_in_docker.sh
Normal file
18
utool/pid_in_docker.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
psid=$1
|
||||||
|
|
||||||
|
ids=$(docker inspect -f "{{.Id}}" $(docker ps -q))
|
||||||
|
|
||||||
|
for did in $ids; do
|
||||||
|
docker top $did | awk '{print $2, $3}' | grep -wq $psid
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo "Docker ID : $did"
|
||||||
|
name=$(docker inspect -f '{{.Name}}' $did | tr -d "/")
|
||||||
|
echo "Docker Name: $name"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Not a docker (sub)process..."
|
||||||
|
|
17
utool/ps_top_20.sh
Normal file
17
utool/ps_top_20.sh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ps -ely | sort -nrk 8 | head -n 20 | awk 'BEGIN{print "UID", "PID", "PPID", "RSS", "CMD"} {print $2, $3, $4, $8/1024"M", $NF}' | column -t
|
||||||
|
fmt="%-9s%-9s%-6s%-6s\033[1;32m%-8s\033[0m%-10s\n"
|
||||||
|
awk -v fmt=$fmt 'BEGIN{printf fmt, "PID","PPID","%CPU","%MEM","RSS","COMM"}' > /tmp/mem.top
|
||||||
|
ps -eo pid,ppid,pcpu,pmem,rss,comm | grep -Ev "grep|ps" | sort -nrk 5 | head -n 20 | awk -v fmt=$fmt '{printf fmt, $1,$2,$3,$4,int($5/1024)"M",$6}' >> /tmp/mem.top
|
||||||
|
|
||||||
|
> /tmp/deli.top
|
||||||
|
for i in `seq 21`; do
|
||||||
|
echo '|' >> /tmp/deli.top
|
||||||
|
done
|
||||||
|
|
||||||
|
fmt="%-9s%-9s\033[1;34m%-6s\033[0m%-6s%-8s%-10s\n"
|
||||||
|
awk -v fmt=$fmt 'BEGIN{printf fmt, "PID","PPID","%CPU","%MEM","RSS","COMM"}' > /tmp/cpu.top
|
||||||
|
ps -eo pid,ppid,pcpu,pmem,rss,comm | sort -nrk 3 | grep -Ev "grep|ps|utool" | head -n 20 | awk -v fmt=$fmt '{printf fmt, $1,$2,$3,$4,int($5/1024)"M",$6}' >> /tmp/cpu.top
|
||||||
|
|
||||||
|
paste /tmp/mem.top /tmp/deli.top /tmp/cpu.top | column -t
|
||||||
|
rm -rf /tmp/{mem.top,cpu.top,deli.top}
|
319
utool/utool.py
319
utool/utool.py
@ -4,175 +4,194 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
c_title = '\033[1;4;31;42m' # title color
|
def utool(option):
|
||||||
c_br = '\033[1;31m' # bold red
|
|
||||||
c_bg = '\033[1;32m' # bold green
|
|
||||||
c_by = '\033[1;33m' # bold yellow
|
|
||||||
c_bb = '\033[1;34m' # bold blue
|
|
||||||
c_bp = '\033[1;35m' # bold purple
|
|
||||||
c_bc = '\033[1;36m' # bold cyan
|
|
||||||
c_bir= '\033[1;3;31m' # * bold italic red
|
|
||||||
c_bib = '\033[1;3;34m' # * bold italic cyan
|
|
||||||
c_bic = '\033[1;3;36m' # bold italic cyan
|
|
||||||
c_e = '\033[0m' # reset
|
|
||||||
|
|
||||||
if len(sys.argv) == 2:
|
def print_usage():
|
||||||
opt_1 = sys.argv[1]
|
intro = """utool -- A self-defined command line interface, which is used to facilitate operating the system, supports the following options. In the description part, where there is a leading asterisk signifies that this option must take an argument, and for more information of this situation, simply run `utool -h` for details."""
|
||||||
opt_rest = None
|
print(f"{c_intro}{intro}{c_e}")
|
||||||
elif len(sys.argv) > 2:
|
print("_" * 121)
|
||||||
opt_1 = sys.argv[1]
|
print(f"{c_title}|Option| Description{' ' * 40}|Option| Description{' ' * 40}|{c_e}")
|
||||||
opt_rest = sys.argv[2:]
|
count = 0
|
||||||
else:
|
for opt, desc in dict_func.items():
|
||||||
opt_1 = None
|
description = "" if desc[0] == "Reserved" else desc[0]
|
||||||
opt_rest = None
|
if count % 2 == 0:
|
||||||
|
print(f"{c_text}|{opt:^6}|{description:<52}{c_e}", end="")
|
||||||
|
else:
|
||||||
|
print(f"{c_text}|{opt:^6}|{description:<52}|{c_e}")
|
||||||
|
count += 1
|
||||||
|
exit(100)
|
||||||
|
|
||||||
opt_index = ['-do_not_use_this', '-a', '-b', '-c', '-d', '-e', '-f', '-g', '-h', '-i', '-j', '-k', '-l', '-m',
|
# -a
|
||||||
'-n', '-o', '-p', '-q', '-r', '-s', '-t', '-u', '-v', '-w', '-x', '-y', '-z']
|
def list_local_using_port():
|
||||||
|
exit_on_wrong_number()
|
||||||
|
os.system('/usr/bin/bash /opt/git/scripts/utool/ipports.sh port')
|
||||||
|
|
||||||
if opt_1 not in opt_index:
|
# -b
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/usage.sh')
|
def github_two_factor():
|
||||||
exit(100)
|
exit_on_wrong_number()
|
||||||
|
os.system("/usr/bin/oathtool -b --totp 'G3NHHFO2L2LZ5W2R'")
|
||||||
|
|
||||||
if opt_1 == '-a':
|
# -c
|
||||||
if opt_rest != None:
|
def get_external_ip():
|
||||||
print(f"This option({opt_1}) will print all ports of now using for local, and accept NO parameter.")
|
exit_on_wrong_number()
|
||||||
exit(opt_index.index(opt_1))
|
os.system("/usr/bin/python3 /opt/git/scripts/roll_api/get_self_ip.py")
|
||||||
|
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh port')
|
# -d
|
||||||
|
def get_ip_location():
|
||||||
|
exit_on_wrong_number(2)
|
||||||
|
import re
|
||||||
|
checked_ip = sys.argv[2]
|
||||||
|
ipv4 = re.match(r"^((([01]?\d\d?)|(2[0-4]\d)|(25[0-5]))\.){3}(([01]?\d\d?)|(2[0-4]\d)|(25[0-5]))$", checked_ip)
|
||||||
|
if ipv4:
|
||||||
|
os.environ['checked_ip'] = checked_ip
|
||||||
|
os.system('/usr/bin/python3 /opt/git/scripts/roll_api/get_ip.py $checked_ip')
|
||||||
|
else:
|
||||||
|
print(f"{c_br}Plz enter correct IP...{c_e}")
|
||||||
|
exit(ord(option.strip('-')))
|
||||||
|
|
||||||
elif opt_1 == '-b':
|
# -e
|
||||||
if opt_rest != None:
|
def gen_md5():
|
||||||
print(f"This option({opt_1}) will generate a two-factor auth-key for github login, and accept NO parameter.")
|
if len(sys.argv) < 3:
|
||||||
exit(opt_index.index(opt_1))
|
print(f"{c_br}需要至少一个字符串作为输入,退出...{c_e}\n")
|
||||||
|
exit(ord(option.strip('-')))
|
||||||
|
|
||||||
os.system("/usr/bin/oathtool -b --totp 'G3NHHFO2L2LZ5W2R'")
|
param=''
|
||||||
|
for item in sys.argv[2:]:
|
||||||
|
param += item
|
||||||
|
|
||||||
elif opt_1 == '-c':
|
os.environ['param'] = param
|
||||||
if opt_rest != None:
|
print(f"{c_by}Warning: 输入字符串中间的任何空白符将会被删除,要保留的话,需手动将字符串用单引号括起来{c_e}")
|
||||||
print(f"This option({opt_1}) will print all intranet IP using in docker, and accept NO parameter.")
|
print(f"本次计算MD5值的字符串为 - {param}\n本次计算得到的MD5的值为 - ", end='')
|
||||||
exit(opt_index.index(opt_1))
|
# print(f"本次计算得到的MD5的值为 - ", end='')
|
||||||
|
os.system('echo -n $param | md5sum | cut -d " " -f 1')
|
||||||
|
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh ip')
|
# -f
|
||||||
|
def number2date():
|
||||||
|
exit_on_wrong_number(2)
|
||||||
|
os.environ['param'] = sys.argv[2]
|
||||||
|
os.system('/usr/bin/bash /opt/git/scripts/utool/number2d.sh $param')
|
||||||
|
|
||||||
elif opt_1 == '-d':
|
# -g
|
||||||
if opt_rest != None:
|
def date2number():
|
||||||
print(f"This option({opt_1}) will return the current IP of local machine, and accept NO parameter.")
|
if len(sys.argv) < 3:
|
||||||
exit(opt_index.index(opt_1))
|
print(f"{c_br}-g选项:将输入的时间转换成十进制和十六进制,需要一个字符串格式的时间作为输入,退出...{c_e}\n")
|
||||||
|
exit(ord(option.strip('-')))
|
||||||
|
|
||||||
os.system("/usr/bin/python3 /opt/scripts/roll_api/get_self_ip.py")
|
param=''
|
||||||
|
for item in sys.argv[2:]:
|
||||||
|
param += item + ' '
|
||||||
|
|
||||||
elif opt_1 == '-e':
|
os.environ['param'] = param
|
||||||
if opt_rest == None:
|
os.system('/usr/bin/bash /opt/git/scripts/utool/date2n.sh $param')
|
||||||
print(f"This option({opt_1}) will return the IP info, and accept at least one IP parameter.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
|
|
||||||
for opt_2 in opt_rest:
|
# -h
|
||||||
os.environ['opt_2'] = opt_2
|
def usage():
|
||||||
os.system('/usr/bin/python3 /opt/scripts/roll_api/get_ip.py $opt_2')
|
exit_on_wrong_number()
|
||||||
|
print_usage()
|
||||||
|
|
||||||
elif opt_1 == '-f':
|
# -i
|
||||||
if len(sys.argv) < 3:
|
def ps_top_20():
|
||||||
print(f"{c_br}需要至少一个字符串作为输入,退出...{c_e}\n")
|
exit_on_wrong_number()
|
||||||
exit(opt_index.index(opt_1))
|
os.system("/usr/bin/bash /opt/git/scripts/utool/ps_top_20.sh")
|
||||||
|
|
||||||
param=''
|
# -j
|
||||||
for item in sys.argv[2:]:
|
def docker_pid():
|
||||||
param += item
|
exit_on_wrong_number(2)
|
||||||
|
os.environ['param'] = sys.argv[2]
|
||||||
|
os.system('/usr/bin/bash /opt/git/scripts/utool/pid_in_docker.sh $param')
|
||||||
|
|
||||||
os.environ['param'] = param
|
# -k
|
||||||
print(f"{c_by}Warning: 输入字符串中间的任何空白符将会被删除,要保留的话,需手动将字符串用单引号括起来{c_e}")
|
def company_two_factor():
|
||||||
print(f"本次计算MD5值的字符串为 - {param}\n本次计算得到的MD5的值为 - ", end='')
|
exit_on_wrong_number()
|
||||||
# print(f"本次计算得到的MD5的值为 - ", end='')
|
# method 1
|
||||||
os.system('echo -n $param | md5sum | cut -d " " -f 1')
|
# os.system("/usr/bin/echo -n 'ujjpsx7q'")
|
||||||
|
# os.system("/usr/bin/oathtool -b --totp '22IH2VYKEQYOWVFCCHY5KTU4CYTJ7Z3O'")
|
||||||
|
# method 2
|
||||||
|
pin = 'ujjpsx7q'
|
||||||
|
totp = os.popen("/usr/bin/oathtool -b --totp '22IH2VYKEQYOWVFCCHY5KTU4CYTJ7Z3O'").read()
|
||||||
|
res = pin + totp
|
||||||
|
print(res, end='')
|
||||||
|
return res
|
||||||
|
|
||||||
elif opt_1 == '-g':
|
# -p
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
def gen_passwd():
|
||||||
exit(opt_index.index(opt_1))
|
exit_on_wrong_number(2)
|
||||||
elif opt_1 == '-h':
|
os.environ['length'] = sys.argv[2]
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/usage.sh')
|
os.system('/usr/bin/bash /opt/git/scripts/utool/genpw.sh length')
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-i':
|
|
||||||
if opt_rest == None:
|
|
||||||
print(f"This option({opt_1}) will return the domain registration info, and accept at least one domain parameter.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
|
|
||||||
for opt_2 in opt_rest:
|
def exit_on_wrong_number(number=1):
|
||||||
os.environ['opt_2'] = opt_2
|
if len(sys.argv) != (number+1):
|
||||||
os.system('/usr/bin/python3 /opt/scripts/roll_api/domain_reg_check.py $opt_2')
|
print(f"{c_br}{sys.argv[1:]}: Wrong arguments!")
|
||||||
|
print(f"Option `{option}' will {dict_func[option][0].strip()}")
|
||||||
|
print(f"NEED: {number}\tGIVE: {len(sys.argv)-1}\n{c_e}")
|
||||||
|
exit(ord(option.strip('-')))
|
||||||
|
|
||||||
elif opt_1 == '-j':
|
dict_func = {
|
||||||
if len(sys.argv) == 2:
|
'-a': [' print all local ports of using for now', list_local_using_port],
|
||||||
print(f"{c_br}-j选项:将十进制或者十六进制数字作为入参,转换成标准时间格式,只接收第一个参数,其他参数将被丢弃,有歧义时,使用'0x'或者'0X'来区分十进制和十六进制,退出...{c_e}\n")
|
'-n': ['Reserved', None],
|
||||||
exit(opt_index.index(opt_1))
|
'-b': [' generate two-factor key of GITHUB', github_two_factor],
|
||||||
|
'-o': ['Reserved', None],
|
||||||
os.environ['param'] = sys.argv[2]
|
'-c': [' show external IP of this machine', get_external_ip],
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/number2d.sh $param')
|
'-p': ['*generate password of length 1~79', gen_passwd],
|
||||||
|
'-d': ['*show the location of ip(only v4 for now)', get_ip_location],
|
||||||
elif opt_1 == '-k':
|
'-q': ['Reserved', None],
|
||||||
if len(sys.argv) < 3:
|
'-e': ['*generate md5 value of the input string', gen_md5],
|
||||||
print(f"{c_br}-k选项:将输入的时间转换成十进制和十六进制,需要一个字符串格式的时间作为输入,退出...{c_e}\n")
|
'-r': ['Reserved', None],
|
||||||
exit(opt_index.index(opt_1))
|
'-f': ['*convert a (hexa)decimal to specific time format', number2date],
|
||||||
|
'-s': ['Reserved', None],
|
||||||
param=''
|
'-g': ['*convert multi-formats time to a decimal', date2number],
|
||||||
for item in sys.argv[2:]:
|
'-t': ['Reserved', None],
|
||||||
param += item + ' '
|
'-h': [' show this help information and exit', print_usage],
|
||||||
|
'-u': ['Reserved', None],
|
||||||
os.environ['param'] = param
|
'-i': [' print top 20 mem and cpu process', ps_top_20],
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/date2n.sh $param')
|
'-v': ['Reserved', None],
|
||||||
|
'-j': ['*find a docker subprocess, if true then print info', docker_pid],
|
||||||
elif opt_1 == '-l':
|
'-w': ['Reserved', None],
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
'-k': [' generate two-factor key of GITHUB', company_two_factor],
|
||||||
exit(opt_index.index(opt_1))
|
'-x': ['Reserved', None],
|
||||||
elif opt_1 == '-m':
|
'-l': ['Reserved', None],
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
'-y': ['Reserved', None],
|
||||||
exit(opt_index.index(opt_1))
|
'-m': ['Reserved', None],
|
||||||
elif opt_1 == '-n':
|
'-z': ['Reserved', None],
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
}
|
||||||
exit(opt_index.index(opt_1))
|
return dict_func[option][1]
|
||||||
elif opt_1 == '-o':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-p':
|
|
||||||
if opt_rest == None:
|
|
||||||
opt_rest = ['',]
|
|
||||||
|
|
||||||
opt_2 = opt_rest[0]
|
|
||||||
os.environ['opt_2'] = opt_2
|
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/genpw.sh $opt_2')
|
|
||||||
|
|
||||||
elif opt_1 == '-q':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-r':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-s':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-t':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-u':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-v':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-w':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-x':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-y':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-z':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
else:
|
|
||||||
print("This line SHOULD NOT be executed, please check carefully.")
|
|
||||||
exit(255)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
global option
|
||||||
|
options = [ '-' + chr(x) for x in range(ord('a'), ord('z')+1)]
|
||||||
|
print_usage = utool('-h')
|
||||||
|
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
option = sys.argv[1]
|
||||||
|
if option in options:
|
||||||
|
func = utool(option)
|
||||||
|
if func == None:
|
||||||
|
print(f"{c_bg}Option `{option}' is reserved for now...{c_e}\n")
|
||||||
|
else:
|
||||||
|
func()
|
||||||
|
else:
|
||||||
|
print_usage()
|
||||||
|
else:
|
||||||
|
print_usage()
|
||||||
|
|
||||||
|
# global area below ↓
|
||||||
|
c_title = '\033[1;4;37;40m' # title color
|
||||||
|
c_text = '\033[37;40m' # text color
|
||||||
|
c_intro = '\033[3;32m' # text color
|
||||||
|
c_br = '\033[1;31m' # bold red
|
||||||
|
c_bg = '\033[1;32m' # bold green
|
||||||
|
c_by = '\033[1;33m' # bold yellow
|
||||||
|
c_bb = '\033[1;34m' # bold blue
|
||||||
|
c_bp = '\033[1;35m' # bold purple
|
||||||
|
c_bc = '\033[1;36m' # bold cyan
|
||||||
|
c_bir= '\033[1;3;31m' # * bold italic red
|
||||||
|
c_bib = '\033[1;3;34m' # * bold italic cyan
|
||||||
|
c_bic = '\033[1;3;36m' # bold italic cyan
|
||||||
|
c_e = '\033[0m' # reset
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user