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

99 lines
3.1 KiB
Bash
Raw Normal View History

2025-01-06 11:33:06 -05:00
#!/usr/bin/env bash
2025-11-21 05:25:29 -05:00
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
2026-05-26 18:08:53 -04:00
##@Version : 202605261538-git
2025-01-06 11:33:06 -05:00
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
2026-05-26 18:08:53 -04:00
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Tue May 26 03:38:50 PM EDT 2026
2025-01-06 11:33:06 -05:00
# @@File : 03-files.sh
# @@Description : script to run files
2025-11-21 05:25:29 -05: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
# - - - - - - - - - - - - - - - - - - - - - - - - -
2026-05-26 18:08:53 -04:00
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
2025-11-21 05:25:29 -05:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
2025-01-06 11:33:06 -05:00
# Set bash options
set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
2025-11-21 05:25:29 -05:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
2025-01-06 11:33:06 -05:00
# Set env variables
exitCode=0
2025-11-21 05:25:29 -05:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
2025-01-06 11:33:06 -05:00
# Predefined actions
if [ -d "/tmp/bin" ]; then
2026-05-26 18:08:53 -04:00
mkdir -p "/usr/local/bin"
for bin in "/tmp/bin"/*; do
[ -e "$bin" ] || continue
name="${bin##*/}"
echo "Installing $name to /usr/local/bin/$name"
cp -Rf "$bin" "/usr/local/bin/$name"
chmod -f +x "/usr/local/bin/$name"
done
2025-01-06 11:33:06 -05:00
fi
unset bin
if [ -d "/tmp/var" ]; then
2026-05-26 18:08:53 -04:00
for var in "/tmp/var"/*; do
[ -e "$var" ] || continue
name="${var##*/}"
echo "Installing $var to /var/$name"
if [ -d "$var" ]; then
mkdir -p "/var/$name"
cp -Rf "$var/." "/var/$name/"
else
cp -Rf "$var" "/var/$name"
fi
done
2025-01-06 11:33:06 -05:00
fi
unset var
if [ -d "/tmp/etc" ]; then
2026-05-26 18:08:53 -04:00
for config in "/tmp/etc"/*; do
[ -e "$config" ] || continue
name="${config##*/}"
echo "Installing $config to /etc/$name"
if [ -d "$config" ]; then
mkdir -p "/etc/$name"
cp -Rf "$config/." "/etc/$name/"
mkdir -p "/usr/local/share/template-files/config/$name"
cp -Rf "$config/." "/usr/local/share/template-files/config/$name/"
else
cp -Rf "$config" "/etc/$name"
cp -Rf "$config" "/usr/local/share/template-files/config/$name"
fi
done
2025-01-06 11:33:06 -05:00
fi
unset config
if [ -d "/tmp/data" ]; then
2026-05-26 18:08:53 -04:00
for data in "/tmp/data"/*; do
[ -e "$data" ] || continue
name="${data##*/}"
echo "Installing $data to /usr/local/share/template-files/data"
if [ -d "$data" ]; then
mkdir -p "/usr/local/share/template-files/data/$name"
cp -Rf "$data/." "/usr/local/share/template-files/data/$name/"
else
cp -Rf "$data" "/usr/local/share/template-files/data/$name"
fi
done
2025-01-06 11:33:06 -05:00
fi
unset data
2025-11-21 05:25:29 -05:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
2025-01-06 11:33:06 -05:00
# Main script
2026-05-26 18:08:53 -04:00
2025-11-21 05:25:29 -05:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
2025-01-06 11:33:06 -05:00
# Set the exit code
2026-05-26 18:08:53 -04:00
exitCode=$?
2025-11-21 05:25:29 -05:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
2025-01-06 11:33:06 -05:00
exit $exitCode
2025-11-21 05:25:29 -05:00
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
2026-05-26 18:08:53 -04:00