1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-04-20 02:52:11 +00:00

Legal Agreement Requirement for Installations

This commit is contained in:
EliterScripts 2019-04-09 21:31:27 -07:00
parent dd7a2aa8a6
commit 1be915abc1
4 changed files with 159 additions and 8 deletions

45
setup/agreement.py Normal file
View File

@ -0,0 +1,45 @@
import sys
import rtyaml
import collections
import os.path
def load_environment():
# Load settings from a KEY=VALUE file.
import collections
env = collections.OrderedDict()
for line in open("/etc/mailinabox.conf"): env.setdefault(*line.strip().split("=", 1))
return env
def write_settings(config, env):
fn = os.path.join(env['STORAGE_ROOT'], 'settings.yaml')
with open(fn, "w") as f:
f.write(rtyaml.dump(config))
def load_settings(env):
fn = os.path.join(env['STORAGE_ROOT'], 'settings.yaml')
try:
config = rtyaml.load(open(fn, "r"))
if not isinstance(config, dict): raise ValueError() # caught below
return config
except:
return { }
env = load_environment()
if(sys.argv[2]):
if( sys.argv[1] == "check" ):
yaml = rtyaml.load(open( os.path.join(env['STORAGE_ROOT'], 'settings.yaml') ))
if( yaml.get("mailinabox-agreement", True) ):
print("true")
else:
print("false")
elif( sys.argv[1] == "set" ):
config = load_settings(env)
config["mailinabox-agreement"] = True
write_settings( config, env )
print("true")

View File

@ -223,3 +223,66 @@ function git_clone {
mv $TMPPATH/$SUBDIR $TARGETPATH
rm -rf $TMPPATH
}
function set_storage_user {
# Set STORAGE_USER to default values ( user-data ), unless
# we've already got those values from a previous run.
if [ -z "${STORAGE_USER:-}" ]; then
STORAGE_USER=$([[ -z "${DEFAULT_STORAGE_USER:-}" ]] && echo "user-data" || echo "$DEFAULT_STORAGE_USER")
fi
}
function set_storage_root {
# Set STORAGE_ROOT to default values ( /home/user-data ), unless
# we've already got those values from a previous run.
if [ -z "${STORAGE_USER:-}" ]; then
STORAGE_USER=$([[ -z "${DEFAULT_STORAGE_USER:-}" ]] && echo "user-data" || echo "$DEFAULT_STORAGE_USER")
fi
if [ -z "${STORAGE_ROOT:-}" ]; then
STORAGE_ROOT=$([[ -z "${DEFAULT_STORAGE_ROOT:-}" ]] && echo "/home/$STORAGE_USER" || echo "$DEFAULT_STORAGE_ROOT")
fi
}
function check_config_agreed {
set_storage_user;
set_storage_root;
if [ -z "${I_AGREE_MAILINABOX:-}" ]; then
if [ ! -d $STORAGE_ROOT ]; then
return 1
fi
if [ ! -f $STORAGE_ROOT/settings.yaml ]; then
return 1
fi
local current_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
local yaml_agreed=$(python check "${current_directory}"/checkagree.py "${STORAGE_ROOT}/settings.yaml")
if [ "$yaml_agreed" -eq "true"]; then
return 0
fi
return 1
else
return 0
fi
}
function set_config_agreed {
set_storage_user;
set_storage_root;
if [ -z "${I_AGREE_MAILINABOX:-}" ]; then
if [ ! -d $STORAGE_ROOT ]; then
return 1
fi
if [ ! -f $STORAGE_ROOT/settings.yaml ]; then
return 1
fi
local current_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
local yaml_agreed=$(python set "${current_directory}"/checkagree.py "${STORAGE_ROOT}/settings.yaml")
if [ "$yaml_agreed" -eq "true"]; then
return 0
fi
return 1
else
return 0
fi
}

View File

@ -22,6 +22,46 @@ if [ -z "${NONINTERACTIVE:-}" ]; then
\n\nI'm going to ask you a few questions.
\n\nTo change your answers later, just run 'sudo mailinabox' from the command line.
\n\nNOTE: You should only install this on a brand new Ubuntu installation 100% dedicated to Mail-in-a-Box. Mail-in-a-Box will, for example, remove apache2."
if [ -z "${I_AGREE_MAILINABOX:-}" ]; then
local config_agreed=$( check_config_agreed && echo "true" || echo "false")
if [ "$config_agreed" -eq "false"]; then
#makes sure the user is aware of our legal stuff.
message_box "Mail-in-a-Box Legal Notice" \
"Mail-in-a-Box, and/or its developers do not take any legal liability and/or responsibility for installations or this software.
\n\nPlease know this software is provided 'as-is', and users should not have any expectations from it.
\n\nBy installing this software, you may be automaticaly agreed to certain agreements, which you will still be legally held accountable for.
The legal agreements you will be automatically agreed to may include (but not limited to):
\n\n * Let's Encrypt Terms of Service.
\n\nBy continuing this installation, you agree to be legally accountable to research, read, understand and agree to any potential agreements this software
automatically agrees you to, or any agreements related to this software (including but not limited to: the Creative Commons Zero license in its Github
repository).
\n\nYou usually can discontinue installing this software by hitting 'ctrl + C'.
"
fi
fi
I_AGREE_MAILINABOX=$(/bin/true)
else
local config_agreed=$( check_config_agreed && echo "true" || echo "false")
if [ "$config_agreed" -eq "true"]; then
I_AGREE_MAILINABOX=$(/bin/true)
fi
#This is so a user can programmatically agree to our legal notice
if [ -z "${I_AGREE_MAILINABOX:-}" ]; then
echo "ERROR: You must agree to Mail-in-a-Box's Legal Notice. You can either:"
echo "run this in interactive mode; or"
echo "set I_AGREE_MAILINABOX variable before running."
exit 1;
fi
I_AGREE_MAILINABOX=$(/bin/true)
fi
# The box needs a name.
@ -184,14 +224,8 @@ if [ "$PRIMARY_HOSTNAME" = "auto" ]; then
PRIMARY_HOSTNAME=$(get_default_hostname)
fi
# Set STORAGE_USER and STORAGE_ROOT to default values (user-data and /home/user-data), unless
# we've already got those values from a previous run.
if [ -z "${STORAGE_USER:-}" ]; then
STORAGE_USER=$([[ -z "${DEFAULT_STORAGE_USER:-}" ]] && echo "user-data" || echo "$DEFAULT_STORAGE_USER")
fi
if [ -z "${STORAGE_ROOT:-}" ]; then
STORAGE_ROOT=$([[ -z "${DEFAULT_STORAGE_ROOT:-}" ]] && echo "/home/$STORAGE_USER" || echo "$DEFAULT_STORAGE_ROOT")
fi
set_storage_user;
set_storage_root;
# Show the configuration, since the user may have not entered it manually.
echo

View File

@ -57,6 +57,15 @@ chmod +x /usr/local/bin/mailinabox
# STORAGE_ROOT.
source setup/questions.sh
if [ -z "${I_AGREE_MAILINABOX:-}" ]; then
echo "ERROR: You must agree to Mail-in-a-Box's Legal Notice. You can either:"
echo "run this in interactive mode; or"
echo "set I_AGREE_MAILINABOX variable before running."
exit 1;
else
set_config_agreed;
fi
# Run some network checks to make sure setup on this machine makes sense.
# Skip on existing installs since we don't want this to block the ability to
# upgrade, and these checks are also in the control panel status checks.