forked from Aliang-code/automatic-theater-jellyfin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·131 lines (117 loc) · 4.02 KB
/
install.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
#!/bin/bash
#
# https://github.com/LuckyPuppy514/automatic-theater/install.sh
# 作者:LuckyPuppy514
# 时间:2022-08-25
#
# 本脚本用于安装 automatic-theater
#
set -e
echo "|------------------------------------------------------|"
echo "| |"
echo "| Automatic Theater |"
echo "| https://github.com/LuckyPuppy514/automatic-theater |"
echo "| |"
echo "|------------------------------------------------------|"
echo ""
echo "|------------------------------------------------------|"
echo "| 当前配置如下 |"
echo "|------------------------------------------------------|"
cat ./docker-compose-default.env
echo "|------------------------------------------------------|"
echo ""
echo "确认信息,并继续执行?(是:y,否:n):"
read CONFIRM
YES=y
if [[ "${CONFIRM}" == "${YES}" ]]; then
echo ""
else
echo "取消并退出"
exit
fi
. ./docker-compose-default.env
compose_file=docker-compose-default.yml
macvlan=$(docker network ls|grep "${macvlan_name}"|awk -F' ' '{print $2}')
if [[ "${macvlan}" ]]; then
if [[ "${qbittorrent_ip}" ]]; then
echo "✅ 已检测到macvlan网络,将使用 ${macvlan} 创建qBittorrent,IP:${qbittorrent_ip}"
compose_file=docker-compose-macvlan.yml
else
echo "✖️ 未指定macvlan下qBittorrent的IP,请设定 qbittorrent_ip 变量"
exit
fi
else
echo "✖️ 未检测到macvlan网络,qBittorrent可能会占用代理流量"
echo " macvlan网络创建示例:docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 -o parent=eth0 macvlan_direct"
fi
sudo cp ./${compose_file} ./docker-compose.yml
sudo chown -R ${USERNAME}:${GROUPNAME} ./docker-compose.yml
sudo chmod -R 770 ./docker-compose.yml
if [[ "${macvlan}" ]]; then
sudo sed -i "s/macvlan_name/${macvlan}/g" ./docker-compose.yml
fi
echo ""
echo "开始创建目录 ......"
if [[ ! -d ${MEDIA_PATH} ]]; then
sudo mkdir -p ${MEDIA_PATH}
echo "✅ 创建目录成功:${MEDIA_PATH}"
fi
if [[ ! -d ${MEDIA_PATH}/movie ]]; then
sudo mkdir ${MEDIA_PATH}/movie
echo "✅ 创建目录成功:${MEDIA_PATH}/movie"
fi
if [[ ! -d ${MEDIA_PATH}/serial ]]; then
sudo mkdir ${MEDIA_PATH}/serial
echo "✅ 创建目录成功:${MEDIA_PATH}/serial"
fi
if [[ ! -d ${MEDIA_PATH}/anime ]]; then
sudo mkdir ${MEDIA_PATH}/anime
echo "✅ 创建目录成功:${MEDIA_PATH}/anime"
fi
if [[ ! -d ${MEDIA_PATH}/download ]]; then
sudo mkdir ${MEDIA_PATH}/download
echo "✅ 创建目录成功:${MEDIA_PATH}/download"
fi
if [[ ! -d ${MEDIA_PATH}/other ]]; then
sudo mkdir ${MEDIA_PATH}/other
echo "✅ 创建目录成功:${MEDIA_PATH}/other"
fi
echo "✅ 创建目录成功"
echo ""
echo "修改目录权限 ......"
sudo chown -R ${USERNAME}:${GROUPNAME} ${MEDIA_PATH}
sudo chmod -R 770 ${MEDIA_PATH}
echo "✅ 修改媒体目录权限成功"
echo "|"
echo "|------------------------------------------------------|"
echo "| 当前目录结构 |"
echo "|------------------------------------------------------|"
ls -l ${MEDIA_PATH}
echo "|------------------------------------------------------|"
echo ""
echo "生成环境变量 ......"
sudo cp ./docker-compose-default.env ./.env
echo "✅ 生成环境变量成功"
workdir=$(pwd)
echo ""
echo "修改目录权限 ......"
sudo chown -R ${USERNAME}:${GROUPNAME} $workdir
sudo chmod -R 770 $workdir
echo "✅ 修改 $(workdir) 目录权限成功"
echo ""
echo "添加显卡配置 ......"
DEVICE=""
if [[ -d "/dev/dri" ]]; then
DEVICE="/dev/dri:/dev/dri"
fi
if [[ -d "/dev/vchiq" ]]; then
DEVICE="/dev/vchiq:/dev/vchiq"
fi
if [[ ${DEVICE} ]]; then
sudo echo " devices:" >> ./docker-compose.yml
sudo echo " - ${DEVICE}" >> ./docker-compose.yml
echo "✅ 添加硬件加速设备成功"
else
echo "✖️ 未检测到 /dev/dri 或 /dev/vchiq,无法为 Jellyfin 添加硬件加速设备"
fi
echo "✅ 程序执行完毕 ✅"