-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMusicAssistant
executable file
·55 lines (30 loc) · 1.26 KB
/
MusicAssistant
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
#!/bin/bash
# Add the HA user if it doesn't exist
container_name="MusicAssistant"
useradd $container_name || echo "User already exists."
# create the ha directory for the docker volumes if it doesn't exist
if [ ! -d /home/$container_name ];then
if ! mkdir /home/$container_name; then # Shorter version. Shell will complain if you p>
echo "Can't make dir: $container_name"
fi
fi
# Create the media directory if it doesn't exist
MediaDir=/media2/$container_name
if [ ! -d $MediaDir ];then
if ! mkdir $MediaDir; then # Shorter version. Shell will complain if you p>
echo "Can't make dir: $MediaDir"
fi
fi
# Now see if the container is running already
if [ "$(docker ps -q -f name=$container_name)" ]; then
echo "Container $container_name is running, nothing to do"
else
# if the container isn't running, remove it and issue the run again
echo "Container $container_name is not running."
if [ "!$(docker container inspect $container_name > /dev/null 2>&1)" ]; then
echo "$container_name is not running $(docker rm $container_name)"
# start the container
docker run -d --restart=always -p 8095:8095 -v $MediaDir/data:/data \
--name $container_name ghcr.io/music-assistant/server
fi
fi