update act runner addons
This commit is contained in:
		
							
								
								
									
										45
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example1/finish
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example1/finish
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
#!/command/with-contenv bashio
 | 
			
		||||
# shellcheck shell=bash
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
# Home Assistant Community Add-on: Example
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
declare exit_code
 | 
			
		||||
readonly exit_code_container=$(</run/s6-linux-init-container-results/exitcode)
 | 
			
		||||
readonly exit_code_service="${1}"
 | 
			
		||||
readonly exit_code_signal="${2}"
 | 
			
		||||
readonly service="example1"
 | 
			
		||||
 | 
			
		||||
bashio::log.info \
 | 
			
		||||
  "Service ${service} exited with code ${exit_code_service}" \
 | 
			
		||||
  "(by signal ${exit_code_signal})"
 | 
			
		||||
 | 
			
		||||
# Received a signal
 | 
			
		||||
if [[ "${exit_code_service}" -eq 256 ]]; then
 | 
			
		||||
 | 
			
		||||
  # The signal might be a result of another service crashing. Only
 | 
			
		||||
  # overwrite the container exit code if it is not already set.
 | 
			
		||||
  if [[ "${exit_code_container}" -eq 0 ]]; then
 | 
			
		||||
    echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  # If the signal is SIGTERM, we should halt the container and take down
 | 
			
		||||
  # the whole  process tree.
 | 
			
		||||
  [[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt
 | 
			
		||||
 | 
			
		||||
# The service exited with a non-zero exit code, which means it crashed.
 | 
			
		||||
elif [[ "${exit_code_service}" -ne 0 ]]; then
 | 
			
		||||
 | 
			
		||||
  # The service might be a result of another service crashing. Only
 | 
			
		||||
  # overwrite the container exit code if it is not already set.
 | 
			
		||||
  if [[ "${exit_code_container}" -eq 0 ]]; then
 | 
			
		||||
    echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
 | 
			
		||||
  fi
 | 
			
		||||
  
 | 
			
		||||
  # We should halt the container and take down the whole process tree.
 | 
			
		||||
  exec /run/s6/basedir/bin/halt
 | 
			
		||||
 | 
			
		||||
# The service exited with a zero exit code, which means it exited, let
 | 
			
		||||
# S6 supervision restart it.
 | 
			
		||||
else
 | 
			
		||||
  bashio::log.info "Service ${service} restarting..."
 | 
			
		||||
fi
 | 
			
		||||
							
								
								
									
										10
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example1/run
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example1/run
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
#!/command/with-contenv bashio
 | 
			
		||||
# shellcheck shell=bash
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
# Home Assistant Community Add-on: Example
 | 
			
		||||
# Runs example1 script
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
 | 
			
		||||
bashio::log.info "Starting Example1..."
 | 
			
		||||
 | 
			
		||||
exec /usr/bin/example1.sh
 | 
			
		||||
							
								
								
									
										1
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example1/type
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example1/type
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
longrun
 | 
			
		||||
							
								
								
									
										45
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example2/finish
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example2/finish
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
#!/command/with-contenv bashio
 | 
			
		||||
# shellcheck shell=bash
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
# Home Assistant Community Add-on: Example
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
declare exit_code
 | 
			
		||||
readonly exit_code_container=$(</run/s6-linux-init-container-results/exitcode)
 | 
			
		||||
readonly exit_code_service="${1}"
 | 
			
		||||
readonly exit_code_signal="${2}"
 | 
			
		||||
readonly service="example2"
 | 
			
		||||
 | 
			
		||||
bashio::log.info \
 | 
			
		||||
  "Service ${service} exited with code ${exit_code_service}" \
 | 
			
		||||
  "(by signal ${exit_code_signal})"
 | 
			
		||||
 | 
			
		||||
# Received a signal
 | 
			
		||||
if [[ "${exit_code_service}" -eq 256 ]]; then
 | 
			
		||||
 | 
			
		||||
  # The signal might be a result of another service crashing. Only
 | 
			
		||||
  # overwrite the container exit code if it is not already set.
 | 
			
		||||
  if [[ "${exit_code_container}" -eq 0 ]]; then
 | 
			
		||||
    echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  # If the signal is SIGTERM, we should halt the container and take down
 | 
			
		||||
  # the whole  process tree.
 | 
			
		||||
  [[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt
 | 
			
		||||
 | 
			
		||||
# The service exited with a non-zero exit code, which means it crashed.
 | 
			
		||||
elif [[ "${exit_code_service}" -ne 0 ]]; then
 | 
			
		||||
 | 
			
		||||
  # The service might be a result of another service crashing. Only
 | 
			
		||||
  # overwrite the container exit code if it is not already set.
 | 
			
		||||
  if [[ "${exit_code_container}" -eq 0 ]]; then
 | 
			
		||||
    echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
 | 
			
		||||
  fi
 | 
			
		||||
  
 | 
			
		||||
  # We should halt the container and take down the whole process tree.
 | 
			
		||||
  exec /run/s6/basedir/bin/halt
 | 
			
		||||
 | 
			
		||||
# The service exited with a zero exit code, which means it exited, let
 | 
			
		||||
# S6 supervision restart it.
 | 
			
		||||
else
 | 
			
		||||
  bashio::log.info "Service ${service} restarting..."
 | 
			
		||||
fi
 | 
			
		||||
							
								
								
									
										10
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example2/run
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example2/run
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
#!/command/with-contenv bashio
 | 
			
		||||
# shellcheck shell=bash
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
# Home Assistant Community Add-on: Example
 | 
			
		||||
# Runs example2 script
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
 | 
			
		||||
bashio::log.info "Starting Example2..."
 | 
			
		||||
 | 
			
		||||
exec /usr/bin/example2.sh
 | 
			
		||||
							
								
								
									
										1
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example2/type
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/example2/type
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
longrun
 | 
			
		||||
							
								
								
									
										8
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/init-example/run
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/init-example/run
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
#!/command/with-contenv bashio
 | 
			
		||||
# shellcheck shell=bash
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
# Home Assistant Community Add-on: Example
 | 
			
		||||
# Example init script, runs before any other service
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
 | 
			
		||||
bashio::log.info "Oh, hi! I'm the init script!"
 | 
			
		||||
							
								
								
									
										1
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/init-example/type
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/init-example/type
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
oneshot
 | 
			
		||||
							
								
								
									
										1
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/init-example/up
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								example/rootfs/etc/s6-overlay/s6-rc.d/init-example/up
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
/etc/s6-overlay/s6-rc.d/init-example/run
 | 
			
		||||
							
								
								
									
										116
									
								
								example/rootfs/usr/bin/example1.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								example/rootfs/usr/bin/example1.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,116 @@
 | 
			
		||||
#!/command/with-contenv bashio
 | 
			
		||||
# shellcheck shell=bash
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
# Home Assistant Community Add-on: Example
 | 
			
		||||
#
 | 
			
		||||
# Example add-on for Home Assistant.
 | 
			
		||||
# This add-on displays a random quote every X seconds.
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
 | 
			
		||||
# ------------------------------------------------------------------------------
 | 
			
		||||
# Get a random quote from quotationspage.com
 | 
			
		||||
#
 | 
			
		||||
# Arguments:
 | 
			
		||||
#   None
 | 
			
		||||
# Returns:
 | 
			
		||||
#   String with the quote
 | 
			
		||||
# ------------------------------------------------------------------------------
 | 
			
		||||
get_quote_online() {
 | 
			
		||||
    local number
 | 
			
		||||
    local html
 | 
			
		||||
    local quote
 | 
			
		||||
 | 
			
		||||
    bashio::log.trace "${FUNCNAME[0]}"
 | 
			
		||||
 | 
			
		||||
    number=$(( ( RANDOM % 999 )  + 1 ))
 | 
			
		||||
    html=$(wget -q -O - "http://www.quotationspage.com/quote/${number}.html")
 | 
			
		||||
 | 
			
		||||
    quote=$(grep -e "<dt>" -e "</dd>" <<< "${html}" \
 | 
			
		||||
        | awk -F'[<>]' '{
 | 
			
		||||
            if($2 ~ /dt/)
 | 
			
		||||
                { print $3 }
 | 
			
		||||
            else if($4 ~ /b/)
 | 
			
		||||
                { print "-- " $7 "  n(" $19 ")"}
 | 
			
		||||
        }'
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    echo "${quote}"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# ------------------------------------------------------------------------------
 | 
			
		||||
# Get a random quote from a prefined set of quotes
 | 
			
		||||
#
 | 
			
		||||
# Arguments:
 | 
			
		||||
#   None
 | 
			
		||||
# Returns:
 | 
			
		||||
#   String with the quote
 | 
			
		||||
# ------------------------------------------------------------------------------
 | 
			
		||||
get_quote_offline() {
 | 
			
		||||
    local -i number
 | 
			
		||||
    local -a quotes
 | 
			
		||||
 | 
			
		||||
    bashio::log.trace "${FUNCNAME[0]}"
 | 
			
		||||
 | 
			
		||||
    quotes+=("Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.\\n -Samuel Beckett")
 | 
			
		||||
    quotes+=("Never give up, for that is just the place and time that the tide will turn.\\n -Harriet Beecher Stowe")
 | 
			
		||||
    quotes+=("Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time.\\n -Thomas A. Edison")
 | 
			
		||||
    quotes+=("Life isn't about getting and having, it's about giving and being.\\n -Kevin Kruse")
 | 
			
		||||
    quotes+=("Strive not to be a success, but rather to be of value.\\n -Albert Einstein")
 | 
			
		||||
    quotes+=("You miss 100% of the shots you don't take.\\n -Wayne Gretzky")
 | 
			
		||||
    quotes+=("People who are unable to motivate themselves must be content with mediocrity, no matter how impressive their other talents. \\n -Andrew Carnegie")
 | 
			
		||||
    quotes+=("Design is not just what it looks like and feels like. Design is how it works.\\n -Steve Jobs")
 | 
			
		||||
    quotes+=("Only those who dare to fail greatly can ever achieve greatly.\\n -Robert F. Kennedy")
 | 
			
		||||
    quotes+=("All our dreams can come true, if we have the courage to pursue them.\\n -Walt Disney")
 | 
			
		||||
    quotes+=("Success consists of going from failure to failure without loss of enthusiasm.\\n -Winston Churchill")
 | 
			
		||||
 | 
			
		||||
    number=$(( ( RANDOM % 11 )  + 1 ))
 | 
			
		||||
    echo "${quotes[$number]}"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# ------------------------------------------------------------------------------
 | 
			
		||||
# Displays a random quote
 | 
			
		||||
#
 | 
			
		||||
# Arguments:
 | 
			
		||||
#   None
 | 
			
		||||
# Returns:
 | 
			
		||||
#   String with the quote
 | 
			
		||||
# -----------------------------------------------------------------------------
 | 
			
		||||
display_quote() {
 | 
			
		||||
    local quote
 | 
			
		||||
    local timestamp
 | 
			
		||||
 | 
			
		||||
    bashio::log.trace "${FUNCNAME[0]}"
 | 
			
		||||
 | 
			
		||||
    if wget -q --spider http://www.quotationspage.com; then
 | 
			
		||||
        quote=$(get_quote_online)
 | 
			
		||||
    else
 | 
			
		||||
        bashio::log.notice \
 | 
			
		||||
            'Could not connect to quotationspage.com, using an offline quote'
 | 
			
		||||
        quote=$(get_quote_offline)
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    # shellcheck disable=SC2001
 | 
			
		||||
    quote=$(sed 's/n()//g' <<< "${quote}" | xargs -0 echo | fmt -40)
 | 
			
		||||
    timestamp=$(date +"%T")
 | 
			
		||||
 | 
			
		||||
    bashio::log.info "Random quote loaded @ ${timestamp}"
 | 
			
		||||
    echo -e "${quote}"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
# RUN LOGIC
 | 
			
		||||
# ------------------------------------------------------------------------------
 | 
			
		||||
main() {
 | 
			
		||||
    local sleep
 | 
			
		||||
 | 
			
		||||
    bashio::log.trace "${FUNCNAME[0]}"
 | 
			
		||||
 | 
			
		||||
    sleep=$(bashio::config 'seconds_between_quotes')
 | 
			
		||||
    bashio::log.info "Seconds between each quotes is set to: ${sleep}"
 | 
			
		||||
 | 
			
		||||
    while true; do
 | 
			
		||||
        display_quote
 | 
			
		||||
        sleep "${sleep}"
 | 
			
		||||
    done
 | 
			
		||||
}
 | 
			
		||||
main "$@"
 | 
			
		||||
							
								
								
									
										16
									
								
								example/rootfs/usr/bin/example2.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								example/rootfs/usr/bin/example2.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
#!/command/with-contenv bashio
 | 
			
		||||
# shellcheck shell=bash
 | 
			
		||||
# ==============================================================================
 | 
			
		||||
# Home Assistant Community Add-on: Example
 | 
			
		||||
#
 | 
			
		||||
# Example add-on for Home Assistant.
 | 
			
		||||
# ------------------------------------------------------------------------------
 | 
			
		||||
main() {
 | 
			
		||||
    bashio::log.trace "${FUNCNAME[0]}"
 | 
			
		||||
 | 
			
		||||
    while true; do
 | 
			
		||||
        echo "Second Script Output"
 | 
			
		||||
        sleep 10
 | 
			
		||||
    done
 | 
			
		||||
}
 | 
			
		||||
main "$@"
 | 
			
		||||
		Reference in New Issue
	
	Block a user