shell script
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
code() {
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: code [-d] <script name>"
|
||||
echo " -d Download and execute the script with bash"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local execute=false
|
||||
|
||||
if [ "$1" = "-d" ]; then
|
||||
execute=true
|
||||
shift
|
||||
fi
|
||||
|
||||
local script_name="$1"
|
||||
local base_url="https://sh.lihanzhang.cn"
|
||||
|
||||
if curl -sfO "${base_url}/${script_name}" 2>/dev/null; then
|
||||
if [ -f "${script_name}" ]; then
|
||||
if [ "$execute" = true ]; then
|
||||
bash "${script_name}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
transfer() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: transfer <file>"
|
||||
return 1
|
||||
fi
|
||||
url=$(curl -sT "$1" https://u.lihanzhang.cn)
|
||||
|
||||
if command -v qrencode >/dev/null 2>&1; then
|
||||
qrencode -t ANSIUTF8 "$url"
|
||||
fi
|
||||
|
||||
echo -e "\e[32m$url\e[0m"
|
||||
}
|
||||
enc() {
|
||||
if [ "$1" = "-d" ]; then
|
||||
shift
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage: enc -d <input_file> <output_file>"
|
||||
return 1
|
||||
fi
|
||||
openssl enc -d -aes-256-cbc -pbkdf2 -in "$1" -out "$2"
|
||||
else
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage: enc <input_file> <output_file>"
|
||||
return 1
|
||||
fi
|
||||
openssl enc -aes-256-cbc -pbkdf2 -in "$1" -out "$2"
|
||||
fi
|
||||
}
|
||||
#curl -L sh.lihanzhang.cn/profile -o /root/.local/bin/.bashrc
|
||||
Reference in New Issue
Block a user