Skip to content

Commit

Permalink
unify anon.conf, revert source_conf method
Browse files Browse the repository at this point in the history
  • Loading branch information
nyxnor committed Aug 17, 2022
1 parent 9e44fce commit 19666d7
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 192 deletions.
12 changes: 4 additions & 8 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ get_os(){

case ${os} in
Linux*)
if test -f /usr/share/anon-gw-base-files/gateway; then
distro="Anon-Gateway"
elif test -f /usr/share/anon-ws-base-files/workstation; then
distro="Anon-Workstation"
if test -f /usr/share/anon-dist/marker; then
distro="Anon"
elif command -v lsb_release >/dev/null; then
distro=$(lsb_release -sd)
elif test -f /etc/os-release; then
Expand Down Expand Up @@ -182,8 +180,7 @@ get_vars(){
case "${distro}" in
"Debian"*|*"buntu"*|"Armbian"*|"Rasp"*|"Linux Mint"*|"LinuxMint"*|"mint"*) . "${topdir}"/etc/onionjuggler/debian.conf;;
"Tails"*) . "${topdir}"/etc/onionjuggler/tails.conf;;
"Anon-Gateway") . "${topdir}"/etc/onionjuggler/anon-gateway.conf;;
"Anon-Workstation") . "${topdir}"/etc/onionjuggler/anon-workstation.conf;;
"Anon") . "${topdir}"/etc/onionjuggler/anon.conf;;
"Arch"*|"Artix"*|"ArcoLinux"*) . "${topdir}"/etc/onionjuggler/arch.conf;;
"Fedora"*|"CentOS"*|"rhel"*|"Redhat"*|"Red hat") . "${topdir}"/etc/onionjuggler/fedora.conf;;
esac
Expand Down Expand Up @@ -312,8 +309,7 @@ case "${command}" in
case "${distro}" in
"Debian"*|*"buntu"*|"Armbian"*|"Rasp"*|"Linux Mint"*|"LinuxMint"*|"mint"*) cp "${topdir}"/etc/onionjuggler/debian.conf "${conf_dir}/onionjuggler.conf";;
"Tails"*) cp "${topdir}"/etc/onionjuggler/tails.conf "${conf_dir}/oionjuggler.conf";;
"Anon-Gateway") cp "${topdir}"/etc/onionjuggler/anon-gateway.conf "${conf_dir}/onionjuggler.conf";;
"Anon-Workstation") cp "${topdir}"/etc/onionjuggler/anon-workstation.conf "${conf_dir}/onionjuggler.conf";;
"Anon") cp "${topdir}"/etc/onionjuggler/anon.conf "${conf_dir}/onionjuggler.conf";;
"Arch"*|"Artix"*|"ArcoLinux"*) cp "${topdir}"/etc/onionjuggler/arch.conf "${conf_dir}/onionjuggler.conf";;
"Fedora"*|"CentOS"*|"rhel"*|"Redhat"*|"Red hat") cp "${topdir}"/etc/onionjuggler/fedora.conf "${conf_dir}/onionjuggler.conf";;
esac
Expand Down
2 changes: 1 addition & 1 deletion debian/onionjuggler-lib.install
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/dh-exec

etc/onionjuggler/conf.d/*
etc/onionjuggler/conf.d/
etc/onionjuggler/debian.conf => etc/onionjuggler/onionjuggler.conf
etc/onionjuggler/dialogrc
usr/share/onionjuggler/*
1 change: 1 addition & 0 deletions debian/onionjuggler-lib.lintian-overrides
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
onionjuggler-lib: initial-upload-closes-no-bugs
onionjuggler-lib: script-not-executable etc/onionjuggler/onionjuggler.conf
44 changes: 0 additions & 44 deletions etc/onionjuggler/anon-gateway.conf

This file was deleted.

30 changes: 0 additions & 30 deletions etc/onionjuggler/anon-workstation.conf

This file was deleted.

63 changes: 63 additions & 0 deletions etc/onionjuggler/anon.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env sh
## Configuration file for OnionJuggler
##
## DO NOT EDIT THIS FILE!!
##
## This file defines the default service selection as shipped in a
## release. Upgrades of OnionJuggler will modify this file.
##
## To select the service options you desire, please override these
## options in the file /etc/onionjuggler/conf.d/*.conf
##
## DO NOT EDIT THIS FILE!!
##
## Lines that begin with "## " try to explain what's going on. Lines
## that begin with just "#" are disabled commands: you can enable them
## by removing the "#" symbol.
##
## If the variable is empty (var=""), will use the default option.
## Double quote to prevent globbing and word splitting.
## variable="value"
##
# shellcheck disable=SC2034

if test -f /usr/share/anon-gw-base-files/gateway; then
## Gateway
########## System ##########
operating_system="anon-gateway"
## web: should be on the workstation
onionjuggler_plugin="auth-server,auth-client"
pkg_mngr_install="apt install -y"
openssl_cmd="openssl"
dialog_box="whiptail"
## this variable not used on the debian package
requirements="tor grep sed openssl basez qrencode ${dialog_box}"

########## tor daemon ##########
daemon_control="systemctl"
tor_daemon="tor@default"
tor_user="debian-tor"
tor_conf_user_group="root:root"
## included tor configuration folder, specifically files matching '*.conf'
tor_conf_dir="/usr/local/etc/torrc.d"
## manage its own unique torrc to avoid user manual modification
tor_conf="${tor_conf_dir}/40_onionjuggler.conf"
tor_data_dir="/var/lib/tor"
## pre-confiured ClientOnionAuthDir
tor_data_dir_auth="${tor_data_dir}/authdir"

elif test -f /usr/share/anon-ws-base-files/workstation; then
## Workstation
########## System ##########
operating_system="anon-workstation"
## web is the only usable plugin for Workstations
onionjuggler_plugin="web"
pkg_mngr_install="apt install -y"
webserver="nginx"
dialog_box="whiptail"
requirements="grep sed qrencode ${dialog_box} ${webserver}"

elif ! test -f /usr/share/anon-dist/marker; then
error_msg "anon.conf chosen but this is not an anon dist"
exit 1
fi
1 change: 1 addition & 0 deletions etc/onionjuggler/arch.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh
## Configuration file for OnionJuggler
##
## DO NOT EDIT THIS FILE!!
Expand Down
1 change: 1 addition & 0 deletions etc/onionjuggler/debian.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh
## Configuration file for OnionJuggler
##
## DO NOT EDIT THIS FILE!!
Expand Down
1 change: 1 addition & 0 deletions etc/onionjuggler/fedora.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh
## Configuration file for OnionJuggler
##
## DO NOT EDIT THIS FILE!!
Expand Down
1 change: 1 addition & 0 deletions etc/onionjuggler/freebsd.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh
## Configuration file for OnionJuggler
##
## DO NOT EDIT THIS FILE!!
Expand Down
1 change: 1 addition & 0 deletions etc/onionjuggler/netbsd.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh
## Configuration file for OnionJuggler
##
## DO NOT EDIT THIS FILE!!
Expand Down
1 change: 1 addition & 0 deletions etc/onionjuggler/openbsd.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh
## Configuration file for OnionJuggler
##
## DO NOT EDIT THIS FILE!!
Expand Down
98 changes: 0 additions & 98 deletions etc/onionjuggler/sample.conf

This file was deleted.

1 change: 1 addition & 0 deletions etc/onionjuggler/tails.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh
## Configuration file for OnionJuggler
##
## DO NOT EDIT THIS FILE!!
Expand Down
1 change: 1 addition & 0 deletions etc/onionjuggler/void.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh
## Configuration file for OnionJuggler on VoidLinux systems
##
## DO NOT EDIT THIS FILE!!
Expand Down
14 changes: 3 additions & 11 deletions usr/share/onionjuggler/defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ error_msg(){ notice "${red}error: ${1}${nocolor}" 1>&2; exit 1; }

## helper for --getconf
get_conf_values(){
for key in operating_system openssl_cmd webserver webserver_conf website_dir requirements \
tor_daemon tor_user tor_conf_dir tor_conf_user_group tor_conf tor_data_dir tor_data_dir_services tor_data_dir_auth \
for key in operating_system onionjuggler_plugin pkg_mngr_install openssl_cmd webserver webserver_conf website_dir dialog requirements \
daemon_control tor_daemon tor_user tor_conf_user_group tor_conf_dir tor_conf tor_data_dir tor_data_dir_services tor_data_dir_auth \
tor_hiddenserviceport_target_addr; do
eval val='$'"${key}"
test -n "${val}" && printf '%s\n' "${key}=\"${val}\""
Expand Down Expand Up @@ -146,16 +146,8 @@ set_default_conf_values(){
source_conf(){
test -f /etc/onionjuggler/onionjuggler.conf || error_msg "Default configuration file not found: /etc/onionjuggler/onionjuggler.conf"
for file in /etc/onionjuggler/onionjuggler.conf /etc/onionjuggler/conf.d/*.conf; do
## not sourcing file directly to avoid running commands
## also us"eful to save variables to a list to be later printed
conf_filtered="/tmp/onionjuggler.conf.read"
grep -v -e "^[[:space:]]*\#" -e "^[[:space:]]*$" "${file}" | tee "${conf_filtered}" >/dev/null
#printf '%s\n' "${conf_read}" | while IFS='=' read -r key val; do
while IFS='=' read -r key val; do
test -n "${key}" && eval "${key}"="${val}"
done < "${conf_filtered}"
. "${file}"
done
rm -f "${conf_filtered}"
set_default_conf_values
}

Expand Down

0 comments on commit 19666d7

Please sign in to comment.