Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 45922 Details for
Bug 60564
verlihub-0.9.7.ebuild (New Package)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
new initscript. supports multihub setups.
verlihub.hub0 (text/plain), 8.24 KB, created by
Daniel Marmander
on 2004-12-13 09:29:45 UTC
(
hide
)
Description:
new initscript. supports multihub setups.
Filename:
MIME Type:
Creator:
Daniel Marmander
Created:
2004-12-13 09:29:45 UTC
Size:
8.24 KB
patch
obsolete
>#!/sbin/runscript > >#This will make the sccript use the proper configuration file. >HUB=`expr match "${1}" '.*\(hub.*\)'` >source /etc/conf.d/`expr match "${1}" '.*/\(.*\)\.hub.*'` >#End of conf.d-part > >#Since verlihub must be started in it's configuration dir, we must save pwd: >CUR_DIR=`pwd` > > >#Static configuration: >dbconf_file="dbconfig" >needfiles="${dbconf_file}" >wantfiles="motd faq rules help_usr help_reg help_vip help_op help_cheef help_master help_admin" >PID_DIR=/var/run/verlihub/ >LOG_DIR=/var/log/verlihub/ >#End static configuration > >depend() { > need net mysql >} > >setup_vars() { > local i hub=${1} > eval conf_dir_HUB=\"\$\{conf_dir_${hub}\}\" > eval port_HUB=\"\$\{port_${hub}\}\" > eval opts_HUB=\"\$\{opts_${hub}\}\" > pid_HUB=${PID_DIR}${hub}.pid > log_HUB=${LOG_DIR}${hub}.log > err_HUB=${LOG_DIR}${hub}.err >} > >authbind_vars(){ > local i db_host=`cat ${conf_dir_HUB}/${dbconf_file}|grep db_host|cut -d " " -f 3` > local i db_user=`cat ${conf_dir_HUB}/${dbconf_file}|grep db_user|cut -d " " -f 3` > local i db_pass=`cat ${conf_dir_HUB}/${dbconf_file}|grep db_pass|cut -d " " -f 3` > local i db_data=`cat ${conf_dir_HUB}/${dbconf_file}|grep db_data|cut -d " " -f 3` > local i extra_listen_ports=`mysql -h ${db_host} -u ${db_user} -p${db_pass} ${db_data} -e \ > "select val from SetupList where var = 'extra_listen_ports';"| \ > tr -cd '0-9 '` > ports="${port_HUB} ${extra_listen_ports}" >} > >randstr() { > case ${1} in > "-l") length=${2}; shift 2 ;; > *) length=1 ;; > esac > _RANDSTR="" > while [ ${#_RANDSTR} -lt ${length} ] ; do > eval _RANDSTR=${_RANDSTR}${sep}\${$(( ${RANDOM} % $# + 1 ))} > done >} > > >new_config(){ > #Since ${conf_dir_HUB} did not exist, following files/symlinks can be created with no further checks. > mkdir -p ${conf_dir_HUB} > ln -s /etc/verlihub/plugins ${conf_dir_HUB}/ > ln -s ${conf_dir_HUB} ${conf_dir_HUB}/.verlihub > > #Create random password. > local lower="a b c d e f g h i j k l m n o p q r s t u v w x y z" > local upper="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" > local numbers="0 1 2 3 4 5 6 7 8 9" > randstr -l 32 ${upper} ${lower} ${numbers} > > #Set database configuration > local i db_pass=${_RANDSTR} > local i db_host="localhost" > local i db_user="verli${HUB}" > local i db_data="verli${HUB}" > einfo "Creating ${conf_dir_HUB}/${dbconf_file}" > echo "db_host = ${db_host}" > ${conf_dir_HUB}/${dbconf_file} > echo "db_user = ${db_user}" >> ${conf_dir_HUB}/${dbconf_file} > echo "db_pass = ${db_pass}" >> ${conf_dir_HUB}/${dbconf_file} > echo "db_data = ${db_data}" >> ${conf_dir_HUB}/${dbconf_file} > >} > >new_database() { > local i verbose=${1} > local i db_host=`cat ${conf_dir_HUB}/${dbconf_file}|grep db_host|cut -d " " -f 3` > local i db_user=`cat ${conf_dir_HUB}/${dbconf_file}|grep db_user|cut -d " " -f 3` > local i db_pass=`cat ${conf_dir_HUB}/${dbconf_file}|grep db_pass|cut -d " " -f 3` > local i db_data=`cat ${conf_dir_HUB}/${dbconf_file}|grep db_data|cut -d " " -f 3` > > err_msg=`mysql -h ${db_host} -u ${db_user} -p${db_pass} ${db_data} -e "QUIT" 2>&1` > err=`expr match "${err_msg}" 'ERROR\ \([0-9]*\).*'` > > if ( [ "${err}" == "" ] && [ "${verbose}" != "verbose" ] ) ; then > #everything seems ok. (Future checks include version check) > return 0 > else > einfo "Database error occured. Trying to fix." > fi ; > > einfo "Give root password to mysql." > read mysql_root_pwd > > #Check once again if database exists, this time as root: > err_msg=`mysql -u root -h ${db_host} -p${mysql_root_pwd} ${db_data} -e "QUIT" 2>&1` > err=`expr match "${err_msg}" 'ERROR\ \([0-9]*\).*'` > #ERROR 1045: Access denied for user > #ERROR 1049: Unknown database > > if ( [ "${err}" == "" ] ) ; then > #Database exists. > einfo "Database ${db_data} already exists." > #Future version check function, and corresponding db updates, will be placed here. > while ( [ -z "" ] ) ; do > read -p "Abort, Ignore, Overwrite [A/i/o]?:" option > if ( [ "${option}" == "a" ] || [ "${option}" == "A" ] ) ; then > #Abort > eerror "Operation aborted." > return 1 > elif ( [ "${option}" == "i" ] || [ "${option}" == "I" ] ) ; then > #Ignore > einfo "Skipping database creation." > return 0 > elif ( [ "${option}" == "o" ] || [ "${option}" == "O" ] ) ; then > #Overwrite > #Drop database, create new and populate. > einfo "Overwriting mysql database." > mysql -u root -h ${db_host} -p${mysql_root_pwd} -e "\ > DROP DATABASE ${db_data}; \ > CREATE DATABASE ${db_data}; \ > GRANT ALL PRIVILEGES ON ${db_data}.* TO ${db_user}@${db_host} IDENTIFIED BY '${db_pass}'; \ > FLUSH PRIVILEGES;" || die "Could not connect to mysql database." > mysql -h ${db_host} -u ${db_user} -p${db_pass} ${db_data} < /etc/verlihub/dbdump.sql > echo -n "Set hub master nickname:" > read hub_master > echo -n "Set hub master password:" > read master_pwd > mysql -h ${db_host} -u ${db_user} -p${db_pass} ${db_data} -e \ > "INSERT INTO reglist (reg_date,reg_op,nick,class,login_pwd,pwd_change,pwd_crypt) \ > VALUES (unix_timestamp(now()),'admin_root','${hub_master}',10,encrypt('${master_pwd}'),0,1)" > return 0 > fi ; > done ; > elif ( [ "${err}" == "1045" ] ) ; then > #Bad password and/or username > eerror "mySQL: Access denied for user: '${db_user}@${db_host}' (Using password: YES)" > return 1 > elif ( [ "${err}" == "1049" ] ) ; then > #Database unknown (not existing), login correct. This is the "first setup" case. Create db and populate it. > mysql -u root -h ${db_host} -p${mysql_root_pwd} -e "\ > CREATE DATABASE ${db_data}; \ > GRANT ALL PRIVILEGES ON ${db_data}.* TO ${db_user}@${db_host} IDENTIFIED BY '${db_pass}'; \ > FLUSH PRIVILEGES;" || ( eerror "Could not connect to mysql database." ; return 1 ) > einfo "Creating mysql database." > mysql -h ${db_host} -u ${db_user} -p${db_pass} ${db_data} < /etc/verlihub/dbdump.sql > echo -n "Set hub master nickname:" > read hub_master > echo -n "Set hub master password:" > read master_pwd > mysql -h ${db_host} -u ${db_user} -p${db_pass} ${db_data} -e \ > "INSERT INTO reglist (reg_date,reg_op,nick,class,login_pwd,pwd_change,pwd_crypt) \ > VALUES (unix_timestamp(now()),'admin_root','${hub_master}',10,encrypt('${master_pwd}'),0,1)" > return 0 > else > eerror "Unknown mySQL error: ${err_msg}" > return 1 > fi ; > >} > > >start(){ > #Get setup variables > setup_vars ${HUB} || return 1 > ebegin "Bringing ${HUB} up..." > if [ ! -d "${conf_dir_HUB}" ]; then > einfo "${conf_dir_HUB} does not exist. Create new hub setup?" > local i answer="" > while ( [ -z "${answer}" ] ) ; do > read -p "[Y/n]:" new > if ( [ "${new}" == "y" ] || [ "${new}" == "Y" ] ) ; then > new_config || return 1 > new_database "verbose" || return 1 > answer="yes" > elif ( [ "${new}" == "n" ] || [ "${new}" == "N" ] ) ; then > die "Correct /etc/conf.d/verlihub and try to start again." > fi ; > done ; > fi ; > for f in $needfiles ; do > file=${conf_dir_HUB}/$f > if [ ! -e "${file}" ]; then > eerror "Missing file $file" > return 1 > fi ; > done ; > #Check if database is ok. > new_database || return 1 > for f in $wantfiles ; do > file=${conf_dir_HUB}/$f > if [ ! -e "${file}" ]; then > einfo "Missing file $file" > fi ; > done ; > if [ ! -e "${err_HUB}" ]; then > touch ${err_HUB} > fi ; > if [ ! -e "${log_HUB}" ]; then > touch ${log_HUB} > fi ; > > mv -f ${err_HUB} ${err_HUB}.old > mv -f ${log_HUB} ${log_HUB}.old > touch ${err_HUB} > touch ${log_HUB} > > #Find out if authbind is installed,and use it to execute as "nobody" if possible. > authbind=`which authbind` > if ( [ -e "${authbind}" ] ); then > einfo "Executing as nobody" > authbind_vars > uid=`id -u nobody` > for port in ${ports}; do > touch /etc/authbind/byport/${port} > chown nobody:nobody /etc/authbind/byport/${port} > chmod 700 /etc/authbind/byport/${port} > done ; > chown ${uid} ${err_HUB} > chown ${uid} ${log_HUB} > cd ${conf_dir_HUB} > start-stop-daemon --start --quiet --make-pidfile --pidfile ${pid_HUB} \ > --chuid ${uid} --exec ${authbind} /usr/bin/verlihub ${port_HUB} ${opts_HUB} > \ > ${log_HUB} 2 > ${err_HUB} & > cd ${CUR_DIR} > > else > einfo "Executing as root" > cd ${conf_dir_HUB} > start-stop-daemon --start --quiet --make-pidfile --pidfile ${pid_HUB} \ > --exec /usr/bin/verlihub ${port_HUB} ${opts_HUB} > ${log_HUB} 2 > ${err_HUB} & > cd ${CUR_DIR} > fi ; >} > >stop() { > setup_vars ${HUB} > authbind_vars > uid=`id -u nobody` > for port in ${ports}; do > rm -f /etc/authbind/byport/${port} > done ; > ebegin "Bringing ${HUB} down..." > start-stop-daemon --stop --quiet --pidfile ${pid_HUB} > eend $? >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 60564
:
37543
|
43645
|
43859
|
43860
|
43861
|
45921
| 45922 |
101145
|
101146
|
101147
|
101148
|
157609