-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud_bella_cli.sh
217 lines (205 loc) · 11.1 KB
/
cloud_bella_cli.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
server_user="root"
server_port="22"
image_ext="png"
systemd="1"
bsa64=""
anim64=""
#cat render.sh | base64 -w0
render_sh="IyEvYmluL2Jhc2gKb3NfbmFtZT0kKGF3ayAtRj0gJyQxPT0iTkFNRSIgeyBwcmludCAkMiA7fScgL2V0Yy9vcy1yZWxlYXNlKQpwbGF0Zm9ybV9pZD0kKGF3ayAtRj0gJyQxPT0iUExBVEZPUk1fSUQiIHsgcHJpbnQgJDIgO30nIC9ldGMvb3MtcmVsZWFzZSkKdXNlcj0kKHdob2FtaSkKZ3JvdXA9JChpZCAtZykKaG9zdG5hbWU9JChob3N0bmFtZSkKaWYgWyAke2hvc3RuYW1lfSA9PSAiYmVsbGExIiBdOyB0aGVuCgliZWxsYV9iaW49Ii91c3IvbG9jYWwvYmluL2JlbGxhX2NsaSIKZWxzZQoJYmVsbGFfYmluPSIuL2JlbGxhX2NsaSIKCWlmICEgdGVzdCAtZiBiZWxsYV9jbGk7IHRoZW4KCQkjIFJIRUwgOC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2Jpbn0gLWk6IiR7ZWFjaH0iIC1wZjoiJHtCRUxMQV9QQVJTRV9GUkFHTUVOVH0iIC1wZjoiJHtpbnNlcnQxfSIgLXBmOiJzZXR0aW5ncy50aHJlYWRzPTA7IiAtb2Q6Ii4vIiA+IGJlbGxhLmxvZwoJCWZpCgkJcm0gJHtlYWNofQoJZG9uZQplbHNlCgllY2hvICJiZWxsYV9jbGkgaXMgYWxyZWFkeSBydW5uaW5nLCBub3RoaW5nIG5ldyBpcyBiZWluZyBkb25lIgpmaQo="
#echo ${render_sh} | base64 -d -i - > render.sh
pid_ssh_agent="$(pgrep ssh-agent)"
if ! [ -z $pid_ssh_agent ]; then
kill $pid_ssh_agent
fi
# cache ssh credentials
if [ $(ps ax | grep ssh-agent | wc -l) -gt 1 ] ; then
echo "ssh-agent is already running"
else
eval $(ssh-agent -s)
if [ "$(ssh-add -l)" == "The agent has no identities." ] ; then
ssh-add ~/.ssh/id_ed25519
fi
trap "ssh-agent -k" exit
fi
while :
do
if [ -z ${server_ip} ]; then
while :
do
echo -e "\nLinux server internet address"
read -p "Enter x.x.x.x:" server_ip
if ! [ -z ${server_ip} ]; then
break
fi
done
if [ ${server_ip} == "masey.indoodle.com" ]; then
server_user="oomer"
server_port="222"
fi
else
echo -e "\n================================================="
select action in upload render progress download advanced server settings quit
do
break
done
if [[ $action == "upload" ]]; then
list_bsz="$(ls *.bsz 2>&1)"
echo ${list_bsz}
select bsz in ${list_bsz} back
do
break
done
if ! [ ${bsz} == "back" ];then
echo "Uploading ${bsz}..."
scp -P ${server_port} ${bsz} ${server_user}@${server_ip}:~
fi
elif [[ $action == "progress" ]]; then
ssh ${server_user}@${server_ip} -p ${server_port} tail bella.log
elif [[ $action == "render" ]]; then
vast_host=$(ssh ${server_user}@${server_ip} -p ${server_port} test -f .vast_containerlabel; echo $?)
if [ ${server_user} == "bella" ]; then
echo "bypass"
elif [ ${server_ip} == "masey.indoodle.com" ]; then
echo "bypass"
elif [ ${server_user} == "root" ]; then
ssh ${server_user}@${server_ip} -p ${server_port} "sed -i /'AcceptEnv LANG LC_*'/d /etc/ssh/sshd_config"
ssh ${server_user}@${server_ip} -p ${server_port} "grep -qxF 'AcceptEnv BELLA_LICENSE_TEXT' /etc/ssh/sshd_config || echo 'AcceptEnv BELLA_LICENSE_TEXT' >> /etc/ssh/sshd_config"
ssh ${server_user}@${server_ip} -p ${server_port} "grep -qxF 'AcceptEnv BELLA_PARSE_FRAGMENT' /etc/ssh/sshd_config || echo 'AcceptEnv BELLA_PARSE_FRAGMENT' >> /etc/ssh/sshd_config"
ssh ${server_user}@${server_ip} -p ${server_port} "grep -qxF 'AcceptEnv BELLA_VERSION' /etc/ssh/sshd_config || echo 'AcceptEnv BELLA_VERSION' >> /etc/ssh/sshd_config"
echo -e "\n${vast_host}"
if [ ${vast_host} == "1" ]; then
ssh ${server_user}@${server_ip} -p ${server_port} "systemctl restart sshd"
else
ssh ${server_user}@${server_ip} -p ${server_port} "/etc/init.d/ssh restart"
fi
else
ssh ${server_user}@${server_ip} -p ${server_port} "grep -qxF 'AcceptEnv BELLA_LICENSE_TEXT' /etc/ssh/sshd_config || echo 'AcceptEnv BELLA_LICENSE_TEXT' | sudo tee -a /etc/ssh/sshd_config"
ssh ${server_user}@${server_ip} -p ${server_port} "grep -qxF 'AcceptEnv BELLA_PARSE_FRAGMENT' /etc/ssh/sshd_config || echo 'AcceptEnv BELLA_PARSE_FRAGMENT' | sudo tee -a /etc/ssh/sshd_config"
ssh ${server_user}@${server_ip} -p ${server_port} "grep -qxF 'AcceptEnv BELLA_VERSION' /etc/ssh/sshd_config || echo 'AcceptEnv BELLA_VERSION' | sudo tee -a /etc/ssh/sshd_config"
echo -e "\n${vast_host}"
if [ ${vast_host} == "1" ]; then
ssh ${server_user}@${server_ip} -p ${server_port} "sudo systemctl restart sshd"
else
ssh ${server_user}@${server_ip} -p ${server_port} "sudo /etc/init.d/ssh restart"
fi
fi
if [ -z ${bsa64} ]; then
ssh ${server_user}@${server_ip} -p ${server_port} "rm -f cloud_bella_cli.bsa"
else
ssh ${server_user}@${server_ip} -p ${server_port} "echo ${bsa64} | base64 --decode > cloud_bella_cli.bsa"
fi
if [ -z ${anim64} ]; then
ssh ${server_user}@${server_ip} -p ${server_port} "rm -f cloud_bella_cli.anim"
else
ssh ${server_user}@${server_ip} -p ${server_port} "echo ${anim64} | base64 --decode > cloud_bella_cli.anim"
fi
ssh ${server_user}@${server_ip} -p ${server_port} "echo ${render_sh} | base64 --decode > render.sh"
ssh ${server_user}@${server_ip} -p ${server_port} "echo ${pf64} | base64 --decode > pf.txt"
ssh ${server_user}@${server_ip} -p ${server_port} "nohup bash render.sh >./nohup.out 2>./nohup.err &"
elif [[ $action == "server" ]]; then
select setting in set_server set_port set_user systemd delete_files delete_bella_cli stop_bella back
do
break
done
if ! [ ${setting} == "back" ];then
if [[ $setting == "set_server" ]]; then
echo -e "\nLinux server internet address"
current=${server_ip}
read -p "Enter: ${current}:" server_ip
if [ -z ${server_ip} ]; then
server_ip=${current}
fi
elif [[ $setting == "delete_files" ]]; then
echo -e "\nDeleting *${file_ext}"
ssh ${server_user}@${server_ip} -p ${server_port} "rm -f *.${file_ext}"
elif [[ $setting == "delete_bella_cli" ]]; then
echo -e "\nDeleting bella_cli"
ssh ${server_user}@${server_ip} -p ${server_port} "rm -f bella_cli"
elif [[ $setting == "stop_bella" ]]; then
echo -e "\nStopping bella_cli"
ssh ${server_user}@${server_ip} -p ${server_port} "pkill -2 -e bella_cli"
elif [[ $setting == "set_user" ]]; then
echo -e "\nLinux username"
current=${server_user}
read -p "Enter: (current: ${current}):" server_user
if [ -z ${server_user} ]; then
server_user=${current}
fi
elif [[ $setting == "systemd" ]]; then
echo -e "\nset to 0 for init.d"
read -p "Enter systemd: (default 1):" systemd
if [ -z ${systemd} ]; then
systemd="1"
fi
elif [[ $setting == "set_port" ]]; then
echo -e "\nLinux server internet port"
current=${server_port}
read -p "Enter: default(${current}):" server_port
if [ -z ${server_port} ]; then
server_port="${current}"
fi
fi
fi
elif [[ $action == "settings" ]]; then
select setting in download_extension back
do
break
done
if ! [ ${setting} == "back" ];then
if [[ $setting == "download_extension" ]]; then
read -p "Enter download extension no period: (default png):" image_ext
if [ -z ${image_ext} ]; then
image_ext="png"
fi
fi
fi
elif [[ $action == "download" ]]; then
echo "Downloading *.${file_ext}"
scp -P ${server_port} ${server_user}@${server_ip}:./*.${image_ext} ./
elif [[ $action == "advanced" ]]; then
select advanced in bsa anim cleanup_server back
do
break
done
if [[ $advanced == "bsa" ]]; then
list_bsa="$(ls *.bsa 2>&1)"
select bsa in ${list_bsa} skip
do
break
done
if ! [ ${bsa} == "skip" ];then
echo "new render will include -pf:\"./${bsa}\""
cat $bsa
bsa64="$(cat ${bsa} | base64 -i - )"
else
bsa64=""
fi
elif [[ $advanced == "anim" ]]; then
list_anim="$(ls *.anim 2>&1)"
select anim in ${list_anim} disable_anim
do
break
done
if [ ${anim} == "disable_anim" ];then
anim64=""
else
prefix=${anim%.*}
echo -e "\nAnim mode activated with .bsa and .anim:"
echo -e "\n"
echo "${prefix}.bsa"
cat ${prefix}.bsa
echo -e "\n$anim"
cat $anim
bsa64="$(cat ${prefix}.bsa | base64 -i - )"
anim64="$(cat ${anim} | base64 -i - )"
fi
elif [ $advanced == "clear_server" ];then
echo -e "\nDeleting *.bsa"
ssh ${server_user}@${server_ip} -p ${server_port} "rm -f *.bsa; rm -f *.anim"
fi
else
exit
fi
fi
done