psa-api-rpc-8.1.1-suse9.3.build81070404.14 T > D
, 0 @ a01ec13bbfbd8ee4d1c5cd4aa53d6ccf4fd62c97 |Ap3jXAE~ > 5 ? d - E : @ G b L G h G G
G G G G
G G k G G @
h
$
( k > q @ y B G G H G I G X , Y 4 Z h [ t \ x G ] G ^ s b k d o e t f z k | l C psa-api-rpc 8.1.1 suse9.3.build81070404.14 Plesk API RPC interface Plesk API provides the Plesk management interface for applications.
This package provides the HTTP RPC XML interface for controlling Plesk. F\bsuse93.plesk.ru +SWsoft Inc. Commercial license Tools http://www.swsoft.com/products/plesk linux noarch #!/bin/sh
#
# Copyright (c) 1999-2005 SWsoft Inc.
# All rights reserved
#
#
# Plesk script
#
remove_tmp_state()
{
if [ -d "/tmp/.state" ]; then
rm -Rf "/tmp/.state" >> $product_log 2>&1
fi
}
api_rpc_create_persistent_tables()
{
inten="create persistent database storage"
echo_try $inten
$mysql < ${PRODUCT_ROOT_D}/etc/api-rpc/api-rpc_db.sql
if [ "X$?" = "X0" ]; then
suc
else
warn "database initialization"
fi
}
#
# Upgrade triggers should be clever enough to recognize necessity of upgrade
#
upgrade_api_75()
{
if db_test_table secret_keys; then
# secret_keys was created - at least 8.0 version
return
fi
$mysql < ${PRODUCT_ROOT_D}/etc/api-rpc/api-rpc_db_upgrade_750.sql
}
upgrade_api_800()
{
if db_test_column_enum_value exp_event event_type exceeded; then
# 'exceeded' was added in 8.0.1
return
fi
$mysql < ${PRODUCT_ROOT_D}/etc/api-rpc/api-rpc_db_upgrade_800.sql
}
upgrade_api_801()
{
if db_test_column_enum_value exp_event obj_class domain_alias; then
# domain_alias was added in 8.0.1 update
return
fi
$mysql < ${PRODUCT_ROOT_D}/etc/api-rpc/api-rpc_db_upgrade_801.sql
}
#
# End of upgrade triggers
#
api_rpc_upgrade_persistent_tables()
{
inten="upgrade persistent database storage"
echo_try $inten
# As we don't know previous version of the package (for all packaging systems)
# all available database upgrade scripts should be executed.
upgrade_api_75 && \
upgrade_api_800 && \
upgrade_api_801
if [ "X$?" = "X0" ]; then
suc
else
warn "database upgrade"
fi
}
get_admin_passwd()
{
if [ -f "$mysql_passwd_file" ]; then
admin_passwd=`cat "$mysql_passwd_file"`
fi
if [ -z "$admin_passwd" ]; then
admin_passwd="$default_mysql_passwd"
fi
}
# db_test test_query awk_script
# Runs test_query and processes it with awk_script. If the output is
# not empty, return 0, otherwise return 1. Hint: supply '1' for
# awk_script to test just for the presence of any output.
db_test()
{
local any_db=
eval `sh_get_args '--any-db) any_db=yes;;'`
local test_query="$1"
local awk_script="$2"
if [ -n "$any_db" ]; then
local output="`mysql_raw_anydb -e \"$test_query\" 2>>\"$product_log\"`"
else
local output="`mysql_raw -e \"$test_query\" 2>>\"$product_log\"`"
fi
local status=$?
if [ "$status" -ne 0 ]; then
p_echo "$output"
die "run the following SQL query: $1"
fi
echo -n "$output" | awk -F '\t' -- "$awk_script" | test `wc -l` -ne 0
}
# db_test_table table
# Returns 0 if the table exists
db_test_table()
{
local table="$1"
db_test "SHOW TABLES LIKE '$table'" 1
}
# db_test_column_enum_value
# Returns O if table.column contains value in enum description
db_test_column_enum_value()
{
local table="$1"
local column="$2"
local value="$3"
db_test "DESC \`$table\` \`$column\`" "/[\'\"]$value[\'\"]/ { print 1 }"
}
check_mysql()
{
mysqld_status || mysqld_start
if ! ${MYSQL_BIN_D}/mysqladmin ${mysql_auth} ping >/dev/null; then
die "Fatal Error: cannot connect to mysql server"
fi
}
p_echo()
{
echo "$*" >> "$product_log" 2>&1
echo "$*"
}
pnnl_echo()
{
if [ -z $necho_defined ]; then
# set up echo
case "`echo 'x\c'`" in
'x\c')
echo="echo"
echo_keys=" -n"
nnl=
;;
x)
echo="echo"
echo_keys=
nnl="\c"
;;
*)
echo "ERROR: unable to set up echo."
;;
esac
necho_defined=true
fi
${echo} ${echo_keys} "$*${nnl}" >> "$product_log" 2>&1
${echo} ${echo_keys} "$*${nnl}"
}
keyupdate_failure_report()
{
if test -z "$KEYUPDATE_FAILURE_INFO"; then
return
fi
p_echo
p_echo " *****************************************************************************"
p_echo " * *"
p_echo " * ERROR: The $PRODUCT_NAME license failed to upgrade. The failure *"
p_echo " * follows: *"
p_echo
p_echo "$KEYUPDATE_FAILURE_INFO"
p_echo
p_echo " * If you did not request the automatic key upgrade, *"
p_echo " * please contact SWsoft, Inc sales department for assistance: *"
p_echo " * ${sales_email}. If you want to proceed with upgrade without *"
p_echo " * the license upgrade, please create an empty file *"
p_echo " * $prodkey *"
p_echo " * *"
p_echo " *****************************************************************************"
p_echo
}
die()
{
PACKAGE_SCRIPT_FAILED="$*"
if [ "X$trigger_uninstall" != "X1" ]; then
printf "\a\a"
p_echo
p_echo "ERROR while trying to $*"
echo "Check the error reason(see log file: ${product_log}), fix and try again"
p_echo
if [ "X$do_patch" != "X1" -a "X$do_reconfigure" != "X1" ]; then
p_echo "Aborting..."
p_echo
fi
fi
smart_undo_install
keyupdate_failure_report
selinux_close
exit 1
}
err()
{
if [ "X$trigger_uninstall" != "X1" ]; then
p_echo
p_echo "ERROR!"
p_echo "Check the error reason(see log file: ${product_log}), fix and try again"
p_echo
if [ "X$do_patch" != "X1" -a "X$do_reconfigure" != "X1" ]; then
p_echo "Exiting..."
p_echo
fi
fi
smart_undo_install
exit 1
}
# This function needs for some print warning when some services cannot restart
# if called with arg, then we add arg to variable SR_WARNING and print warning
# message for arg, else print warning message for SR_WARNING
service_restart_warning()
{
if [ "X$1" != "X" ]; then
if [ "X${SR_WARNING}" = "X" ]; then
SR_WARNING=$1
else
for i in ${SR_WARNING}; do
if [ "$i" = "$1" ]; then
break
fi
done
if [ "$1" != "$i" ]; then
SR_WARNING=$SR_WARNING" "$1
fi
fi
p_echo "WARNING!"
p_echo "Some problems occured when $1 restart, check it after installation/upgrade complete"
p_echo
p_echo "Continue..."
p_echo
else
if [ "X${SR_WARNING}" != "X" ]; then
p_echo "WARNING!"
p_echo "Some problems occured when following services restart:"
for i in ${SR_WARNING}; do
p_echo $i
done
p_echo "Don't forget to check it after installation/upgrade complete"
p_echo
p_echo "More information can be found in log file: ${product_log}"
p_echo
fi
fi
}
warn()
{
local inten
inten="$1"
p_echo
p_echo "WARNING!"
pnnl_echo "During the $inten found some problems"
echo "(see log file: ${product_log})"
p_echo
p_echo "Continue..."
p_echo
}
echo_try()
{
msg="$*"
pnnl_echo " Trying to $msg... "
}
suc()
{
p_echo "done"
}
mk_backup()
{
target="$1"
dup="$2"
opts="$3"
if [ -L "$target" ]; then
rm "$target"
elif [ -$opts "$target" ]; then
if [ ! -$opts "$target.$product_suffo" ]; then
case "$dup" in
mv)
mv -f $target $target.$product_suffo || die "mv -f $target $target.$product_suff"
;;
cp)
cp -fp $target $target.$product_suffo || die "cp -fp $target $target.$product_suff"
;;
*)
p_echo " mk_backup: wrong option -- must be 'cp' or 'mv'"
die "mk_backup"
;;
esac
else
case "$dup" in
mv)
mv -f $target $target.$product_suff || die "mv -f $target $target.$product_suff"
;;
cp)
cp -fp $target $target.$product_suff || die "cp -fp $target $target.$product_suff"
;;
*)
p_echo " mk_backup: wrong option -- must be 'cp' or 'mv'"
die "mk_backup"
;;
esac
fi
else
case "$opts" in
f|d)
;;
*)
p_echo " mk_backup: wrong option -- must be 'f' or 'd'"
die "mk_backup"
;;
esac
fi
}
detect_vz()
{
local vzcheck_file
PLESK_VZ=0
vzcheck_file="/proc/self/status"
if [ ! -f ${vzcheck_file} ]; then
return 1;
fi
grep -q -E '^envID\:[[:space:]]*([[:digit:]]+)$' < ${vzcheck_file} >/dev/null 2>&1
if [ $? -eq 0 ]; then
PLESK_VZ=1
return 0;
fi
return 1;
}
call_optional_function()
{
local type_output="`type \"$1\" 2>/dev/null | head -n 1`"
case "$type_output" in
*function)
"$@"
;;
*)
return 0
;;
esac
}
sh_get_args()
{
echo 'while true; do case "$1" in '"$1"'*) break;; esac; shift; done'
}
restart_super_server()
{
if [ -n "$CHROOTISH" ]; then
return 0
fi
inten="$action $super_server daemon"
echo_try "$inten"
case "$super_server" in
'xinetd')
case "$machine" in
linux)
$PRODUCT_RC_D/xinetd reload >> $product_log 2>&1
;;
*)
xinetd_pid=`$ps | grep xinetd | egrep "\?" | grep -v grep | head -1 | awk '{print $1}' -`
if [ "X${xinetd_pid}" = "X" ]; then
service_restart_warning "xinetd"
else
$K_USR2 $xinetd_pid >> $product_log 2>&1 && suc || die "$inten"
fi
;;
esac
;;
'inetd')
inetd_pid=`$ps | grep inetd | egrep "\?" | grep -v grep | head -1 | awk '{print $1}' -`
inten="restart inetd daemon"
echo_try "$inten"
if [ "X${inetd_pid}" = "X" ]; then
service_restart_warning "inetd"
else
$K_HUP $inetd_pid >> $product_log 2>&1 && suc || die "$inten"
fi
;;
esac
}
comment_service_xinetd()
{
#comment service records
local dir file service grep_res
service=$1
inten="comment out record for service $service"
echo_try "$inten"
for dir in $xinetd_dir; do
for file in $dir/*; do
grep_res=`grep "$service" $file`
case "$?" in
0)
awk "/^[[:space:]]*service[[:space:]]+$service($|[[:space:]]+)/,/.*}.*/ \
{ print \"#\"\$0; next; }
{print}
" <$file >$file.tmp &&
mv -f $file.tmp $file || die "$inten" >> $product_log 2>&1
restart_super_server
;;
*)
;;
esac
done;
done;
suc
}
comment_service_inetd()
{
local grep_res
service=$1
inten="comment out record for service $service"
echo_try "$inten"
grep_res=`grep "^$service[[:space:]]" $inetd_conf`
case "$?" in
0)
sed -e "s|^$service|##commented_by_psa $service|g" < "$inetd_conf" > "$inetd_conf.${product}_tmp" \
&& mv -f "$inetd_conf.${product}_tmp" "$inetd_conf" \
&& suc || die >> $product_log 2>&1
restart_super_server
;;
*)
p_echo " no record for service $service found in the $inetd_conf"
;;
esac
}
comment_service()
{
local service
service=$1
case "$super_server" in
'xinetd')
comment_service_xinetd "$service"
;;
'inetd')
comment_service_inetd "$service"
;;
*)
die "Super server type is undefined"
;;
esac
}
remove_xinetd()
{
local service file
service=$1;
rm -f $xinetd_dir/${service}_${product}
#uncomment old records
inten="comment out ${product} record for service $service"
for file in $xinetd_dir/*; do
awk "/^[[:space:]]*#[[:space:]]*service[[:space:]]+$service($|[[:space:]]+)/,/.*}.*/ \
{ print substr(\$0,2); next; }
{print}
" <$file >$file.tmp &&
mv -f $file.tmp $file >> $product_log 2>&1
done;
restart_super_server
}
remove_inetd()
{
local service
service=$1;
case "$service" in
ftp)
inten="restore ftp service record in the $inetd_conf"
sed -e "s|^ftp.*/${product}/ftpd/sbin/proftpd.*||g" \
-e "s|ftp.*/${prev_product}/ftpd/sbin/proftpd.*||g" \
< $inetd_conf > $inetd_conf.${product}_tmp \
&& mv -f $inetd_conf.${product}_tmp $inetd_conf >> $product_log 2>&1
;;
smtp)
inten="restore smtp service record in the $inetd_conf"
sed -e "s|^smtp.*$QMAIL_ROOT_D/qmail/bin/tcp-env.*tcp-env.*/qmail/bin/relaylock.*||g" \
-e "s|^smtp.*${product}/qmail/bin/tcp-env.*tcp-env.*/qmail/bin/relaylock.*||g" \
-e "s|smtp.*${prev_product}/qmail/bin/tcp-env.*tcp-env.*/qmail/bin/relaylock.*||g" \
< $inetd_conf > $inetd_conf.${product}_tmp \
&& mv -f $inetd_conf.${product}_tmp $inetd_conf >> $product_log 2>&1
;;
smtps)
inten="restore smtp service record in the $inetd_conf"
sed -e "s|^smtps.*$QMAIL_ROOT_D/qmail/bin/tcp-env.*tcp-env.*/qmail/bin/relaylock.*||g" \
-e "s|^smtps.*${product}/qmail/bin/tcp-env.*tcp-env.*/qmail/bin/relaylock.*||g" \
-e "s|smtps.*${prev_product}/qmail/bin/tcp-env.*tcp-env.*/qmail/bin/relaylock.*||g" \
< $inetd_conf > $inetd_conf.${product}_tmp \
&& mv -f $inetd_conf.${product}_tmp $inetd_conf >> $product_log 2>&1
;;
pop3)
inten="restore pop3 service record in the $inetd_conf"
sed -e "s|^pop[-]*3.*/qmail/bin/tcp-env.*tcp-env.*/qmail/bin/pop3$||g" \
-e "s|^pop[-]*3.*/qmail/bin/tcp-env.*tcp-env.*/qmail/bin/pop3$||g" \
< $inetd_conf > $inetd_conf.${product}_tmp \
&& mv -f $inetd_conf.${product}_tmp $inetd_conf >> $product_log 2>&1
;;
poppassd)
# poppassd stream tcp nowait root /usr/sbin/tcpd /${PRODUCT_ROOT_D}/admin/bin/poppassd
inten="restore poppassd service record in the $inetd_conf"
sed -e "s|^poppassd.*$PRODUCT_ROOT_D/admin/bin/poppassd.*||g" \
< $inetd_conf > $inetd_conf.${product}_tmp \
&& mv -f $inetd_conf.${product}_tmp $inetd_conf >> $product_log 2>&1
;;
esac
# uncomment old records
sed -e "s|^##commented_by_psa $service|$service|g" < $inetd_conf > $inetd_conf.${product}_tmp \
&& mv -f $inetd_conf.${product}_tmp $inetd_conf >> $product_log 2>&1
restart_super_server
}
remove_super_server()
{
local service
service=$1;
case "$super_server" in
xinetd)
remove_xinetd "$service"
;;
inetd)
remove_inetd "$service"
;;
esac
}
setup_xinetd()
{
local service file rbl_on rbl_server
service=$1;
rbl_on=$2;
rbl_server=$3;
#comment old records
comment_service "$service"
#setup
service=$1;
inten="set up record for service $service"
echo_try "$inten"
case "$service" in
ftp)
echo "
service ftp
{
socket_type = stream
protocol = tcp
wait = no
disable = no
user = root
instances = UNLIMITED
server = $PRODUCT_ROOT_D/ftpd/sbin/proftpd
server_args = -c $PRODUCT_ROOT_D/ftpd/etc/proftpd.conf
}" > "$xinetd_dir/ftp_${product}" || die "$inten"
;;
smtp)
case "$rbl_on" in
on)
echo "
service smtp
{
socket_type = stream
protocol = tcp
wait = no
disable = no
user = root
instances = UNLIMITED
server = $QMAIL_ROOT_D/bin/tcp-env
server_args = $RBLSMTPD $rbl_server $QMAIL_ROOT_D/bin/relaylock $QMAIL_ROOT_D/bin/qmail-smtpd $QMAIL_ROOT_D/bin/smtp_auth $TRUE_BIN $QMAIL_ROOT_D/bin/cmd5checkpw $TRUE_BIN
}" > "$xinetd_dir/smtp_${product}" || die "$inten"
;;
*)
echo "
service smtp
{
socket_type = stream
protocol = tcp
wait = no
disable = no
user = root
instances = UNLIMITED
server = $QMAIL_ROOT_D/bin/tcp-env
server_args = $QMAIL_ROOT_D/bin/relaylock $QMAIL_ROOT_D/bin/qmail-smtpd $QMAIL_ROOT_D/bin/smtp_auth $TRUE_BIN $QMAIL_ROOT_D/bin/cmd5checkpw $TRUE_BIN
}" > "$xinetd_dir/smtp_${product}" || die "$inten"
;;
esac
;;
smtps)
case "$rbl_on" in
on)
echo "
service smtps
{
socket_type = stream
protocol = tcp
wait = no
disable = no
user = root
instances = UNLIMITED
server = $QMAIL_ROOT_D/bin/tcp-env
server_args = $RBLSMTPD $rbl_server $QMAIL_ROOT_D/bin/relaylock $QMAIL_ROOT_D/bin/qmail-smtpd $QMAIL_ROOT_D/bin/smtp_auth $TRUE_BIN $QMAIL_ROOT_D/bin/cmd5checkpw $TRUE_BIN
}" > "$xinetd_dir/smtps_${product}" || die "$inten"
;;
*)
echo "
service smtps
{
socket_type = stream
protocol = tcp
wait = no
disable = no
user = root
instances = UNLIMITED
server = $QMAIL_ROOT_D/bin/tcp-env
server_args = $QMAIL_ROOT_D/bin/relaylock $QMAIL_ROOT_D/bin/qmail-smtpd $QMAIL_ROOT_D/bin/smtp_auth $TRUE_BIN $QMAIL_ROOT_D/bin/cmd5checkpw $TRUE_BIN
}" > "$xinetd_dir/smtps_${product}" || die "$inten"
;;
esac
;;
poppassd)
echo "
service poppassd
{
socket_type = stream
protocol = tcp
port = 106
wait = no
disable = no
user = root
instances = 1000
flags = KEEPALIVE
server = $PRODUCT_ROOT_D/admin/bin/poppassd
}" > "$xinetd_dir/poppassd_${product}" || die "$inten"
;;
esac
case "$machine" in
Darwin)
echo '#!/bin/sh
name_script="$0"
name_service='org.xinetd.xinetd'
case "$1" in
start)
echo "Plesk: Starting xinetd"
launchctl start "$name_service"
;;
stop)
echo "Plesk: Stopping xinetd"
launchctl stop "$name_service"
;;
restart)
$name_script stop
$name_script start
;;
*)
echo "Usage: xinetd [start|stop|restart]"
;;
esac
' > "$PRODUCT_RC_D/xinetd"
chmod 755 "$PRODUCT_RC_D/xinetd"
;;
*)
;;
esac
suc
}
setup_inetd()
{
local service rbl_on rbl_server
service=$1;
rbl_on=$2;
rbl_server=$3;
local ftp_rec smtp_rec pop3_rec
ftp_rec="ftp stream tcp nowait root $PRODUCT_ROOT_D/ftpd/sbin/proftpd proftpd -c $PRODUCT_ROOT_D/ftpd/etc/proftpd.conf"
case "$linux_distr" in
debian)
maxconn='.1000'
;;
*)
maxconn=""
;;
esac
case "$rbl_on" in
on)
smtp_rec="smtp stream tcp nowait$maxconn root $QMAIL_ROOT_D/bin/tcp-env tcp-env $RBLSMTPD $rbl_server $QMAIL_ROOT_D/bin/relaylock $QMAIL_ROOT_D/bin/qmail-smtpd $QMAIL_ROOT_D/bin/smtp_auth $QMAIL_ROOT_D/bin/true $QMAIL_ROOT_D/bin/cmd5checkpw $QMAIL_ROOT_D/bin/true"
smtps_rec="smtps stream tcp nowait$maxconn root $QMAIL_ROOT_D/bin/tcp-env tcp-env $RBLSMTPD $rbl_server $QMAIL_ROOT_D/bin/relaylock $QMAIL_ROOT_D/bin/qmail-smtpd $QMAIL_ROOT_D/bin/smtp_auth $QMAIL_ROOT_D/bin/true $QMAIL_ROOT_D/bin/cmd5checkpw $QMAIL_ROOT_D/bin/true"
;;
*)
smtp_rec="smtp stream tcp nowait$maxconn root $QMAIL_ROOT_D/bin/tcp-env tcp-env $QMAIL_ROOT_D/bin/relaylock $QMAIL_ROOT_D/bin/qmail-smtpd $QMAIL_ROOT_D/bin/smtp_auth $QMAIL_ROOT_D/bin/true $QMAIL_ROOT_D/bin/cmd5checkpw $QMAIL_ROOT_D/bin/true"
smtps_rec="smtps stream tcp nowait$maxconn root $QMAIL_ROOT_D/bin/tcp-env tcp-env $QMAIL_ROOT_D/bin/relaylock $QMAIL_ROOT_D/bin/qmail-smtpd $QMAIL_ROOT_D/bin/smtp_auth $QMAIL_ROOT_D/bin/true $QMAIL_ROOT_D/bin/cmd5checkpw $QMAIL_ROOT_D/bin/true"
;;
esac
case "$machine" in
BSD*)
poppassd_rec="poppassd stream tcp nowait/1000 root /usr/libexec/tcpd $PRODUCT_ROOT_D/admin/bin/poppassd"
;;
*)
poppassd_rec="poppassd stream tcp nowait/1000 root /usr/sbin/tcpd $PRODUCT_ROOT_D/admin/bin/poppassd"
;;
esac
case "$service" in
ftp)
if [ -x /usr/sbin/update-inetd ]; then
# Use Debian inetd config manipulation facility
/usr/sbin/update-inetd --remove "ftp"
/usr/sbin/update-inetd --add "$ftp_rec"
else
grep_res=`egrep "^ftp.*/${product}/ftpd/sbin/proftpd*." $inetd_conf`
inten="add ftp service (proftpd) record into the $inetd_conf file"
echo_try $inten
case "$grep_res" in
ftp*)
p_echo
p_echo " ftp service (proftpd) is already in the $inetd_conf"
;;
*)
comment_service $service
echo "$ftp_rec" >> $inetd_conf && suc || die
;;
esac
fi
;;
smtp)
if [ -x /usr/sbin/update-inetd ]; then
# Use Debian inetd config manipulation facility
/usr/sbin/update-inetd --remove "smtp"
/usr/sbin/update-inetd --add "$smtp_rec"
else
egrep "^smtp.*$QMAIL_ROOT_D/bin/tcp-env.*tcp-env.*$QMAIL_ROOT_D/bin/relaylock.*$" "$inetd_conf" >> $product_log 2>&1
case "$?" in
0)
sed -e "/^smtp/d" < "$inetd_conf" > "$inetd_conf.${product}_tmp" \
&& mv -f "$inetd_conf.${product}_tmp" "$inetd_conf" || die >> $product_log 2>&1
;;
1)
comment_service $service
;;
*)
err
;;
esac
inten="add smtp service record into the $inetd_conf file"
echo_try $inten
echo "$smtp_rec" >> $inetd_conf && suc || die $inten
fi
;;
smtps)
if [ -x /usr/sbin/update-inetd ]; then
# Use Debian inetd config manipulation facility
/usr/sbin/update-inetd --remove "smtps"
/usr/sbin/update-inetd --add "$smtps_rec"
else
egrep "^smtps.*$QMAIL_ROOT_D/bin/tcp-env.*tcp-env.*$QMAIL_ROOT_D/bin/relaylock.*$" "$inetd_conf" >> $product_log 2>&1
case "$?" in
0)
sed -e "/^smtps/d" < "$inetd_conf" > "$inetd_conf.${product}_tmp" \
&& mv -f "$inetd_conf.${product}_tmp" "$inetd_conf" || die >> $product_log 2>&1
;;
1)
comment_service $service
;;
*)
err
;;
esac
inten="add smtps service record into the $inetd_conf file"
echo_try $inten
echo "$smtps_rec" >> $inetd_conf && suc || die $inten
fi
;;
poppassd)
if [ -x /usr/sbin/update-inetd ]; then
# Use Debian inetd config manipulation facility
/usr/sbin/update-inetd --remove "poppassd"
/usr/sbin/update-inetd --add "$poppassd_rec"
else
# ^poppassd.*$PRODUCT_ROOT_D/admin/bin/poppassd.*
grep_res=`egrep "^poppassd.*$PRODUCT_ROOT_D/admin/bin/poppassd.*" $inetd_conf`
inten="add poppassd service record in the $inetd_conf"
echo_try $inten
case "$grep_res" in
poppassd*)
p_echo
p_echo " poppassd service is already in the $inetd_conf"
;;
*)
comment_service $service
echo "$poppassd_rec" >> $inetd_conf && suc || die
;;
esac
fi
;;
esac
}
setup_super_server()
{
local service rbl_on rbl_server
service=$1;
rbl_on=$2;
rbl_server=$3;
case "$super_server" in
xinetd)
setup_xinetd "$service" "$rbl_on" "$rbl_server"
;;
inetd)
setup_inetd "$service" "$rbl_on" "$rbl_server"
;;
esac
restart_super_server
}
# here goes functions
package_script_begin_rpm()
{
package_script_begin
}
package_script_end_rpm()
{
package_script_end
}
package_script_begin()
{
local title
set_common_params
product_log="/tmp/${PACKAGE_NAME}_${PACKAGE_VERSION}_${PACKAGE_RELEASE}_${process}.log"
product_problems_log="/tmp/${PACKAGE_NAME}_${PACKAGE_VERSION}_${PACKAGE_RELEASE}_problems.log"
title="`package_script_log_title`"
echo "START $title" >>"$product_log" \
&& echo "START $title" >>"$product_problems_log" \
&& chmod 600 "$product_log" "$product_problems_log" \
|| {
echo "Cannot write installation log $product_log, $product_problems_log" >&2
exit 1
}
problems_occured=0
read_conf
}
package_script_end()
{
local title
title="`package_script_log_title`"
echo "STOP $title" >>"$product_log"
echo "STOP $title" >>"$product_problems_log"
}
package_script_log_title()
{
local stage
case "$do_upgrade" in
0) stage="installing";;
1) stage="upgrading";;
*) stage="installing";;
esac
if [ -n "$PACKAGE_DEB_ACTION" ]; then
stage="$stage (deb action: $PACKAGE_DEB_ACTION)"
fi
echo "$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE $stage AT `date`"
}
# NAME VERSION RELEASE [DEB_ACTION]
package_script_call_main_function()
{
package_script_call_main_function_begin "$@"
for package_func in $1; do
if ! call_optional_function "$package_func"; then
break
fi
done
package_script_end_handler ok
}
package_script_call_main_function_begin()
{
PACKAGE_NAME="$2"
PACKAGE_VERSION="$3"
PACKAGE_RELEASE="$4"
PACKAGE_DEB_ACTION="$5"
package_script_begin_this_system
trap "package_script_end_handler error" HUP PIPE INT QUIT TERM EXIT
}
package_script_end_handler()
{
case "$1" in
error)
if [ -z "$PACKAGE_SCRIPT_FAILED" ]; then
PACKAGE_SCRIPT_FAILED="Package script failed"
fi
;;
ok) PACKAGE_SCRIPT_FAILED=
;;
esac
trap - EXIT
package_script_end_this_system
}
package_script_begin_this_system()
{
package_script_begin_rpm
}
package_script_end_this_system()
{
package_script_end_rpm
}
get_pid()
{
local i
ex_f="$1"
opt="$2"
owner="$3"
min_num=`expr 1`
case "$opt" in
false)
for i in `$ps_long | grep $ex_f | grep -v grep | grep -v httpsdctl | grep -v apachectl | awk '{print $2}' -`; do
min_num=$i
break
done
;;
true)
for i in `$ps_long | grep $ex_f | grep -v grep | grep -v httpsdctl | grep -v apachectl | grep "$owner" | awk '{print $2}' -`; do
min_num=$i
break
done
;;
*)
p_echo "get_pid: wrong parameter"
die "get_pid $ex_f $opt $owner"
;;
esac
common_var=$min_num
return $min_num
}
kill_pids()
{
ex_f="$1"
owner="$2"
for i in `$ps_long | grep $ex_f | grep -v grep | grep -v httpsdctl | grep -v apachectl | grep $owner | awk '{print $2}' -`; do
if [ $i -gt 1 ]; then
$K_TERM $i >> $product_log 2>&1
fi
done
}
delete_user()
{
local rm_user
rm_user="$1"
# if it is mailman user, remove its crontab from system
if [ "X${rm_user}" = "X${mailman_user}" ]; then
inten="remove crontab of ${rm_user}"
echo "y" | $crontab -u "${mailman_user}" -r >> $product_log 2>&1 || die "$inten"
fi
inten="remove user $rm_user"
echo_try "$inten"
case "$machine" in
BSD)
echo "y" | pw userdel $rm_user>> $product_log 2>&1 && suc
pwd_mkdb /etc/master.passwd >> $product_log 2>&1
;;
BSDI)
rmuser $rm_user>> $product_log 2>&1 && suc || die "$inten"
pwd_mkdb /etc/master.passwd >> $product_log 2>&1
;;
linux|solaris)
userdel $rm_user>> $product_log 2>&1 && suc || die "$inten"
;;
Darwin)
niutil -destroy / /users/"$rm_user" >> $product_log 2>&1 && suc || die "$inten"
reload_darwin_netinfo
;;
esac
}
delete_group()
{
local rm_group
rm_group="$1"
inten="remove group $rm_group"
echo_try "$inten"
case "$machine" in
BSD)
pw groupdel $rm_group>> $product_log 2>&1
pwd_mkdb /etc/master.passwd >> $product_log 2>&1
;;
BSDI)
rmgroup $rm_group>> $product_log 2>&1
pwd_mkdb /etc/master.passwd >> $product_log 2>&1
;;
linux|solaris)
mk_backup "/etc/group" cp f
if [ -f "/etc/group" ]; then
sed -e "/$rm_group/d" < /etc/group > /etc/group.tmp || die $inten
mv -f /etc/group.tmp /etc/group >> $product_log 2>&1
if [ "$?" -ne 0 ]; then
rsr_backup "/etc/group" cp f
die $inten
fi
fi
# groupdel $rm_group>> $product_log 2>&1
;;
Darwin)
niutil -destroy / /groups/"$rm_group" >> $product_log 2>&1 && suc || die "$inten"
reload_darwin_netinfo
;;
esac
suc
}
reload_darwin_netinfo()
{
if [ -f /var/run/memberd.pid ]; then
kill -HUP `cat /var/run/memberd.pid`
sleep 1
else
SystemStarter start memberd
sleep 1
fi
return 0
}
initial_conf()
{
DEMO_VERSION="no"
PRODNAME="psa"
PRODUCT_NAME="Plesk"
product_full="Plesk"
PRODUCT_FULL_NAME="Plesk"
product_etc="/etc/${PRODNAME}"
prod_conf_t="/etc/psa/psa.conf"
prodkey="$product_etc/$PRODNAME.key"
minimal_changes="0"
MYSQL_VERS="4.1.18"
POSTGRESQL_VERS="7.4.11"
EXTERNAL_PACKAGES=""
EXTERNAL_PACKAGES_DIR=""
BUILDER_UID="10007"
PERL5LIB="/usr/local/psa/lib/perl5/site_perl/5.8.6:/usr/local/psa/lib/perl5/site_perl/5.8.6/i586-linux-thread-multi"
export PERL5LIB
product_bs=Plesk
support_contact="http://www.swsoft.com/support"
sales_email="sales@swsoft.com"
product_version="8.1.1"
product_db_version="0811"
product_build="81070404.14"
conceived_os_vendor=SuSE
conceived_os_version="9.3"
osrels="suse9.3"
# This variable contains all versions, which is supported by
# cumulative upgrade
known_product_versions="20 25 50 60 70 71 75 80 81"
prev_product="plesk"
prev_clients_group="${prev_product}cln"
# GID for mailman
mm_mailgroup=12
# plesk default password
if [ "X$DEMO_VERSION" = "Xyes" ]; then
PRODUCT_DEFAULT_PASSWORD="plesk"
else
PRODUCT_DEFAULT_PASSWORD="setup"
fi
my_name_0="`pwd`"
if [ $? -ne 0 ]; then
echo "Unable to determine current working directory."
echo "Please fix the problem and run installation again."
exit 1
fi
my_name_1="`basename ""$0""`"
my_name_2=`echo ""$0""|sed -e "s/^\.\///"`
echo $my_name_2 | egrep '^/' >/dev/null 2>&1
case "$?" in
0)
my_name="$my_name_2"
;;
1)
my_name="$my_name_0"/"$my_name_2"
;;
*)
echo "Unable to determine the name of installer."
echo "Please fix the problem and run installation again."
exit 1
;;
esac
}
read_conf()
{
product_default_conf
initial_conf
if [ -s $prod_conf_t ]; then
tmp_var=`perl -e 'undef $/; $_=<>; s/#.*$//gm;
s/^\s*(\S+)\s*/$1=/mg;
print' $prod_conf_t`
eval $tmp_var
else
if [ "X$do_upgrade" = "X1" ]; then
[ 0$ignore_miss_conf -ne 1 ] && p_echo "Unable to find product configuration file: $prod_conf_t"
return 1
fi
fi
return 0
}
product_conf()
{
initial_conf
product_default_conf
APACHE_ROOT="/usr"
TRUE_BIN="$QMAIL_ROOT_D/bin/true"
MYSQL_SOCKETS="/var/lib/mysql/mysql.sock /tmp/mysql.sock /var/run/mysqld/mysqld.sock"
}
#default values
product_default_conf()
{
PRODUCT_ROOT_D=/usr/local/psa
PRODUCT_RC_D=/etc/init.d
PRODUCT_ETC_D=/usr/local/psa/etc
HTTPD_VHOSTS_D=/srv/www/vhosts
HTTPD_CONF_D=/etc/apache2
HTTPD_INCLUDE_D=/etc/apache2/conf.d
HTTPD_BIN_D=/usr/bin
HTTPD_LOG_D=/var/log/apache2
QMAIL_ROOT_D=/var/qmail
QMAIL_MAILNAMES_D=/var/qmail/mailnames
RBLSMTPD=/usr/sbin/rblsmtpd
COURIER_IMAP_ROOT_D=/
FTPD_CONF=/etc/proftpd.conf
FTPD_CONF_INC=/etc/proftpd.include
FTPD_BIN_D=/usr/bin
FTPD_VAR_D=/var/run/proftpd
NAMED_RUN_ROOT_D=/var/lib/named
NAMED_OPTIONS_CONF=/etc/named.conf.include.plesk-options
NAMED_ZONES_CONF=/etc/named.conf.include.plesk-zones
WEB_STAT=/usr/bin/webalizer
LOGROTATE=/usr/local/psa/logrotate/sbin/logrotate
MYSQL_VAR_D=/var/lib/mysql
MYSQL_BIN_D=/usr/bin
PGSQL_DATA_D=/var/lib/pgsql/data
PGSQL_BIN_D=/usr/bin
DUMP_D=/var/lib/psa/dumps
MAILMAN_ROOT_D=/usr/lib/mailman
MAILMAN_VAR_D=/var/lib/mailman
PYTHON_BIN=/usr/bin/python2.4
CATALINA_HOME=/usr/share/tomcat5
DRWEB_ROOT_D=/opt/drweb
DRWEB_ETC_D=/etc/drweb
GPG_BIN=/usr/bin/gpg
TAR_BIN=/bin/tar
CURL_CA_BUNDLE_FILE=/usr/share/curl/curl-ca-bundle.crt
AWSTATS_ETC_D=/etc/awstats
AWSTATS_BIN_D=/srv/www/cgi-bin/awstats
AWSTATS_TOOLS_D=/usr/share/awstats
AWSTATS_DOC_D=/usr/share/apache2/icons/awstats
OPENSSL_BIN=/usr/bin/openssl
}
#Need for register/unregister services into /etc/rc.conf for BSD OSes.
#Create or change strings such as service_option_variable="variable"
rc_service()
{
local service="$1"
local option="$2"
local variable="$3"
local comment="$4"
local config="/etc/rc.conf"
if [ "X$variable" = "Xdefault" ]; then
remove_option_string "${service}_${option}" "$config"
return 0
fi
if [ ! -f /etc/rc.conf ]; then
die 'File /etc/rc.conf not found!'
fi
if [ "X$service" = "X" -o "X$option" = "X" -o "X$variable" = "X" ]; then
die
fi
local flag="`grep "${service}_${option}" $config`"
if [ "X$flag" = "X" ]; then
if [ "X$comment" = "Xyes" ]; then
echo "#Option for $service created by Plesk installer." >> $config
fi
echo "${service}_${option}=\"${variable}\"" >> $config || die
else
sed -i "" -e 's|\('"${service}_${option}"'.*=\"\).*|\1'"${variable}"'\"|' $config || die
fi
return 0
}
remove_option_string()
{
#using: remove_option_string