diff --git a/rootfs/root/docker/setup/03-files.sh b/rootfs/root/docker/setup/03-files.sh index ea8a281..af725e7 100755 --- a/rootfs/root/docker/setup/03-files.sh +++ b/rootfs/root/docker/setup/03-files.sh @@ -29,60 +29,65 @@ exitCode=0 # - - - - - - - - - - - - - - - - - - - - - - - - - # Predefined actions if [ -d "/tmp/bin" ]; then - mkdir -p "/usr/local/bin" - for bin in "/tmp/bin"/*; do - name="$(basename -- "$bin")" - echo "Installing $name to /usr/local/bin/$name" - copy "$bin" "/usr/local/bin/$name" - chmod -f +x "/usr/local/bin/$name" - done + mkdir -p "/usr/local/bin" + for bin in "/tmp/bin"/*; do + name="$(basename -- "$bin")" + echo "Installing $name to /usr/local/bin/$name" + copy "$bin" "/usr/local/bin/$name" + chmod -f +x "/usr/local/bin/$name" + done fi unset bin if [ -d "/tmp/var" ]; then - for var in "/tmp/var"/*; do - name="$(basename -- "$var")" - echo "Installing $var to /var/$name" - if [ -d "$var" ]; then - mkdir -p "/var/$name" - copy "$var/." "/var/$name/" - else - copy "$var" "/var/$name" - fi - done + for var in "/tmp/var"/*; do + name="$(basename -- "$var")" + echo "Installing $var to /var/$name" + if [ -d "$var" ]; then + mkdir -p "/var/$name" + copy "$var/." "/var/$name/" + else + copy "$var" "/var/$name" + fi + done fi unset var if [ -d "/tmp/etc" ]; then - for config in "/tmp/etc"/*; do - name="$(basename -- "$config")" - echo "Installing $config to /etc/$name" - if [ -d "$config" ]; then - mkdir -p "/etc/$name" - copy "$config/." "/etc/$name/" - mkdir -p "/usr/local/share/template-files/config/$name" - copy "$config/." "/usr/local/share/template-files/config/$name/" - else - copy "$config" "/etc/$name" - copy "$config" "/usr/local/share/template-files/config/$name" - fi - done + for config in "/tmp/etc"/*; do + name="$(basename -- "$config")" + echo "Installing $config to /etc/$name" + if [ -d "$config" ]; then + mkdir -p "/etc/$name" + copy "$config/." "/etc/$name/" + mkdir -p "/usr/local/share/template-files/config/$name" + copy "$config/." "/usr/local/share/template-files/config/$name/" + else + copy "$config" "/etc/$name" + copy "$config" "/usr/local/share/template-files/config/$name" + fi + done fi unset config if [ -d "/tmp/data" ]; then - for data in "/tmp/data"/*; do - name="$(basename -- "$data")" - echo "Installing $data to /usr/local/share/template-files/data" - if [ -d "$data" ]; then - mkdir -p "/usr/local/share/template-files/data/$name" - copy "$data/." "/usr/local/share/template-files/data/$name/" - else - copy "$data" "/usr/local/share/template-files/data/$name" - fi - done + for data in "/tmp/data"/*; do + name="$(basename -- "$data")" + echo "Installing $data to /usr/local/share/template-files/data" + if [ -d "$data" ]; then + mkdir -p "/usr/local/share/template-files/data/$name" + copy "$data/." "/usr/local/share/template-files/data/$name/" + else + copy "$data" "/usr/local/share/template-files/data/$name" + fi + done fi unset data # - - - - - - - - - - - - - - - - - - - - - - - - - # Main script - +for tor_bin in relay bridge server; do + if [ ! -f "/usr/local/bin/tor-$tor_bin" ]; then + cp -Rf "$(type -P tor 2>/dev/null)" "/usr/local/bin/tor-$tor_bin" + chmod +x "/usr/local/bin/tor-$tor_bin" + fi +done # - - - - - - - - - - - - - - - - - - - - - - - - - # Set the exit code #exitCode=$? diff --git a/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh b/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh index b037fed..d8b5ea4 100755 --- a/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh +++ b/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh @@ -200,9 +200,12 @@ RANDOM_NICK="$(head -n50 '/dev/random' | tr -dc 'a-zA-Z' | tr -d '[:space:]\042\ __run_precopy() { # Define environment local hostname=${HOSTNAME} + local tor_bin="$(type -P "tor" 2>/dev/null)" + local server_bin="$(type -P "tor-bridge" 2>/dev/null)" # Define actions/commands [ -d "$DATA_DIR" ] || mkdir -p "$DATA_DIR" - + [ -n "$tor_bin" ] && [ -z "$server_bin" ] && cp -Rf "$tor_bin" "/usr/local/bin/tor-bridge" + chmod +x "/usr/local/bin/tor-bridge" # allow custom functions if builtin type -t __run_precopy_local | grep -q 'function'; then __run_precopy_local; fi } diff --git a/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh b/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh index af7aab4..5393ab8 100755 --- a/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh +++ b/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh @@ -200,8 +200,12 @@ RANDOM_NICK="$(head -n50 '/dev/random' | tr -dc 'a-zA-Z' | tr -d '[:space:]\042\ __run_precopy() { # Define environment local hostname=${HOSTNAME} + local tor_bin="$(type -P "tor" 2>/dev/null)" + local server_bin="$(type -P "tor-relay" 2>/dev/null)" # Define actions/commands [ -d "$DATA_DIR" ] || mkdir -p "$DATA_DIR" + [ -n "$tor_bin" ] && [ -z "$server_bin" ] && cp -Rf "$tor_bin" "/usr/local/bin/tor-relay" + chmod +x "/usr/local/bin/tor-relay" # allow custom functions if builtin type -t __run_precopy_local | grep -q 'function'; then __run_precopy_local; fi diff --git a/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh b/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh index b30d2e2..c16188e 100755 --- a/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh +++ b/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh @@ -200,8 +200,12 @@ RANDOM_NICK="$(head -n50 '/dev/random' | tr -dc 'a-zA-Z' | tr -d '[:space:]\042\ __run_precopy() { # Define environment local hostname=${HOSTNAME} + local tor_bin="$(type -P "tor" 2>/dev/null)" + local server_bin="$(type -P "tor-server" 2>/dev/null)" # Define actions/commands [ -d "$DATA_DIR" ] || mkdir -p "$DATA_DIR" + [ -n "$tor_bin" ] && [ -z "$server_bin" ] && cp -Rf "$tor_bin" "/usr/local/bin/tor-server" + chmod +x "/usr/local/bin/tor-server" # allow custom functions if builtin type -t __run_precopy_local | grep -q 'function'; then __run_precopy_local; fi