-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload.sh
143 lines (118 loc) · 2.72 KB
/
load.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env bash
# get absoltae path to the dir this is in, work in bash, zsh
# if you want transfer symbolic link to true path, just change `pwd` to `pwd -P`
here=$(cd "$(dirname "${BASH_SOURCE[0]-$0}")"; pwd)
here="`(readlink "$here" || echo "$here") | sed -E 's|^/mfs/([^/]+)|/home/\1/mfs|'`"
admin_tool_path="${here}"
alias _all="zsh $here/all.sh"
all()
{
_all "$@"
}
alltest()
{
if [ $# -eq 0 ]; then
local server_set='a'
else
local server_set="$1"
fi
all "$server_set" 'echo "hello world"'
}
alias _send="zsh $here/all.sh --send"
send()
{
_send "$@"
}
alluid()
{
local server_set=
if [ $# -eq 1 ]; then
server_set="a"
else
server_set="$1"
shift
fi
local uid="$1"
all "$server_set" --uid $uid --gid $uid
}
allgid()
{
local server_set=
if [ $# -eq 1 ]; then
server_set="a"
else
server_set="$1"
shift
fi
local gid="$1"
all "$server_set" --gid $gid
}
if [[ "`type allgpu 2>&1`" =~ 'alias' ]]; then
unalias allgpu
fi
allgpu()
{
local server_set=
if [ $# -eq 0 ]; then
server_set=g
else
server_set="$1"
fi
all "$server_set" --no-prompt 'gpustat'
}
# use sudo to do something with this package
admin()
{
# echo "$@"
# echo "$*"
# local commands=''
# for i in "$@"; do
# # echo -E "$i"
# if [[ "$i" =~ ' ' ]]; then
# local i="${i//\"/\\\"}"
# local i="${i//\$/\\\$}"
# local commands="$commands \"$i\""
# else
# local commands="$commands $i"
# fi
# done
# echo commands: $commands
# commands="${commands//\`/\\\`}"
# echo commands: $commands
if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
echo "\`admin\` to run commands with admin_tool package"
echo "Usage:"
echo "admin 'command1' [ 'command2' ... ]"
echo "admin \"command1\" [ \"command2\" ... ]"
return
fi
local cmds=''
for i in "$@"; do
local cmds="$cmds $i;"
done
echo "cmds: $cmds"
sudo su -c ". $admin_tool_path/load.sh && $cmds"
}
# quota_du: 通过quota显示某给文件夹下所在文件系统的各个用户的文件总大小
. $here/sl/mfs_quota.sh
. $here/sl/sl_home.sh
# slG()
# {
# local tmp_log=$(mktemp /tmp/tmp.XXXXXXXXXX)
# echo $tmp_log
# local exit_func() {
# pkill -P $$
# rm $tmp_log
# }
# trap exit_func SIGINT
# du -axhd1 --block-size=1G $@ >> $tmp_log &
# watch -n 1 -t "sort -n $tmp_log"
# # wait
# # exit_func
# }
. $here/user_manage.sh
. $here/mfs_set.sh
. $here/software.sh
# 设置交互内存
alias swap="sudo bash ${admin_tool_path}/swap.sh"
unset here