mirror of
https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git
synced 2025-12-15 11:22:43 +03:00
Fix UserData Script chmod, etc.
This commit is contained in:
parent
e650415799
commit
badf0f65d1
1
dist/openrc/tiny-cloud
vendored
1
dist/openrc/tiny-cloud
vendored
@ -1,5 +1,6 @@
|
||||
#!/sbin/openrc-run
|
||||
# vim:set ts=8 noet ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
description="Tiny Cloud Bootstrap - main phase"
|
||||
extra_commands="complete incomplete"
|
||||
|
||||
1
dist/openrc/tiny-cloud-early
vendored
1
dist/openrc/tiny-cloud-early
vendored
@ -1,5 +1,6 @@
|
||||
#!/sbin/openrc-run
|
||||
# vim:set ts=8 noet ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
description="Tiny Cloud Bootstrap - early phase"
|
||||
|
||||
|
||||
1
dist/openrc/tiny-cloud-final
vendored
1
dist/openrc/tiny-cloud-final
vendored
@ -1,5 +1,6 @@
|
||||
#!/sbin/openrc-run
|
||||
# vim:set ts=8 noet ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
description="Tiny Cloud Bootstrap - final phase"
|
||||
|
||||
|
||||
1
dist/openrc/tiny-cloud-net
vendored
1
dist/openrc/tiny-cloud-net
vendored
@ -1,5 +1,6 @@
|
||||
#!/sbin/openrc-run
|
||||
# vim:set ts=8 noet ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
description="Tiny Cloud Bootstrap - net phase"
|
||||
depend() {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Tiny Cloud - Init Functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
INIT_ACTIONS_EARLY="$(replace_word set_default_interfaces set_network_interfaces $INIT_ACTIONS_EARLY)"
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# AWS Instance MetaData Service variables and functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
IMDS_HEADER="X-aws-ec2-metadata-token"
|
||||
IMDS_TOKEN_TTL_HEADER="X-aws-ec2-metadata-token-ttl-seconds"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# AWS mdev Hotplug Modules
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
# makes symlinks for NVMe devices that correlate to AWS EBS sd/xvd devices
|
||||
mod__nvme_ebs_links() {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Azure Instance MetaData Service variables and functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
IMDS_HEADER="Metadata"
|
||||
IMDS_QUERY="?format=text&api-version=2021-05-01"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Google Cloud Instance MetaData Service variables and functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
IMDS_HEADER="Metadata-Flavor"
|
||||
IMDS_URI="computeMetadata/v1"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# NoCloud Instance Metadata
|
||||
# vim: ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
NOCLOUD_FILES="meta-data user-data vendor-data network-config"
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# OCI Instance MetaData Service variables and functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
IMDS_HEADER="Authorization"
|
||||
IMDS_URI="opc/v2"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Tiny Cloud - common script functions
|
||||
# vim: ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
# set defaults
|
||||
[ -f "$ROOT/etc/tiny-cloud.conf" ] && . "$ROOT/etc/tiny-cloud.conf"
|
||||
@ -26,7 +27,7 @@ log() {
|
||||
shift
|
||||
|
||||
[ -n "$init" ] && echo "$@" >&2
|
||||
logger $stderr -p "$facility.$level" -t "$tag[$$]" "$@"
|
||||
logger $stderr -p "$facility.$level" -t "${tag}[$$]" "$@"
|
||||
case "$level" in
|
||||
crit|alert|emerg) exit 1 ;;
|
||||
esac
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Tiny Cloud - Init Functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
# set defaults
|
||||
: "${LIBDIR:=$PREFIX/lib}"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Tiny Cloud - mdev hotplug functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
# generic helper function to install mdev rules
|
||||
install_before() {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Script UserData Functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
INIT_ACTIONS_MAIN="$(insert_after set_hostname \
|
||||
"userdata_bootcmd userdata_ntp userdata_apk_cache userdata_apk_repositories userdata_packages" \
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# CloudConfig UserData Functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
# TODO
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Missing UserData Functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
init__missing_userdata() {
|
||||
log -i -t "$phase" notice "$ACTION: no user-data found"
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
# Script UserData Functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
init__run_userdata() {
|
||||
local log="$TINY_CLOUD_LOGS/user-data.log"
|
||||
local exit="$TINY_CLOUD_LOGS/user-data.exit"
|
||||
local userdata="$TINY_CLOUD_VAR/user-data"
|
||||
|
||||
chmod +x "$userdata"
|
||||
chmod u+x "$userdata"
|
||||
{ "$userdata" 2>& 1; echo $? > "$exit"; } | tee "$log"
|
||||
|
||||
return $(cat "$exit")
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Unknown UserData Functions
|
||||
# vim:set ts=4 et ft=sh:
|
||||
# shellcheck shell=sh
|
||||
|
||||
init__unknown_userdata() {
|
||||
local type="$(userdata_type)"
|
||||
|
||||
@ -10,16 +10,19 @@ set -e
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: ${0##*/} [-h | --help] { early | net | main | final | --bootstrap {complete|incomplete} | --setup }
|
||||
Usage: ${0##*/} [-h | --help] { early | net | main | final | --bootstrap [complete|incomplete|status] | --setup }
|
||||
EOF
|
||||
}
|
||||
|
||||
init__bootstrap_complete() {
|
||||
bootstrap_complete() {
|
||||
touch "$TINY_CLOUD_VAR/.bootstrap-complete"
|
||||
}
|
||||
bootstrap_incomplete() {
|
||||
rm -f "$TINY_CLOUD_VAR/.bootstrap-complete"
|
||||
}
|
||||
is_bootstrap_complete() {
|
||||
[ -f "$TINY_CLOUD_VAR/.bootstrap-complete" ]
|
||||
}
|
||||
|
||||
args=$(getopt -o hsb: --long help,setup,bootstrap: -n ${0##*/} -- "$@") || { usage >&2; exit 1; }
|
||||
if [ $# -eq 0 ]; then
|
||||
@ -33,11 +36,12 @@ while true; do
|
||||
-b|--bootstrap) shift
|
||||
case "$1" in
|
||||
complete) # indicate bootstrap is done
|
||||
init__bootstrap_complete
|
||||
bootstrap_complete
|
||||
log -i notice 'bootstrap marked complete';;
|
||||
incomplete) # indicate bootstrap isn't done
|
||||
bootstrap_incomplete
|
||||
log -i warn 'bootstrap marked incomplete';;
|
||||
status) is_bootstrap_complete && echo 'complete' || echo 'incomplete' ;;
|
||||
*) usage >&2; exit 1;;
|
||||
esac
|
||||
exit 0;;
|
||||
@ -65,7 +69,7 @@ case "$phase" in
|
||||
esac
|
||||
|
||||
# is initial bootstrap already done?
|
||||
if [ -f "$TINY_CLOUD_VAR/.bootstrap-complete" ]; then
|
||||
if is_bootstrap_complete; then
|
||||
log -i -t "$phase" info "already bootstrapped"
|
||||
exit 0;
|
||||
fi
|
||||
@ -85,6 +89,9 @@ skip_action() {
|
||||
}
|
||||
|
||||
# mandatory final action...
|
||||
init__bootstrap_complete() {
|
||||
bootstrap_complete
|
||||
}
|
||||
INIT_ACTIONS_FINAL="${INIT_ACTIONS_FINAL} bootstrap_complete"
|
||||
|
||||
### let's do stuff!
|
||||
@ -97,14 +104,15 @@ case "$phase" in
|
||||
*) usage >&2; exit 1
|
||||
esac
|
||||
|
||||
printf '\n' >&2
|
||||
for ACTION in $INIT_ACTIONS; do
|
||||
if skip_action "$ACTION"; then
|
||||
printf '\n -- ' >&2
|
||||
printf ' -- ' >&2
|
||||
log -i -t "$phase" notice "$ACTION: skipped"
|
||||
continue
|
||||
fi
|
||||
printf '\n ++ ' >&2
|
||||
log -i -t "$phase" info "$ACTION"
|
||||
printf ' ++ ' >&2
|
||||
log -i -t "$phase" info "$ACTION: starting"
|
||||
RESULT="unknown"
|
||||
LEVEL="err"
|
||||
if type "init__$ACTION" | grep -q -w "function"; then
|
||||
@ -118,4 +126,3 @@ for ACTION in $INIT_ACTIONS; do
|
||||
printf ' ++ ' >&2
|
||||
log -i -t "$phase" "$LEVEL" "$ACTION: $RESULT"
|
||||
done
|
||||
echo >&2
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env atf-sh
|
||||
# shellcheck shell=sh
|
||||
|
||||
. $(atf_get_srcdir)/test_env.sh
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env atf-sh
|
||||
# shellcheck shell=sh
|
||||
|
||||
. $(atf_get_srcdir)/test_env.sh
|
||||
init_tests \
|
||||
@ -17,13 +18,13 @@ init_tests \
|
||||
|
||||
fake_wget_usage_body() {
|
||||
atf_check -s exit:0 \
|
||||
-o match:"^usage: $@" \
|
||||
-o match:"^usage: $*" \
|
||||
-e empty \
|
||||
wget -h
|
||||
|
||||
atf_check -s exit:1 \
|
||||
-o empty \
|
||||
-e match:"^usage: $@" \
|
||||
-e match:"^usage: $*" \
|
||||
wget -INVALID
|
||||
}
|
||||
|
||||
@ -109,4 +110,3 @@ fake_wget_content_from_path_body() {
|
||||
-o match:"^value$" \
|
||||
wget --quiet -O - https://example.com/foo/key
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env atf-sh
|
||||
# shellcheck shell=sh
|
||||
|
||||
. $(atf_get_srcdir)/test_env.sh
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env atf-sh
|
||||
# shellcheck shell=sh
|
||||
|
||||
. $(atf_get_srcdir)/test_env.sh
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env atf-sh
|
||||
# shellcheck shell=sh
|
||||
|
||||
. $(atf_get_srcdir)/test_env.sh
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env atf-sh
|
||||
# shellcheck shell=sh
|
||||
|
||||
. $(atf_get_srcdir)/test_env.sh
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env atf-sh
|
||||
# shellcheck shell=sh
|
||||
|
||||
. $(atf_get_srcdir)/test_env.sh
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env atf-sh
|
||||
# shellcheck shell=sh
|
||||
|
||||
. $(atf_get_srcdir)/test_env.sh
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user