135 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			135 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!/bin/bash
 | ||
| # User specific aliases and functions
 | ||
| 
 | ||
| alias cls='clear && ls'
 | ||
| # alias trash='cd /usr/local/script/fanmf11/trash/fanmf11 && ls'
 | ||
| alias fanmf11='cd /usr/local/script/fanmf11 && ls'
 | ||
| alias ..='cd ../ && ls'
 | ||
| alias ...='cd ../.. && ls'
 | ||
| alias l='ls -alh'
 | ||
| alias common='cat /usr/local/script/fanmf11/data/cmds'
 | ||
| 
 | ||
| c_br='\e[1;31m'     # bold red
 | ||
| c_bg='\e[1;32m'     # bold green
 | ||
| c_by='\e[1;33m'     # bold yellow
 | ||
| c_bb='\e[1;34m'     # bold blue
 | ||
| c_bp='\e[1;35m'     # bold purple
 | ||
| c_bc='\e[1;36m'     # bold cyan
 | ||
| c_bir='\e[1;3;31m'  # * bold italic red
 | ||
| c_big='\e[1;3;32m'  # bold italic cyan
 | ||
| c_bib='\e[1;3;34m'  # * bold italic cyan
 | ||
| c_bip='\e[1;3;35m'  # bold italic cyan
 | ||
| c_bic='\e[1;3;36m'  # bold italic cyan
 | ||
| c_e='\e[0m'         # reset
 | ||
| 
 | ||
| trash='/usr/local/script/fanmf11/trash'
 | ||
| 
 | ||
| function utool() {
 | ||
| 
 | ||
|     if [[ $1 == '-a' ]]; then
 | ||
|         # set -x
 | ||
|         [[ $# -lt 1 ]] && { echo -e "${c_bir}[UTOOL-100] Need at least one parameter, exiting...${c_e}"; return 100; }
 | ||
|         [[ $# -eq 1 ]] && place='fanmf11' || place="$2"
 | ||
|         ls $trash | grep -wq $place
 | ||
|         [[ $? -ne 0 ]] && { echo -e "${c_br}[UTOOL-101] $place用户不存在,或该用户从未使用过相关工具,退出...${c_e}"; return 101; }
 | ||
| 
 | ||
|         > $trash/fanmf11/record.log
 | ||
|         items="ips ids map infos logs config"
 | ||
|         for item in $items; do
 | ||
|             date_lists=`find $trash/$place -name "$item" -type f | sort | uniq | awk -F '/' '{print $8}' | sort | uniq`
 | ||
|             for date_list in $date_lists; do
 | ||
|                 let number=${date_list:0:10}
 | ||
|                 date_fmt=`date -d@$number +'%Y-%m-%d %H:%M:%S'`
 | ||
|                 echo "$date_fmt $date_list $item" >> $trash/fanmf11/record.log
 | ||
|             done
 | ||
|         done
 | ||
|         cat $trash/fanmf11/record.log | sort -nk3 | awk '{printf "%-11s%-14s%-25s%-s\n", $1, $2, $3, $4}'
 | ||
|         # set +x
 | ||
|     elif [[ $1 == '-b' ]]; then
 | ||
|         cat /usr/local/script/fanmf11/data/cmds
 | ||
|     elif [[ $1 == '-c' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-d' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-e' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-f' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-g' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-h' ]]; then
 | ||
|         usage
 | ||
|     elif [[ $1 == '-i' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-j' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-k' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-l' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-m' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-n' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-o' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-p' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-q' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-r' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-s' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-t' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-u' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-v' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-w' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-x' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-y' ]]; then
 | ||
|         :
 | ||
|     elif [[ $1 == '-z' ]]; then
 | ||
|         echo -e "${c_bg}直播:120.39.248.231"
 | ||
|         echo -e "全站:222.187.236.6"
 | ||
|         echo -e "全站:222.187.236.7"
 | ||
|         echo -e "点播:113.62.113.33${c_e}"
 | ||
|     else
 | ||
|         :
 | ||
|     fi
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| function usage() {
 | ||
|     let col=`tput cols`
 | ||
|     if [[ $col -lt 120 ]]; then
 | ||
|         echo -e "\e[1;3;31mYour screen width is too small to show the usage info neatly. So make the display window maximized.\e[0m"
 | ||
|         read -p "Press any key to continue..."
 | ||
|         echo ''
 | ||
|     fi
 | ||
| 
 | ||
| 
 | ||
|     echo -e "\e[1;32mDESCRIPTION:\e[0m"
 | ||
|     echo -e "\e[3;32mutool -- 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.\e[0m"
 | ||
|     echo -e "\e[1;4m                                                                                                                       \e[0m"
 | ||
|     echo -e "\e[37;40m|\e[0m\e[1;4;37;40mOption| Description                                       |Option| Description                                       \e[0m\e[37;40m|\e[0m"
 | ||
|     echo -e "\e[37;40m|  -a  |*find dirs of specified item in trash              |  -n  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -b  | show some often used commands                     |  -o  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -c  |                                                   |  -p  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -d  |                                                   |  -q  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -e  |                                                   |  -r  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -f  |                                                   |  -s  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -g  |                                                   |  -t  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -h  | show usage info                                   |  -u  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -i  |                                                   |  -v  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -j  |                                                   |  -w  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -k  |                                                   |  -x  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|  -l  |                                                   |  -y  |                                                   |\e[0m"
 | ||
|     echo -e "\e[37;40m|\e[0m\e[4;37;40m  -m  |                                                   |  -z  |                                                   \e[0m\e[37;40m|\e[0m\n"
 | ||
| }
 |