Files
opengist/rootfs/root/docker/setup/03-files.sh
T

93 lines
2.7 KiB
Bash
Raw Normal View History

2025-09-16 23:50:20 -04:00
#!/usr/bin/env bash
2026-06-12 05:39:45 -04:00
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202606120507-git
2025-09-16 23:50:20 -04:00
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
2026-06-04 14:47:16 -04:00
# @@License : WTFPL
2026-06-12 05:39:45 -04:00
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Fri Jun 12 05:07:20 AM EDT 2026
2025-09-16 23:50:20 -04:00
# @@File : 03-files.sh
# @@Description : script to run files
2026-06-12 05:39:45 -04:00
# @@Changelog : newScript
# @@TODO : Refactor code
# @@Other : N/A
# @@Resource : N/A
# @@Terminal App : yes
# @@sudo/root : yes
# @@Template : templates/dockerfiles/init_scripts/03-files.sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
2025-11-29 08:22:47 -05:00
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
2026-06-12 05:39:45 -04:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options
set -eo pipefail
2025-09-16 23:50:20 -04:00
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
2026-06-12 05:39:45 -04:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables
2025-09-16 23:50:20 -04:00
exitCode=0
2026-06-12 05:39:45 -04:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Predefined actions
2025-11-29 08:22:47 -05:00
if [ -d "/tmp/bin" ]; then
2026-06-12 05:39:45 -04:00
mkdir -p "/usr/local/bin"
2025-11-29 08:22:47 -05:00
for bin in "/tmp/bin"/*; do
2026-06-12 05:39:45 -04:00
[ -e "$bin" ] || continue
2026-06-04 14:47:16 -04:00
name="${bin##*/}"
2025-11-29 08:22:47 -05:00
echo "Installing $name to /usr/local/bin/$name"
2026-06-12 05:39:45 -04:00
cp -Rf "$bin" "/usr/local/bin/$name"
chmod -f +x "/usr/local/bin/$name"
2025-11-29 08:22:47 -05:00
done
fi
unset bin
if [ -d "/tmp/var" ]; then
for var in "/tmp/var"/*; do
2026-06-12 05:39:45 -04:00
[ -e "$var" ] || continue
2026-06-04 14:47:16 -04:00
name="${var##*/}"
2025-11-29 08:22:47 -05:00
echo "Installing $var to /var/$name"
if [ -d "$var" ]; then
2026-06-12 05:39:45 -04:00
mkdir -p "/var/$name"
cp -Rf "$var/." "/var/$name/"
2025-11-29 08:22:47 -05:00
else
2026-06-12 05:39:45 -04:00
cp -Rf "$var" "/var/$name"
2025-11-29 08:22:47 -05:00
fi
done
fi
unset var
if [ -d "/tmp/etc" ]; then
for config in "/tmp/etc"/*; do
2026-06-12 05:39:45 -04:00
[ -e "$config" ] || continue
2026-06-04 14:47:16 -04:00
name="${config##*/}"
2025-11-29 08:22:47 -05:00
echo "Installing $config to /etc/$name"
if [ -d "$config" ]; then
2026-06-12 05:39:45 -04:00
mkdir -p "/etc/$name"
cp -Rf "$config/." "/etc/$name/"
2025-11-29 08:22:47 -05:00
else
2026-06-12 05:39:45 -04:00
cp -Rf "$config" "/etc/$name"
2025-11-29 08:22:47 -05:00
fi
done
fi
unset config
2026-06-04 14:47:16 -04:00
if [ -d "/tmp/usr" ]; then
2026-06-12 05:39:45 -04:00
for share in "/tmp/usr"/*; do
[ -e "$share" ] || continue
name="${share##*/}"
dest="/usr/$name"
echo "Installing $share to $dest"
mkdir -p "$dest"
cp -Rf "$share/." "$dest/"
2025-11-29 08:22:47 -05:00
done
fi
2026-06-12 05:39:45 -04:00
unset share
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code
2026-06-04 14:47:16 -04:00
exitCode=$?
2026-06-12 05:39:45 -04:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
2025-09-16 23:50:20 -04:00
exit $exitCode
2026-06-12 05:39:45 -04:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
2025-11-29 08:22:47 -05:00
# ex: ts=2 sw=2 et filetype=sh
2026-06-12 05:39:45 -04:00
# - - - - - - - - - - - - - - - - - - - - - - - - -