+echo " outconf: \"$outconf\""
+echo " apache_conf:\"$apache_conf\""
+echo " card_hand: $card_hand"
+echo " players_n: $players_n"
+echo " tables_n: $tables_n"
+echo " tables_auth_n: $tables_auth_n"
+echo " brisk_auth_conf: \"$brisk_auth_conf\""
+echo " brisk_debug:\"$brisk_debug\""
+echo " web_path: \"$web_path\""
+echo " ftok_path: \"$ftok_path\""
+echo " legal_path: \"$legal_path\""
+echo " proxy_path: \"$proxy_path\""
+echo " prefix_path:\"$prefix_path\""
+echo " brisk_conf: \"$brisk_conf\""
+echo " usock_path: \"$usock_path\""
+echo " sys_user: \"$sys_user\""
+echo " web_only: \"$web_only\""
+
+if [ ! -z "$outconf" ]; then
+ (
+ echo "#"
+ echo "# Produced automatically by brisk::INSTALL.sh"
+ echo "#"
+ echo "apache_conf=$apache_conf"
+ echo "card_hand=$card_hand"
+ echo "players_n=$players_n"
+ echo "tables_n=$tables_n"
+ echo "tables_auth_n=$tables_auth_n"
+ echo "brisk_auth_conf=\"$brisk_auth_conf\""
+ echo "brisk_debug=\"$brisk_debug\""
+ echo "web_path=\"$web_path\""
+ echo "ftok_path=\"$ftok_path\""
+ echo "proxy_path=\"$proxy_path\""
+ echo "legal_path=\"$legal_path\""
+ echo "prefix_path=\"$prefix_path\""
+ echo "brisk_conf=\"$brisk_conf\""
+ echo "usock_path=\"$usock_path\""
+ echo "sys_user=\"$sys_user\""
+ echo "web_only=\"$web_only\""
+ ) > "$outconf"
+fi
+
+max_players=$((40 + players_n * tables_n))
+
+if [ "$action" = "system" ]; then
+ scrname="$(echo "$prefix_path" | sed 's@^/@@g;s@/$@@g;s@/@_@g;')"
+ echo
+ echo "script name: [$scrname]"
+ echo "brisk path: [$web_path]"
+ echo "private path: [$legal_path]"
+ echo "system user: [$sys_user]"
+ echo
+ read -p "press enter to continue" sure
+ cp bin/brisk-init.sh brisk-init.sh.wrk
+ sed -i "s@^BPATH=.*@BPATH=\"${web_path}\"@g;s@^PPATH=.*@PPATH=\"${legal_path}\"@g;s@^SSUFF=.*@SSUFF=\"${scrname}\"@g;s@^BUSER=.*@BUSER=\"${sys_user}\"@g" brisk-init.sh.wrk
+
+ su -c "cp brisk-init.sh.wrk /etc/init.d/${scrname}"
+
+ rm brisk-init.sh.wrk
+ echo
+ echo "... DONE."
+ echo "DON'T FORGET: after the first installation you MUST configure your run-levels accordingly"
+ echo
+ echo "Example: su -c 'update-rc.d $scrname defaults'"
+ echo
+ exit 0
+fi
+#
+# Pre-check
+#
+# check for etc path existence
+dsta="$(dirname "$web_path")"
+etc_path="$(searchetc "$dsta" Etc)"
+if [ $? -ne 0 ]; then
+ echo "Etc directory not found"
+ exit 1
+fi