Author: doogie
Date: Sat Apr 18 06:39:34 2009 New Revision: 766249 URL: http://svn.apache.org/viewvc?rev=766249&view=rev Log: The admin port, and admin key, are now saved in a config file, and no longer passed on the ofbiz command line. Additionally, the port can be changed during install. Plus, the admin key is randomized to something different, if it isn't already set during an install or an upgrade. Modified: ofbiz/trunk/debian/ofbiz-framework.config ofbiz/trunk/debian/ofbiz-framework.ofbiz.init ofbiz/trunk/debian/ofbiz-framework.postinst ofbiz/trunk/debian/ofbiz-framework.postrm Modified: ofbiz/trunk/debian/ofbiz-framework.config URL: http://svn.apache.org/viewvc/ofbiz/trunk/debian/ofbiz-framework.config?rev=766249&r1=766248&r2=766249&view=diff ============================================================================== --- ofbiz/trunk/debian/ofbiz-framework.config (original) +++ ofbiz/trunk/debian/ofbiz-framework.config Sat Apr 18 06:39:34 2009 @@ -45,7 +45,28 @@ fi return 1; } -ofbiz_admin_port="10523" +get_random_chars() { + ( + LANG=C + LC_ALL=C + length="$1" + chars="" + while :; do + needed_length=$((${length} - ${#chars})) + chars="$chars$(dd if=/dev/urandom count="${needed_length}" bs=1 2>/dev/null | sed -n -e 's/[^[:alnum:]]//g;p;q')" + if [ "${#chars}" -ge "$length" ]; then + break + fi + done + echo $chars + ) +} +if [ -r "/etc/ofbiz/debconf.cfg" ]; then + eval `sed -n 's/^ofbiz\.admin\.\(port\|key\)=\(.*\)/ofbiz_admin_\1=\2;/p' "/etc/ofbiz/debconf.cfg" ` +fi +if [ "z" = "z$ofbiz_admin_port" ]; then + ofbiz_admin_port="10523" +fi #env LANG=C LC_ALL=C sed -n -e 's/[^[:alnum:]]//g;p;q' < /dev/urandom | cut -b1-12 #db_set ofbiz/admin-password ofbiz || true set_if ofbiz/admin-user "$ofbiz_admin_user" || true @@ -82,3 +103,22 @@ ;; esac db_stop +if [ "z" = "z$ofbiz_admin_port" ]; then + ofbiz_admin_port="10523" +fi +if [ "z" = "z$ofbiz_admin_key" ]; then + ofbiz_admin_key="$(get_random_chars 32)" +fi +if [ -e "/etc/ofbiz/debconf.cfg" ]; then + sed -i \ + -e "s/^ofbiz.admin.port=\".*\"\$/ofbiz.admin.port=\"$ofbiz_admin_port\"/" \ + -e "s/^ofbiz.admin.key=\".*\"\$/ofbiz.admin.key=\"$ofbiz_admin_key\"/" \ + "/etc/ofbiz/debconf.cfg" +else + cat > "/etc/ofbiz/debconf.cfg.new" << _EOF_ +ofbiz.admin.port=$ofbiz_admin_port +ofbiz.admin.key=$ofbiz_admin_key +_EOF_ + chmod 640 "/etc/ofbiz/debconf.cfg.new" + mv "/etc/ofbiz/debconf.cfg.new" "/etc/ofbiz/debconf.cfg" +fi Modified: ofbiz/trunk/debian/ofbiz-framework.ofbiz.init URL: http://svn.apache.org/viewvc/ofbiz/trunk/debian/ofbiz-framework.ofbiz.init?rev=766249&r1=766248&r2=766249&view=diff ============================================================================== --- ofbiz/trunk/debian/ofbiz-framework.ofbiz.init (original) +++ ofbiz/trunk/debian/ofbiz-framework.ofbiz.init Sat Apr 18 06:39:34 2009 @@ -63,9 +63,10 @@ PIDFILE=/var/run/ofbiz.pid CLASS=org.ofbiz.base.start.Start -ADMIN_PORT=10523 -ADMIN_KEY=so3du5kasd5dn -PROPS="-Dofbiz.admin.port=$ADMIN_PORT -Dofbiz.admin.key=$ADMIN_KEY" +PROPS="" +if [ -f "/etc/ofbiz/debconf.cfg" ]; then + PROPS="$PROPS -Dofbiz.system.props=/etc/ofbiz/debconf.cfg" +fi if [ "x$JAVA_HOME" == x ]; then if [ "x$JAVA_HOMES" != x ]; then Modified: ofbiz/trunk/debian/ofbiz-framework.postinst URL: http://svn.apache.org/viewvc/ofbiz/trunk/debian/ofbiz-framework.postinst?rev=766249&r1=766248&r2=766249&view=diff ============================================================================== --- ofbiz/trunk/debian/ofbiz-framework.postinst (original) +++ ofbiz/trunk/debian/ofbiz-framework.postinst Sat Apr 18 06:39:34 2009 @@ -121,7 +121,10 @@ ofbiz_admin_key="$(get_random_chars 32)" ofbiz_readers="" fi - +if [ -r "/etc/ofbiz/debconf.cfg" ]; then + chown root:ofbiz "/etc/ofbiz/debconf.cfg" + eval `sed -n 's/^ofbiz\.admin\.\(port\|key\)=\(.*\)/ofbiz_admin_\1=\2;/p' "/etc/ofbiz/debconf.cfg" ` +fi if [ "$1" = "triggered" ]; then run_seed="" for trigger in $2; do Modified: ofbiz/trunk/debian/ofbiz-framework.postrm URL: http://svn.apache.org/viewvc/ofbiz/trunk/debian/ofbiz-framework.postrm?rev=766249&r1=766248&r2=766249&view=diff ============================================================================== --- ofbiz/trunk/debian/ofbiz-framework.postrm (original) +++ ofbiz/trunk/debian/ofbiz-framework.postrm Sat Apr 18 06:39:34 2009 @@ -29,7 +29,7 @@ case "$1" in (purge) - rm -f /etc/ofbiz/dbc-debconf.cfg + rm -f /etc/ofbiz/debconf.cfg /etc/ofbiz/dbc-debconf.cfg if which ucf >/dev/null; then ucf --purge /etc/ofbiz/dbc-debconf.cfg; fi if which ucfr >/dev/null; then ucfr --purge ofbiz /etc/ofbiz/dbc-debconf.cfg; fi find /var/log/ofbiz -mindepth 1 -maxdepth 1 -print0 | xargs -0 --no-run-if-empty rm -rf |
Free forum by Nabble | Edit this page |