root folder creation

This commit is contained in:
Youe Graillot 2022-07-15 14:22:04 +02:00
parent a5ef6efd4d
commit f31106e1db
4 changed files with 51 additions and 47 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
config/ config/
config_deemix/ config_deemix/
downloads/ downloads/
music/

View File

@ -5,10 +5,6 @@ services:
image: lidarr-onsteroids image: lidarr-onsteroids
build: build:
context: . context: .
environment:
- PUID=1000
- PGID=100
- AUTOCONFIG=true
ports: ports:
- "8686:8686" - "8686:8686"
- "6595:6595" - "6595:6595"
@ -16,4 +12,5 @@ services:
- ./config:/config - ./config:/config
- ./config_deemix:/config_deemix - ./config_deemix:/config_deemix
- ./downloads:/downloads - ./downloads:/downloads
- ./music:/music
restart: unless-stopped restart: unless-stopped

View File

@ -4,6 +4,8 @@ LABEL maintainer="youegraillot"
ENV DEEMIX_SINGLE_USER=true ENV DEEMIX_SINGLE_USER=true
ENV AUTOCONFIG=true ENV AUTOCONFIG=true
ENV PUID=1000
ENV PGID=1000
# flac2mp3 # flac2mp3
COPY lidarr-flac2mp3/root/usr /usr COPY lidarr-flac2mp3/root/usr /usr
@ -13,9 +15,9 @@ RUN apk add --no-cache ffmpeg && \
# deemix # deemix
COPY --from=registry.gitlab.com/bockiii/deemix-docker:latest /deemix-server /deemix-server COPY --from=registry.gitlab.com/bockiii/deemix-docker:latest /deemix-server /deemix-server
RUN chmod +x /deemix-server RUN chmod +x /deemix-server
VOLUME [ "/config_deemix" "/downloads" ] VOLUME "/config_deemix" "/downloads"
EXPOSE 6595 EXPOSE 6595
COPY root / COPY root /
VOLUME "/config" VOLUME "/config" "/music"
EXPOSE 6595 8686 EXPOSE 6595 8686

View File

@ -1,6 +1,26 @@
#!/usr/bin/with-contenv sh #!/usr/bin/with-contenv sh
# shellcheck shell=sh # shellcheck shell=sh
url="http://localhost:8686"
urlPlugin="https://github.com/ta264/Lidarr.Plugin.Deemix"
# string, route
isPresent() {
apiCall "GET" "$2" | grep -q "$1"
}
# method, route, payload
apiCall() {
curl \
-s \
-X "$1" \
-H "Content-Type: application/json" \
-H "X-Api-Key: $apiKey" \
-d "$3" \
$url/api/v1/"$2"
return 0
}
echo " echo "
---------------------------------------------------------------------- ----------------------------------------------------------------------
Flac2MP3 SETUP Flac2MP3 SETUP
@ -24,66 +44,50 @@ echo "
---------------------------------------------------------------------- ----------------------------------------------------------------------
LIDARR SETUP LIDARR SETUP
---------------------------------------------------------------------- ----------------------------------------------------------------------
Source=$urlPlugin PluginSource=$urlPlugin
---------------------------------------------------------------------- ----------------------------------------------------------------------
" "
url="http://localhost:8686"
urlPlugin="https://github.com/ta264/Lidarr.Plugin.Deemix"
# string, route
isPresent() {
apiCall "GET" "$2" | grep -q "$1"
}
# method, route, payload
apiCall() {
curl \
-sS \
-X "$1" \
-H "Content-Type: application/json" \
-H "X-Api-Key: $apiKey" \
-d "$3" \
$url/api/v1/"$2"
return 0
}
apiKey="$(curl \
-sS \
--retry-all-errors \
--retry 10 \
$url/initialize.js |
sed -n "s/apiKey: '\(.*\)'.*/\1/p")"
if isPresent $urlPlugin "system/plugins"; then
echo "Plugin already installed"
else
echo "Installing plugin"
apiCall "POST" "command" '{"name":"InstallPlugin","githubUrl":"'$urlPlugin'"}'
fi
if [ "$AUTOCONFIG" = "true" ]; then if [ "$AUTOCONFIG" = "true" ]; then
echo "[autoconfig] Waiting Lidarr to launch on 8686..."
while ! nc -z localhost 8686; do
sleep 0.1
done
apiKey="$(curl \
-sS \
--retry-all-errors \
--retry 10 \
$url/initialize.js |
sed -n "s/apiKey: '\(.*\)'.*/\1/p")"
if ! isPresent $urlPlugin "system/plugins"; then
echo "[autoconfig] Installing plugin"
apiCall "POST" "command" '{"name":"InstallPlugin","githubUrl":"'$urlPlugin'"}'
fi
if ! isPresent "path" "rootFolder"; then
echo "[autoconfig] Setting /music rootFolder"
apiCall "POST" "rootFolder" '{"defaultTags":[],"defaultQualityProfileId":1,"defaultMetadataProfileId":1,"path":"/music","name":"Music"}'
fi
loginPath="/config_deemix/login.json" loginPath="/config_deemix/login.json"
echo "Waiting for $loginPath to be filled..." echo "[autoconfig] Waiting for $loginPath to be filled..."
while [ -z "$arl" ]; do while [ -z "$arl" ]; do
sleep 1 sleep 1
arl=$(sed -n 's/.*arl.*"\(.*\)"/\1/p' "$loginPath" 2>/dev/null) arl=$(sed -n 's/.*arl.*"\(.*\)"/\1/p' "$loginPath" 2>/dev/null)
done done
if [ "$(apiCall "GET" "delayprofile" | jq .[0].items[2].allowed)" = "false" ]; then if [ "$(apiCall "GET" "delayprofile" | jq .[0].items[2].allowed)" = "false" ]; then
echo "Allowing Deemix in default delay profile" echo "[autoconfig] Allowing Deemix in default delay profile"
apiCall "PUT" "delayprofile/1" \ apiCall "PUT" "delayprofile/1" \
'{"name":"Default","items":[{"name":"Usenet","protocol":"UsenetDownloadProtocol","allowed":true,"delay":0},{"name":"Torrent","protocol":"TorrentDownloadProtocol","allowed":true,"delay":0},{"name":"Deemix","protocol":"DeemixDownloadProtocol","allowed":true,"delay":0}],"tags":[],"id":1}' '{"name":"Default","items":[{"name":"Usenet","protocol":"UsenetDownloadProtocol","allowed":true,"delay":0},{"name":"Torrent","protocol":"TorrentDownloadProtocol","allowed":true,"delay":0},{"name":"Deemix","protocol":"DeemixDownloadProtocol","allowed":true,"delay":0}],"tags":[],"id":1}'
fi fi
if ! isPresent "Deemix" "indexer"; then if ! isPresent "Deemix" "indexer"; then
loginPath="/config_deemix/login.json" loginPath="/config_deemix/login.json"
echo "Updating indexer" echo "[autoconfig] Updating indexer"
apiCall "POST" "indexer" \ apiCall "POST" "indexer" \
'{"enableRss":true,"enableAutomaticSearch":true,"enableInteractiveSearch":true,"supportsRss":true,"supportsSearch":true,"protocol":"DeemixDownloadProtocol","priority":25,"downloadClientId":0,"name":"Deemix","fields":[{"name":"baseUrl","value":"http://localhost:6595"},{"name":"arl","value":"'"$arl"'"},{"name":"earlyReleaseLimit"}],"implementationName":"Deemix","implementation":"Deemix","configContract":"DeemixIndexerSettings","infoLink":"https://wiki.servarr.com/lidarr/supported#deemix","tags":[]}' '{"enableRss":true,"enableAutomaticSearch":true,"enableInteractiveSearch":true,"supportsRss":true,"supportsSearch":true,"protocol":"DeemixDownloadProtocol","priority":25,"downloadClientId":0,"name":"Deemix","fields":[{"name":"baseUrl","value":"http://localhost:6595"},{"name":"arl","value":"'"$arl"'"},{"name":"earlyReleaseLimit"}],"implementationName":"Deemix","implementation":"Deemix","configContract":"DeemixIndexerSettings","infoLink":"https://wiki.servarr.com/lidarr/supported#deemix","tags":[]}'
fi fi
if ! isPresent "Deemix" "downloadclient"; then if ! isPresent "Deemix" "downloadclient"; then
echo "Updating download client" echo "[autoconfig] Updating download client"
apiCall "POST" "downloadclient" \ apiCall "POST" "downloadclient" \
'{"enable":true,"protocol":"DeemixDownloadProtocol","priority":1,"removeCompletedDownloads":true,"removeFailedDownloads":true,"name":"Deemix","fields":[{"name":"host","value":"localhost"},{"name":"port","value":6595},{"name":"urlBase"},{"name":"useSsl","value":false},{"name":"arl","value":"'"$arl"'"}],"implementationName":"Deemix","implementation":"Deemix","configContract":"DeemixSettings","infoLink":"https://wiki.servarr.com/lidarr/supported#deemix","tags":[]}' '{"enable":true,"protocol":"DeemixDownloadProtocol","priority":1,"removeCompletedDownloads":true,"removeFailedDownloads":true,"name":"Deemix","fields":[{"name":"host","value":"localhost"},{"name":"port","value":6595},{"name":"urlBase"},{"name":"useSsl","value":false},{"name":"arl","value":"'"$arl"'"}],"implementationName":"Deemix","implementation":"Deemix","configContract":"DeemixSettings","infoLink":"https://wiki.servarr.com/lidarr/supported#deemix","tags":[]}'
fi fi
echo "Configuration is up to date" echo "[autoconfig] Configuration is up to date"
fi fi