-
Notifications
You must be signed in to change notification settings - Fork 794
/
emby_config_editor.sh
291 lines (244 loc) · 7.7 KB
/
emby_config_editor.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#!/bin/bash
# shellcheck shell=bash
PATH=${PATH}:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
export PATH
#
# ——————————————————————————————————————————————————————————————————————————————————
# __ ___ _ _ _
# \ \ / (_) /\ | (_) | |
# \ V / _ __ _ ___ _ _ __ _ / \ | |_ ___| |_
# > < | |/ _` |/ _ \| | | |/ _` | / /\ \ | | / __| __|
# / . \| | (_| | (_) | |_| | (_| | / ____ \| | \__ \ |_
# /_/ \_\_|\__,_|\___/ \__, |\__,_| /_/ \_\_|_|___/\__|
# __/ |
# |___/
#
# Copyright (c) 2024 DDSRem <https://blog.ddsrem.com>
#
# This is free software, licensed under the GNU General Public License v3.0.
#
# ——————————————————————————————————————————————————————————————————————————————————
#
DATE_VERSION="v1.0.2-2024_04_13_20_37"
#
# ——————————————————————————————————————————————————————————————————————————————————
Sky_Blue="\e[36m"
Blue="\033[34m"
Green="\033[32m"
Red="\033[31m"
Yellow='\033[33m'
Font="\033[0m"
INFO="[${Green}INFO${Font}]"
ERROR="[${Red}ERROR${Font}]"
WARN="[${Yellow}WARN${Font}]"
function INFO() {
echo -e "${INFO} ${1}"
}
function ERROR() {
echo -e "${ERROR} ${1}"
}
function WARN() {
echo -e "${WARN} ${1}"
}
function sedsh() {
if [[ "$(uname -s)" = "Darwin" ]]; then
sed -i '' "$@"
else
sed -i "$@"
fi
}
function get_dev_dri() {
if [ "${dev_dri}" == "no" ]; then
echo -e "${Red}关闭${Font}"
elif [ "${dev_dri}" == "yes" ]; then
echo -e "${Green}开启${Font}"
else
echo -e "${Red}错误${Font}"
fi
}
function set_dev_dri() {
if [ "${dev_dri}" == "no" ]; then
new_dev_dri=yes
elif [ "${dev_dri}" == "yes" ]; then
new_dev_dri=no
else
new_dev_dri=no
fi
sedsh "s/dev_dri=.*/dev_dri=${new_dev_dri}/" "${config_dir}/emby_config.txt"
}
function set_mode() {
if [ "${mode}" == "bridge" ]; then
new_mode=host
elif [ "${mode}" == "host" ]; then
new_mode=bridge
else
new_mode=host
fi
sedsh "s/mode=.*/mode=${new_mode}/" "${config_dir}/emby_config.txt"
}
function set_image() {
if [ "${image}" == "emby" ]; then
new_image=amilys
elif [ "${image}" == "amilys" ]; then
new_image=emby
else
new_image=emby
fi
sedsh "s/image=.*/image=${new_image}/" "${config_dir}/emby_config.txt"
}
function set_version() {
if [ "${version}" == "4.8.9.0" ]; then
new_version=latest
elif [ "${version}" == "latest" ]; then
new_version=4.8.9.0
else
new_version=4.8.9.0
fi
sedsh "s/version=.*/version=${new_version}/" "${config_dir}/emby_config.txt"
}
function get_media_dir() {
if [ "$media_dir" != "" ]; then
OLD_MEDIA_DIR=${media_dir}
INFO "已读取媒体库目录:${OLD_MEDIA_DIR} (默认不更改回车继续,如果需要更改请输入新路径)"
read -erp "MEDIA_DIR:" MEDIA_DIR
[[ -z "${MEDIA_DIR}" ]] && MEDIA_DIR=${OLD_MEDIA_DIR}
sedsh "s#media_dir=.*#media_dir=${MEDIA_DIR}#" "${config_dir}/emby_config.txt"
else
INFO "请输入媒体库目录(默认 /media )"
read -erp "MEDIA_DIR:" MEDIA_DIR
[[ -z "${MEDIA_DIR}" ]] && MEDIA_DIR="/media"
sedsh "s#media_dir=.*#media_dir=${MEDIA_DIR}#" "${config_dir}/emby_config.txt"
fi
}
function get_resilio() {
if [ "${resilio}" == "no" ]; then
echo -e "${Red}否${Font}"
elif [ "${resilio}" == "yes" ]; then
echo -e "${Green}是${Font}"
else
echo -e "${Red}错误${Font}"
fi
}
function set_resilio() {
if [ "${resilio}" == "no" ]; then
new_resilio=yes
elif [ "${resilio}" == "yes" ]; then
new_resilio=no
else
new_resilio=no
fi
sedsh "s/resilio=.*/resilio=${new_resilio}/" "${config_dir}/emby_config.txt"
}
function main_return() {
# shellcheck disable=SC1091
source "${config_dir}/emby_config.txt"
cat /tmp/xiaoya_alist
echo -e "1、开启/关闭硬解GPU映射 当前配置:$(get_dev_dri)"
echo -e "2、Emby容器网络模式 当前配置:${Sky_Blue}${mode}模式${Font}"
echo -e "3、Emby镜像 当前配置:${Sky_Blue}${image}${Font}"
echo -e "4、Emby镜像版 当前配置:${Sky_Blue}${version}${Font}"
echo -e "5、媒体库路径 当前配置:${Sky_Blue}${media_dir}${Font}"
echo -e "6、是否安装Resilio 当前配置:$(get_resilio)"
echo -e "0、退出脚本 | Script info: ${DATE_VERSION} Thanks: ${Blue}xiaoyaLiu${Font}"
echo -e "——————————————————————————————————————————————————————————————————————————————————"
read -erp "请输入数字 [0-6]:" num
case "$num" in
1)
set_dev_dri
clear
main_return
;;
2)
set_mode
clear
main_return
;;
3)
set_image
clear
main_return
;;
4)
set_version
clear
main_return
;;
5)
clear
get_media_dir
clear
main_return
;;
6)
set_resilio
clear
main_return
;;
0)
clear
exit 0
;;
*)
clear
ERROR '请输入正确数字 [0-6]'
main_return
;;
esac
}
clear
if [[ $EUID -ne 0 ]]; then
ERROR '此脚本必须以 root 身份运行!'
exit 1
fi
if [[ "$(uname -s)" = "Darwin" ]]; then
stty -icanon
fi
if [ ! "$1" ]; then
ERROR "未设置xiaoya配置目录"
exit 1
fi
config_dir=${1}
if [ ! -d "${config_dir}" ]; then
mkdir -p "${config_dir}"
fi
find "${config_dir}" -type f -name "*.txt" -exec sed -i "s/\r$//g" {} \;
if [ ! -s "${config_dir}/emby_config.txt" ]; then
{
echo "dev_dri=no"
echo "mode=host"
echo "image=emby"
echo "media_dir="
echo "resilio=no"
echo "version=4.8.9.0"
} >> "${config_dir}/emby_config.txt"
else
# shellcheck disable=SC1091
source "${config_dir}/emby_config.txt"
if [ -z "${dev_dri}" ]; then
echo "dev_dri=no" >> "${config_dir}/emby_config.txt"
fi
if [ -z "${mode}" ]; then
echo "mode=host" >> "${config_dir}/emby_config.txt"
fi
if [ -z "${image}" ]; then
echo "image=emby" >> "${config_dir}/emby_config.txt"
fi
if [ -z "${media_dir}" ]; then
echo "media_dir=" >> "${config_dir}/emby_config.txt"
fi
if [ -z "${resilio}" ]; then
echo "resilio=no" >> "${config_dir}/emby_config.txt"
fi
if [ -z "${version}" ]; then
echo "version=4.8.9.0" >> "${config_dir}/emby_config.txt"
fi
fi
if [ -f /tmp/xiaoya_alist ]; then
rm -rf /tmp/xiaoya_alist
fi
if ! curl -sL https://ddsrem.com/xiaoya/xiaoya_alist -o /tmp/xiaoya_alist; then
if ! curl -sL https://cdn.jsdelivr.net/gh/DDS-Derek/xiaoya-alist@latest/xiaoya_alist -o /tmp/xiaoya_alist; then
curl -sL https://raw.githubusercontent.com/DDS-Derek/xiaoya-alist/master/xiaoya_alist -o /tmp/xiaoya_alist
fi
fi
main_return