Compare commits
98 Commits
3c1609aa68
...
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 | |||
19f72612cd | |||
ce95c20bc4 | |||
ac2ee2f48c | |||
e0cdc133a2 | |||
8d11aa9ec8 | |||
5efa59be75 | |||
b32ea0978d | |||
d05c443552 | |||
38b59e86c3 | |||
76c82ded84 | |||
b7c656afd3 | |||
6e50da6f8d | |||
1ab7a327ca | |||
aee4d3ca16 | |||
d796401648 | |||
e0b5bfbdcd | |||
41cfb25650 | |||
2b4d9f1bf5 | |||
15362bfeea | |||
ea87853a7b | |||
94aba6a154 | |||
77a475b51e |
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()
|
||||||
|
|
||||||
|
|
@ -1,12 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
> /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}'`
|
||||||
alarm="Docker Alarm - $name:\nContainer $name has been off line, please check ASAP."
|
echo "Docker Alarm - $name: Container $name has been off line, please check ASAP." >> /tmp/docker_alarm.log
|
||||||
bash /opt/scripts/alert/sendmsg.sh "$alarm"
|
|
||||||
fi
|
fi
|
||||||
done < /opt/logs/docker_status.log
|
done < /opt/logs/docker_status.log
|
||||||
|
|
||||||
|
if [[ -s /tmp/docker_alarm.log ]]; then
|
||||||
|
alarm=`cat /tmp/docker_alarm.log`
|
||||||
|
python3 /opt/git/scripts/alert/sendmail.py "Docker Alarms" "$alarm"
|
||||||
|
fi
|
||||||
|
|
||||||
|
63
alert/sendmail.py
Normal file
63
alert/sendmail.py
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
# 脚本接收两个及以上的参数
|
||||||
|
# 第一个参数:邮件主题
|
||||||
|
# 第二个参数:邮件文本内容
|
||||||
|
# 其他参数:邮件附件
|
||||||
|
|
||||||
|
|
||||||
|
from email.mime.text import MIMEText
|
||||||
|
from email.mime.image import MIMEImage
|
||||||
|
from email.mime.multipart import MIMEMultipart
|
||||||
|
import smtplib
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Mail basic information
|
||||||
|
mail_host = "smtp.163.com"
|
||||||
|
from_mail = 'xgdfmf@163.com'
|
||||||
|
from_mail_password = 'PSIKFDYLMGBPSEPJ'
|
||||||
|
receiver_to = ['mffan0922@163.com']
|
||||||
|
receiver_cc = []
|
||||||
|
to_mail = receiver_to + receiver_cc
|
||||||
|
|
||||||
|
|
||||||
|
# MIMEMultipart: mixed/alternative/related
|
||||||
|
# (1)mixed: default option, especially situation with mail attachments must use this one
|
||||||
|
# (2)alternative: with both plain text and hyper text in mail content, using this one
|
||||||
|
# (3)related:sending content of html format, probably using picture as the background of mail
|
||||||
|
# content, then html text will be stored in alternative segment, whereas the background picture
|
||||||
|
# will be stored in multipart/related segment
|
||||||
|
|
||||||
|
# Mail content
|
||||||
|
msg = MIMEMultipart()
|
||||||
|
msg['From'] = from_mail
|
||||||
|
msg['To'] = ";".join(to_mail)
|
||||||
|
msg['Subject'] = sys.argv[1]
|
||||||
|
txt = sys.argv[2]
|
||||||
|
body = MIMEText(txt, 'plain', 'utf-8')
|
||||||
|
msg.attach(body)
|
||||||
|
|
||||||
|
|
||||||
|
# Mail attachment
|
||||||
|
if len(sys.argv) > 3:
|
||||||
|
for attachment in sys.argv[3:]:
|
||||||
|
filename = attachment.split('/')[-1]
|
||||||
|
attach_file = open(attachment, 'r').read()
|
||||||
|
attach = MIMEText(str(attach_file), 'base64', 'utf-8')
|
||||||
|
attach["Content-Type"] = 'application/octet-stream'
|
||||||
|
attach.add_header('Content-Disposition', 'attachment', filename=filename)
|
||||||
|
msg.attach(attach)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
server = smtplib.SMTP(mail_host)
|
||||||
|
server.docmd('helo', from_mail)
|
||||||
|
server.starttls()
|
||||||
|
server.login(from_mail, from_mail_password)
|
||||||
|
|
||||||
|
server.sendmail(from_mail, to_mail, msg.as_string())
|
||||||
|
server.quit()
|
||||||
|
print('sendemail successful!')
|
||||||
|
except Exception as err:
|
||||||
|
print('Sending email failed, the reason is as below:')
|
||||||
|
print(err)
|
||||||
|
|
@ -4,33 +4,33 @@ import time
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def send_alert_msg(alert_msg):
|
# def send_alert_msg(alert_msg):
|
||||||
"""
|
# """
|
||||||
send warning messages to phone via Enterprise WeChat Bot API
|
# send warning messages to phone via Enterprise WeChat Bot API
|
||||||
:param alert_msg: messages needed to be sent
|
# :param alert_msg: messages needed to be sent
|
||||||
:return: None
|
# :return: None
|
||||||
"""
|
# """
|
||||||
|
#
|
||||||
# get the datetime, which is using at a failed situation
|
# # get the datetime, which is using at a failed situation
|
||||||
alert_datetime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
|
# alert_datetime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
|
||||||
# # Enterprise Wechat Bot API and the format of body to send
|
# # # Enterprise Wechat Bot API and the format of body to send
|
||||||
hook_url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=ddea3f5f-fbfc-4c21-994a-71e9fc50e4ef'
|
# hook_url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=ddea3f5f-fbfc-4c21-994a-71e9fc50e4ef'
|
||||||
body = {
|
# body = {
|
||||||
"msgtype": "text",
|
# "msgtype": "text",
|
||||||
"text": {
|
# "text": {
|
||||||
"content": alert_msg
|
# "content": alert_msg
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
# get the result of API call
|
# # get the result of API call
|
||||||
res = requests.post(hook_url, data=json.dumps(body, ensure_ascii=False).encode('utf-8'))
|
# res = requests.post(hook_url, data=json.dumps(body, ensure_ascii=False).encode('utf-8'))
|
||||||
|
#
|
||||||
# when failed, log it in /opt/logs/alert.log file
|
# # when failed, log it in /opt/logs/alert.log file
|
||||||
if res.status_code != 200:
|
# if res.status_code != 200:
|
||||||
with open('/opt/logs/alert.log', 'a', encoding='utf-8') as alert_log:
|
# with open('/opt/logs/alert.log', 'a', encoding='utf-8') as alert_log:
|
||||||
alert_log.write(alert_datetime + ' >>>> ')
|
# alert_log.write(alert_datetime + ' >>>> ')
|
||||||
alert_log.write('Failed sending message: ')
|
# alert_log.write('Failed sending message: ')
|
||||||
alert_log.write(alert_msg + '\n')
|
# alert_log.write(alert_msg + '\n')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -87,7 +87,13 @@ def main():
|
|||||||
alert_msg += '\n'
|
alert_msg += '\n'
|
||||||
|
|
||||||
alert_msg += 'So, hurry up!! Go get things done!!'
|
alert_msg += 'So, hurry up!! Go get things done!!'
|
||||||
send_alert_msg(alert_msg)
|
os.environ['subject'] = 'TODO TIPS'
|
||||||
|
os.environ['txt'] = alert_msg
|
||||||
|
# os.system('/usr/bin/echo subject = $subject')
|
||||||
|
# os.system('/usr/bin/echo txt = $txt')
|
||||||
|
# exit(9)
|
||||||
|
os.system('/usr/bin/python3 /opt/scripts/alert/sendmail.py "$subject" "$txt"')
|
||||||
|
# send_alert_msg(alert_msg)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
calibre='/opt/apps/calibre/calibre-web-0.6.20'
|
calibre='/opt/apps/calibre/calibre-web-0.6.20'
|
||||||
# get the pid of calibre, and write it into file /tmp/calibre_pids
|
cd $calibre
|
||||||
ps -ef | grep "$calibre/cps.py" | grep -v grep | awk '{print $2}' > /tmp/calibre_pids
|
# get the pid of calibre, and write it into file calibre_pids
|
||||||
|
ps -ef | grep "$calibre/cps.py" | grep -v grep | awk '{print $2}' > calibre_pids
|
||||||
|
|
||||||
# if not exist, signifying that there is no calibre process
|
# if not exist, signifying that there is no calibre process
|
||||||
if [[ ! -s /tmp/calibre_pids ]]; then
|
if [[ ! -s calibre_pids ]]; then
|
||||||
echo -e "\e[1;31mCannot terminate Calibre process cause there is no such things, will run calibre later automatically.\e[0m"
|
echo -e "\e[1;31mCannot terminate Calibre process cause there is no such things, will run calibre later automatically.\e[0m"
|
||||||
else
|
else
|
||||||
for calibre_pid in `cat /tmp/calibre_pids`; do
|
for calibre_pid in `cat calibre_pids`; do
|
||||||
kill -9 $calibre_pid > /dev/null 2>&1
|
kill -9 $calibre_pid > /dev/null 2>&1
|
||||||
done
|
done
|
||||||
fi
|
fi
|
@ -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
old/localip.sh
Normal file
16
old/localip.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
localip='/opt/wd/99-Temp/localip.txt'
|
||||||
|
> $localip
|
||||||
|
networks=('wlx90de80ca01ec' 'enp1s0' 'enp2s0')
|
||||||
|
for network in ${networks[@]}; do
|
||||||
|
ifconfig $network | grep -iq 'Device not found'
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo -n "$network: " >> $localip
|
||||||
|
ifconfig $network | grep 'inet ' | awk '{print $2}' >> $localip
|
||||||
|
echo >> $localip
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
sed -i '/^$/d' $localip
|
||||||
|
cp $localip /opt/apps/syncthing/data/common/Z-TMP/
|
||||||
|
|
25
old/macvlan.sh
Normal file
25
old/macvlan.sh
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
for i in `seq 3`; do
|
||||||
|
gateway=`ip route | head -n 1 | grep -Eow '([0-9]{1,3}.){3}[0-9]{1,3}'`
|
||||||
|
[[ $gateway == '' ]] && { sleep 3; continue; }
|
||||||
|
done
|
||||||
|
[[ $gateway == '' ]] && exit 9
|
||||||
|
|
||||||
|
num1=`echo $gateway | awk -F '.' '{print $1}'`
|
||||||
|
num2=`echo $gateway | awk -F '.' '{print $2}'`
|
||||||
|
num3=`echo $gateway | awk -F '.' '{print $3}'`
|
||||||
|
|
||||||
|
for num4 in `seq 200 254`; do
|
||||||
|
IP=$num1'.'$num2'.'$num3'.'$num4
|
||||||
|
ping -c 2 $IP
|
||||||
|
[[ $? -ne 0 ]] && break
|
||||||
|
done
|
||||||
|
|
||||||
|
ip link add main2wrt link enp1s0 type macvlan mode bridge
|
||||||
|
ip addr add $IP dev main2wrt
|
||||||
|
ip link set main2wrt up
|
||||||
|
ip route add 192.168.10.123 dev main2wrt
|
||||||
|
|
||||||
|
ip link set main2wrt promisc on
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
@ -42,6 +42,36 @@ ABORT=9
|
|||||||
# lack of bluetooth drivers and wireless net card(Intel AX101)drivers -- ibt-0040-1050.sfi
|
# lack of bluetooth drivers and wireless net card(Intel AX101)drivers -- ibt-0040-1050.sfi
|
||||||
# cp ibt-0040-0041.sfi ibt-0040-1050.sfi
|
# cp ibt-0040-0041.sfi ibt-0040-1050.sfi
|
||||||
# cp ibt-0040-0041.ddc ibt-0040-1050.ddc
|
# cp ibt-0040-0041.ddc ibt-0040-1050.ddc
|
||||||
|
# -------------------------------------------------------------------------------------------------------------
|
||||||
|
# do nothing when closing laptop lid
|
||||||
|
# Firstly, edit file /etc/systemd/logind.conf
|
||||||
|
# HandleLidSwitch=ignore
|
||||||
|
# HandleLidSwitchExternalPower=ignore
|
||||||
|
# HandleLidSwitchDocked=ignore
|
||||||
|
# LidSwitchIgnoreInhibited=yes
|
||||||
|
#
|
||||||
|
# Candidate: suspend/lock/ignore/poweroff/hibernate
|
||||||
|
#
|
||||||
|
# Secondly, reboot the system
|
||||||
|
# -------------------------------------------------------------------------------------------------------------
|
||||||
|
# get host local ip when using a new network environment
|
||||||
|
# ping BeeLink
|
||||||
|
# -------------------------------------------------------------------------------------------------------------
|
||||||
|
# x-ui build up
|
||||||
|
# bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)
|
||||||
|
# -------------------------------------------------------------------------------------------------------------
|
||||||
|
# update docker images
|
||||||
|
# 0. docker-compose down
|
||||||
|
# 1. docker-compose pull
|
||||||
|
# 2. docker-compose up -d --remove-orphans
|
||||||
|
# 3. docker image prune
|
||||||
|
# -------------------------------------------------------------------------------------------------------------
|
||||||
|
# -------------------------------------------------------------------------------------------------------------
|
||||||
|
# -------------------------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
# =============================================================================================================
|
# =============================================================================================================
|
||||||
# This script must be executed by root privilege
|
# This script must be executed by root privilege
|
||||||
@ -106,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
|
||||||
@ -242,6 +273,8 @@ systemctl start nginx.service
|
|||||||
# =============================================================================================================
|
# =============================================================================================================
|
||||||
# install jekyll
|
# install jekyll
|
||||||
echo -e "\n\e[1;34mInstall jekyll blog env...\e[0m\n"
|
echo -e "\n\e[1;34mInstall jekyll blog env...\e[0m\n"
|
||||||
|
gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
|
||||||
|
gem sources -l
|
||||||
gem install jekyll jekyll-paginate
|
gem install jekyll jekyll-paginate
|
||||||
jekyll b -s /opt/apps/blog/ -d /opt/websites/blog/
|
jekyll b -s /opt/apps/blog/ -d /opt/websites/blog/
|
||||||
|
|
||||||
@ -303,13 +336,16 @@ docker network create -d bridge --subnet=10.10.0.0/24 --gateway 10.10.0.1 inner
|
|||||||
# option ifname 'eth0'
|
# option ifname 'eth0'
|
||||||
# option proto 'static'
|
# option proto 'static'
|
||||||
# option netmask '255.255.255.0'
|
# option netmask '255.255.255.0'
|
||||||
# option gateway '192.168.0.1'
|
# option gateway '192.168.31.1'
|
||||||
# option ip6assign '60'
|
# option ip6assign '60'
|
||||||
# option dns ' 8.8.8.8 114.114.114.114'
|
# option dns ' 8.8.8.8 114.114.114.114'
|
||||||
# option ipaddr '192.168.0.254'
|
# option ipaddr '192.168.31.123'
|
||||||
# option broadcast '192.168.0.255'
|
# option broadcast '192.168.31.255'
|
||||||
# /etc/init.d/network restart
|
# /etc/init.d/network restart
|
||||||
# modify the above according to different situations
|
# modify the above according to different situations, and the following is another method to do this
|
||||||
|
# docker network create -d macvlan --subnet=192.168.31.1/24 --gateway=192.168.31.2 -o parent=enp1s0 net_openwrt
|
||||||
|
# docker run -d --name openwrt --net net_openwrt --privileged --ip 192.168.183.123 sulinggg/openwrt:x86_64 /sbin/init
|
||||||
|
# when using openwrt or another ethernet port, keep in mind that need to modify ip addr accordingly
|
||||||
|
|
||||||
# =============================================================================================================
|
# =============================================================================================================
|
||||||
# configure cloudreve after mysql docker is up
|
# configure cloudreve after mysql docker is up
|
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,10 +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 /root/.acme.sh/rustle.cc_ecc/rustle.cc.{key,cer} /opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/
|
||||||
|
cp -rf /opt/apps/syncthing/data/common/A_Program/FRP/* /opt/apps/frp/frpc-xtcp-visitor/
|
||||||
|
cp -rf /etc/systemd/network /opt/configs/conf/
|
||||||
|
cp -rf /etc/modprobe.d/pcspkr-blacklist.conf /opt/configs/conf/
|
||||||
|
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 --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
|
||||||
@ -33,7 +40,21 @@ if [[ $count -gt 10 ]]; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# tar -I pixz -cf $backup_dir/vps-${t}.tar.xz -C /opt configs data logs scripts source-code websites > /dev/null 2>&1
|
# on 1st of every month, do a compress
|
||||||
|
if [[ `date +%d` == '01' ]]; then
|
||||||
|
t=`date +%Y%m%d%H%M%S` && cd /opt/wd/72-Backups/
|
||||||
|
|
||||||
|
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
|
||||||
set +x
|
set +x
|
||||||
echo End Time: `date`
|
echo End Time: `date`
|
||||||
echo "========================================================================="
|
echo "========================================================================="
|
||||||
|
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
|
@ -1,14 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ip link set enp1s0 promisc on
|
#==============================================================================
|
||||||
ip link set enp2s0 promisc on
|
|
||||||
ip link set wlx90de80ca01ec promisc on
|
|
||||||
|
|
||||||
/usr/bin/qbittorrent-nox --webui-port=10005 -d
|
/usr/bin/qbittorrent-nox --webui-port=10005 -d
|
||||||
/usr/bin/bash /opt/scripts/update/jekyll_update.sh
|
mv /opt/wd/99-Temp/shutdown /opt/wd/99-Temp/shutdown.old
|
||||||
/usr/bin/bash /opt/scripts/update/calibre.sh
|
mv /opt/wd/99-Temp/reboot /opt/wd/99-Temp/reboot.old
|
||||||
|
sleep 20
|
||||||
|
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/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
|
||||||
|
|
||||||
|
|
||||||
|
|
11
update/sysmngt.sh
Normal file
11
update/sysmngt.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# code=`cat /opt/wd/99-Temp/shutdown.txt`
|
||||||
|
|
||||||
|
if [[ -f "/opt/wd/99-Temp/shutdown" ]]; then
|
||||||
|
poweroff
|
||||||
|
elif [[ -f "/opt/wd/99-Temp/reboot" ]]; then
|
||||||
|
reboot
|
||||||
|
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