|
@@ -1,17 +1,20 @@
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
-# Blank portainer template (32 and 64 bits)
|
|
|
|
-json32='{"version":"2","templates":[]}'
|
|
|
|
-json64='{"version":"2","templates":[]}'
|
|
|
|
|
|
+# Blank portainer templates
|
|
|
|
+json_arm32='{"version":"2","templates":[]}'
|
|
|
|
+json_arm64='{"version":"2","templates":[]}'
|
|
|
|
+json_amd64='{"version":"2","templates":[]}'
|
|
|
|
|
|
# File variables
|
|
# File variables
|
|
appinfo='build/info.json'
|
|
appinfo='build/info.json'
|
|
-Oldtemplate32='pi-hosted_template/template/portainer-v2.json'
|
|
|
|
-template32='template/portainer-v2-arm32.json'
|
|
|
|
-template64='template/portainer-v2-arm64.json'
|
|
|
|
|
|
+Oldtemplate_arm32='pi-hosted_template/template/portainer-v2.json'
|
|
|
|
+template_arm32='template/portainer-v2-arm32.json'
|
|
|
|
+template_arm64='template/portainer-v2-arm64.json'
|
|
|
|
+template_amd64='template/portainer-v2-amd64.json'
|
|
|
|
|
|
# App info
|
|
# App info
|
|
repo='https://github.com/pi-hosted/pi-hosted/blob/master/'
|
|
repo='https://github.com/pi-hosted/pi-hosted/blob/master/'
|
|
|
|
+rawrepo='https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/'
|
|
header='<h3>Template created by Pi-Hosted Series</h3><b>Check our Github page: <a href="https://github.com/pi-hosted/pi-hosted" target="_blank">https://github.com/pi-hosted/pi-hosted</a></b><br>'
|
|
header='<h3>Template created by Pi-Hosted Series</h3><b>Check our Github page: <a href="https://github.com/pi-hosted/pi-hosted" target="_blank">https://github.com/pi-hosted/pi-hosted</a></b><br>'
|
|
|
|
|
|
# Run script from base directory
|
|
# Run script from base directory
|
|
@@ -56,13 +59,16 @@ for app in template/apps/*.json; do
|
|
unset PHDoc
|
|
unset PHDoc
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
+ # Pre-Install Script
|
|
if Script=$( echo "$appjson" | jq -e '.preInstallScript' ) ; then
|
|
if Script=$( echo "$appjson" | jq -e '.preInstallScript' ) ; then
|
|
- Script="<br><b>Pre-installation script must be RAN before you install: </b><a href=\"${repo}tools/${Script:1:-1}\" target=\"_blank\">${Script:1:-1}</a>"
|
|
|
|
|
|
+ scriptexec=$( jq '.tools[] | select(.File=='"$Script"') | .Exec' "$appinfo" )
|
|
|
|
+ Script="<br><b><a href=\"${repo}tools/${Script:1:-1}\" target=\"_blank\">Pre-installation script</a> must be RAN before you install: </b>wget -qO- ${rawrepo}tools/${Script:1:-1} | ${scriptexec:1:-1}"
|
|
appjson=$( echo "$appjson" | jq 'del(.preInstallScript)' )
|
|
appjson=$( echo "$appjson" | jq 'del(.preInstallScript)' )
|
|
else
|
|
else
|
|
unset Script
|
|
unset Script
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
+ # Youtube Video
|
|
if VideoID=$( echo "$appjson" | jq -e '.videoID' ) ; then
|
|
if VideoID=$( echo "$appjson" | jq -e '.videoID' ) ; then
|
|
VideoURL=$( jq '.youtube[] | select(.ID=='"$VideoID"') | .URL' "$appinfo" )
|
|
VideoURL=$( jq '.youtube[] | select(.ID=='"$VideoID"') | .URL' "$appinfo" )
|
|
VideoTitle=$( jq '.youtube[] | select(.ID=='"$VideoID"') | .Title' "$appinfo" | tr -d '"')
|
|
VideoTitle=$( jq '.youtube[] | select(.ID=='"$VideoID"') | .Title' "$appinfo" | tr -d '"')
|
|
@@ -72,6 +78,7 @@ for app in template/apps/*.json; do
|
|
unset VideoID VideoURL
|
|
unset VideoID VideoURL
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
+ # Extra Scripts
|
|
if ExtraScript=$( echo "$appjson" | jq -e '.extraScript' ) ; then
|
|
if ExtraScript=$( echo "$appjson" | jq -e '.extraScript' ) ; then
|
|
appjson=$( echo "$appjson" | jq 'del(.extraScript)' )
|
|
appjson=$( echo "$appjson" | jq 'del(.extraScript)' )
|
|
# If only one entry
|
|
# If only one entry
|
|
@@ -98,8 +105,9 @@ for app in template/apps/*.json; do
|
|
appjson=$( echo "$appjson" | jq --arg n "$note" '.note = $n' )
|
|
appjson=$( echo "$appjson" | jq --arg n "$note" '.note = $n' )
|
|
|
|
|
|
# Splitting into 32 and 64 bit jsons
|
|
# Splitting into 32 and 64 bit jsons
|
|
- appjson32=$appjson
|
|
|
|
- appjson64=$appjson
|
|
|
|
|
|
+ appjson_arm32=$appjson
|
|
|
|
+ appjson_arm64=$appjson
|
|
|
|
+ appjson_amd64=$appjson
|
|
|
|
|
|
# Check if app is to be applied to all (no arch identified)
|
|
# Check if app is to be applied to all (no arch identified)
|
|
# If there is no indication of architecture (32 or 64) on image or stackfile keys
|
|
# If there is no indication of architecture (32 or 64) on image or stackfile keys
|
|
@@ -107,47 +115,65 @@ for app in template/apps/*.json; do
|
|
# else apply specific image/stackfile to indicated architecture
|
|
# else apply specific image/stackfile to indicated architecture
|
|
if ! echo "$appjson" | grep -qE '"(image|stackfile)":' ; then
|
|
if ! echo "$appjson" | grep -qE '"(image|stackfile)":' ; then
|
|
|
|
|
|
- # Parsing 32 bit apps (check if there is an image32 or stackfile32)
|
|
|
|
- if echo "$appjson32" | grep -qE '"(image|stackfile)32":' ; then
|
|
|
|
- # Remove 64 bit info
|
|
|
|
- appjson32=$( echo "$appjson32" | sed -E 's/"(image|stackfile)32":/"\1":/' )
|
|
|
|
|
|
+ # Parsing arm 32 bit apps (check if there is an image32 or stackfile32)
|
|
|
|
+ if echo "$appjson_arm32" | grep -qE '"(image|stackfile)_arm32":' ; then
|
|
|
|
+ # Rename key
|
|
|
|
+ appjson_arm32=$( echo "$appjson_arm32" | sed -E 's/"(image|stackfile)_arm32":/"\1":/' )
|
|
else
|
|
else
|
|
# App does not contain 32bit template
|
|
# App does not contain 32bit template
|
|
- unset appjson32
|
|
|
|
|
|
+ unset appjson_arm32
|
|
fi
|
|
fi
|
|
|
|
|
|
- # Parsing 64 bit apps
|
|
|
|
- if echo "$appjson64" | grep -qE '"(image|stackfile)64":' ; then
|
|
|
|
- appjson64=$( echo "$appjson64" | sed -E 's/"(image|stackfile)64":/"\1":/' )
|
|
|
|
|
|
+ # Parsing arm 64 bit apps
|
|
|
|
+ if echo "$appjson_arm64" | grep -qE '"(image|stackfile)_arm64":' ; then
|
|
|
|
+ # Rename key
|
|
|
|
+ appjson_arm64=$( echo "$appjson_arm64" | sed -E 's/"(image|stackfile)_arm64":/"\1":/' )
|
|
else
|
|
else
|
|
# App does not contain 64bit template
|
|
# App does not contain 64bit template
|
|
- unset appjson64
|
|
|
|
|
|
+ unset appjson_arm64
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ # Parsing amd 64 bit apps
|
|
|
|
+ if echo "$appjson_amd64" | grep -qE '"(image|stackfile)_amd64":' ; then
|
|
|
|
+ # Rename key
|
|
|
|
+ appjson_amd64=$( echo "$appjson_amd64" | sed -E 's/"(image|stackfile)_amd64":/"\1":/' )
|
|
|
|
+ else
|
|
|
|
+ # App does not contain 64bit template
|
|
|
|
+ unset appjson_amd64
|
|
fi
|
|
fi
|
|
|
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
- # Appending to json32
|
|
|
|
- if [[ -n "$appjson32" ]]; then
|
|
|
|
|
|
+ # Appending to json_arm32
|
|
|
|
+ if [[ -n "$appjson_arm32" ]]; then
|
|
|
|
+ # Cleaning App json before adding to template
|
|
|
|
+ appjson_arm32=$( echo "$appjson_arm32" | jq 'del(.image_arm32, .image_arm64, .image_amd64, .repository.stackfile_arm32, .repository.stackfile_arm64, .repository.stackfile_amd64)')
|
|
|
|
+ json_arm32=$( echo "$json_arm32" | jq --argjson newApp "$appjson_arm32" '.templates += [$newApp]' )
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ # Appending to json_arm64
|
|
|
|
+ if [[ -n "$appjson_arm64" ]]; then
|
|
# Cleaning App json before adding to template
|
|
# Cleaning App json before adding to template
|
|
- appjson32=$( echo "$appjson32" | jq 'del(.image32, .image64, .repository.stackfile32, .repository.stackfile64)')
|
|
|
|
- json32=$( echo "$json32" | jq --argjson newApp "$appjson32" '.templates += [$newApp]' )
|
|
|
|
|
|
+ appjson_arm64=$( echo "$appjson_arm64" | jq 'del(.image_arm32, .image_arm64, .image_amd64, .repository.stackfile_arm32, .repository.stackfile_arm64, .repository.stackfile_amd64)')
|
|
|
|
+ json_arm64=$( echo "$json_arm64" | jq --argjson newApp "$appjson_arm64" '.templates += [$newApp]' )
|
|
fi
|
|
fi
|
|
|
|
|
|
- # Appending to json64
|
|
|
|
- if [[ -n "$appjson64" ]]; then
|
|
|
|
|
|
+ # Appending to json_amd64
|
|
|
|
+ if [[ -n "$appjson_amd64" ]]; then
|
|
# Cleaning App json before adding to template
|
|
# Cleaning App json before adding to template
|
|
- appjson64=$( echo "$appjson64" | jq 'del(.image32, .image64, .repository.stackfile32, .repository.stackfile64)')
|
|
|
|
- json64=$( echo "$json64" | jq --argjson newApp "$appjson64" '.templates += [$newApp]' )
|
|
|
|
|
|
+ appjson_amd64=$( echo "$appjson_amd64" | jq 'del(.image_arm32, .image_arm64, .image_amd64, .repository.stackfile_arm32, .repository.stackfile_arm64, .repository.stackfile_amd64)')
|
|
|
|
+ json_amd64=$( echo "$json_amd64" | jq --argjson newApp "$appjson_amd64" '.templates += [$newApp]' )
|
|
fi
|
|
fi
|
|
|
|
|
|
# clean variables before next loop
|
|
# clean variables before next loop
|
|
- unset appjson32 appjson64 note
|
|
|
|
|
|
+ unset appjson_arm32 appjson_arm64 appjson_amd64 note
|
|
done
|
|
done
|
|
|
|
|
|
# Create Templates
|
|
# Create Templates
|
|
-echo "$json32" | jq --tab '.templates |= sort_by(.title | ascii_upcase)' > "$template32"
|
|
|
|
-echo "$json64" | jq --tab '.templates |= sort_by(.title | ascii_upcase)' > "$template64"
|
|
|
|
|
|
+echo "$json_arm32" | jq --tab '.templates |= sort_by(.title | ascii_upcase)' > "$template_arm32"
|
|
|
|
+echo "$json_arm64" | jq --tab '.templates |= sort_by(.title | ascii_upcase)' > "$template_arm64"
|
|
|
|
+echo "$json_amd64" | jq --tab '.templates |= sort_by(.title | ascii_upcase)' > "$template_amd64"
|
|
|
|
|
|
# Keep old template up to date
|
|
# Keep old template up to date
|
|
-cp -f "$template32" "$Oldtemplate32"
|
|
|
|
|
|
+cp -f "$template_arm32" "$Oldtemplate_arm32"
|