mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-07 01:18:16 +02:00
Rename addons_updater/rootfs/etc/system.d/run to addons_updater/rootfs/etc/cont-init.d/run
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
bashio::log.info "Checking status of referenced repositoriess..."
|
||||
|
||||
#Defining github values
|
||||
bashio::log.info "... github authentification"
|
||||
GITUSER=$(bashio::config 'gituser')
|
||||
GITPASS=$(bashio::config 'gitpass')
|
||||
GITMAIL=$(bashio::config 'gitemail')
|
||||
git config --system http.sslVerify false
|
||||
git config --system credential.helper 'cache --timeout 7200'
|
||||
git config --system user.name ${GITUSER}
|
||||
git config --system user.password ${GITPASS}
|
||||
git config --system user.email ${GITMAIL}
|
||||
|
||||
bashio::log.info "... parse addons"
|
||||
for addons in $(bashio::config "addon|keys"); do
|
||||
SLUG=$(bashio::config "addon[${addons}].slug")
|
||||
REPOSITORY=$(bashio::config "addon[${addons}].repository")
|
||||
UPSTREAM=$(bashio::config "addon[${addons}].upstream")
|
||||
BETA=$(bashio::config "addon[${addons}].beta")
|
||||
BASENAME=$(basename "https://github.com/$REPOSITORY")
|
||||
|
||||
#Update local version
|
||||
bashio::log.info "... $SLUG : cloning ${REPOSITORY}"
|
||||
cd /
|
||||
git clone "https://github.com/${REPOSITORY}" || cd "/${BASENAME}" && git fetch --all && git reset --hard origin/master
|
||||
|
||||
#Define the folder addon
|
||||
bashio::log.info "... $SLUG : checking slug exists in repo"
|
||||
cd /${BASENAME}/${SLUG} || bashio::log.error "$SLUG addon not found in this repository. Exiting." exit
|
||||
|
||||
#Find current version
|
||||
bashio::log.info "... $SLUG : get current version"
|
||||
CURRENT=$(jq .version config.json) || bashio::log.error "$SLUG addon version in config.json not found. Exiting." exit
|
||||
|
||||
#If beta flag, select beta version
|
||||
if [ ${BETA} = true ]; then
|
||||
bashio::log.info "... $SLUG : beta is on"
|
||||
LASTVERSION=$(lastversion --pre "https://github.com/$UPSTREAM" --format tag)
|
||||
else
|
||||
bashio::log.info "... $SLUG : beta is off"
|
||||
LASTVERSION=$(lastversion "https://github.com/$UPSTREAM" --format tag)
|
||||
fi
|
||||
|
||||
if [ ${CURRENT} != ${LASTVERSION} ]; then
|
||||
bashio::log.info "... $SLUG : update from $CURRENT to $LASTVERSION"
|
||||
|
||||
|
||||
#Change all instances of version
|
||||
bashio::log.info "... $SLUG : updating files"
|
||||
|
||||
files=$(grep -rl '"'${CURRENT}'"' /${BASENAME}/${SLUG}) && echo $files | xargs sed -i 's/"'${CURRENT}'"/"'${LASTVERSION}'"/g'
|
||||
|
||||
if [ $files != "" ]; then
|
||||
git commit -m "Bot update to $CURRENT" $files || true
|
||||
|
||||
#Git commit and push
|
||||
bashio::log.info "... $SLUG : push to master"
|
||||
git remote set-url origin "https://${GITUSER}:${GITPASS}@github.com/${REPOSITORY}" | echo
|
||||
git push | echo "No changes"
|
||||
|
||||
#Update the current flag
|
||||
bashio::log.info "... $SLUG : updating current flag"
|
||||
sed -i "s/${CURRENT}/${LASTVERSION}/g" /data/options.json
|
||||
|
||||
#Log
|
||||
bashio::log.info "... $SLUG : updated and published"
|
||||
else
|
||||
bashio::log.info "... $SLUG : couldn't update, please check the current version"
|
||||
fi
|
||||
|
||||
else
|
||||
bashio::log.info "Addon $SLUG is already up-to-date."
|
||||
fi
|
||||
done
|
||||
exit
|
||||
Reference in New Issue
Block a user