📄 copi.funcs
字号:
#!/bin/bash# $Id: copi.funcs,v 1.3 2001/01/15 22:24:26 tom Exp $# ComeOn Point Functions! v0.9.2# - usate da vari altri moduli ComeOn Point...## AUTHOR: Beppe (beppe.dem@nsm.it)## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.#HOST=`hostname`DOMAIN=`hostname -d`PKTNAME="ComeOn Point Installer!"COMEONDIR=/usr/lib/ComeOnAKASETUP=$COMEONDIR/point/.akasetupCOPIUSER=$COMEONDIR/point/.copi.userEMSIFILE=$COMEONDIR/point/.emsiPNTSETUP=$COMEONDIR/point/.pntsetupmkstemp() { eval 'tmp_'$1'=`tempfile 2>/dev/null` || tmp_'$1'=/tmp/'$1'$$'}# Args: [start_uid]# Returns: $FOUND_UIDfind_unused_uid() { if [ $1 ]; then FOUND_UID=$1 else FOUND_UID=501 fi while [ "`cut -f3 -d: /etc/passwd | grep -x $FOUND_UID`" ] do FOUND_UID=$[$FOUND_UID+1] done}int2fido() { _RETVAL="`echo $1 | cut -f3 -d. | cut -c2-`:\`echo $1 | cut -f2 -d. | cut -c2-`/\`echo $1 | cut -f1 -d. | cut -c2-`"}int2fidonet() { _RETVAL="`echo $1 | cut -f3 -d. | cut -c2-`:\`echo $1 | cut -f2 -d. | cut -c2-`/\`echo $1 | cut -f1 -d. | cut -c2-`@\`echo $1 | cut -f4- -d.`"}fido2int() { _RETVAL="f\`echo $1 | cut -f2 -d '/'`.n\`echo $1 | cut -f1 -d '/' | cut -f2 -d:`.z\`echo $1 | cut -f1 -d '/' | cut -f1 -d:`"}fidonet2int() { _RETVAL="f\`echo $1 | cut -f2 -d/ | cut -f1 -d@`.n\`echo $1 | cut -f1 -d/ | cut -f2 -d:`.z\`echo $1 | cut -f1 -d/ | cut -f1 -d:`.\`echo $1 | cut -f2 -d@`"}fidonetpoint2int() { _RETVAL="p\`echo $1 | cut -f2 -d. | cut -f1 -d@`.f\`echo $1 | cut -f2 -d/ | cut -f1 -d.`.n\`echo $1 | cut -f2 -d: | cut -f1 -d/`.z\`echo $1 | cut -f1 -d/ | cut -f1 -d:`.\`echo $1 | cut -f2 -d@`.org"}# Parameters: fqdnconfigure_loopback() { dialog --backtitle "$TITLE" --infobox "Configuro la rete (in modo loopback)..." 0 0 FQDN=$1 HOST=`echo $FQDN | cut -f1 -d.` DOMAIN=`echo $FQDN | cut -f2- -d.` save /etc/hostname echo $FQDN >/etc/HOSTNAME export HOSTNAME=$FQDN hostname $HOST save /etc/rc.d/rc.inet1 cat <<EOF >/etc/rc.d/rc.inet1 #! /bin/sh## rc.inet1 This shell script boots up the base INET system.# Attach the loopback device./sbin/ifconfig lo 127.0.0.1/sbin/route add -net 127.0.0.0# End of rc.inet1EOF chmod 755 /etc/rc.d/rc.inet1 save /etc/networks cat <<EOF >/etc/networks## networks This file describes a number of netname-to-address# mappings for the TCP/IP subsystem. It is mostly# used at boot time, when no name servers are running.#loopback 127.0.0.0# End of networks.EOF chmod 644 /etc/networks save /etc/hosts cat <<EOF >/etc/hosts## hosts This file describes a number of hostname-to-address# mappings for the TCP/IP subsystem. It is mostly# used at boot time, when no name servers are running.# On small systems, this file can be used instead of a# "named" name server. Just add the names, addresses# and any aliases to this file...## By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1# should NEVER be named with the name of the machine. It causes problems# for some (stupid) programs, irc and reputedly talk. :^)## But we (ComeOn Linux!) says that this is not valid for you, because# you resulted to have not a network at the installation time.# For loopbacking.127.0.0.1 localhost $FQDN $HOST# End of hosts.EOF chmod 644 /etc/hosts save /etc/resolv.conf echo domain $DOMAIN >/etc/resolv.conf chmod 644 /etc/resolv.conf save /etc/host.conf cat <<EOF >/etc/host.conforder hosts,bindmulti onEOF chmod 644 /etc/host.conf /etc/rc.d/rc.inet1}# Private function, adds an user to a group. Args: user, groupadd_to_group() { if [ ! "`groups \"$1\" | grep \" $2 \"`" ] then USERS="`grep \"$2:\" /etc/group | cut -s -f4 -d:`" mkstemp group if [ "$USERS" ]; then sed "/$2:/s/:$USERS/:$USERS,$1/" /etc/group >$tmp_group else sed "/$2:/s/:/:$1/3" /etc/group >$tmp_group fi save /etc/group mv $tmp_group /etc/group fi}# Arguments: user, fullnameadd_postmaster() { dialog --backtitle "$TITLE" --infobox "Creo l'user principale e/o ne adatto le informazioni..." 0 0 USER="$1" NAME="$2" HOMEDIR="/home/$USER"# echo "$USER" >$COPIUSER # you've to do this in any other location ENTRY="`cut /etc/passwd -s -f1,2,5 -d: | grep $USER:`" if [ "$ENTRY" ] then OLDNAME="`echo $ENTRY | cut -f3 -d:`" PASW="`echo $ENTRY | cut -f2 -d:`" if [ "$OLDNAME" != "$NAME" ] then mkstemp passwd sed "/$USER:$PASW:/s/:$OLDNAME:/:$NAME:/" /etc/passwd >$tmp_passwd save /etc/passwd mv $tmp_passwd /etc/passwd fi add_to_group "$USER" mail else if [ -f /bin/bash ]; then USERSHELL=/bin/bash; else USERSHELL=""; fi find_unused_uid echo "$USER:*:$FOUND_UID:12:$NAME:$HOMEDIR:$USERSHELL" >>/etc/passwd mkdir -p $HOMEDIR -m 755 chown $USER.mail $HOMEDIR fi}comment_nntp_in_inetdconf() { dialog --backtitle "$TITLE" --infobox "Commento la riga 'nntp' in /etc/inetd.conf..." 0 0 mkstemp inetd sed "/in.nntpd/s/nntp/#&/" /etc/inetd.conf >$tmp_inetd save /etc/inetd.conf mv $tmp_inetd /etc/inetd.conf killall -1 inetd}# Args: organizationset_organization() { dialog --backtitle "$TITLE" --infobox "Imposto l' origin..." 0 0 ORGANIZATION=/etc/organization save $ORGANIZATION NEW_ORGANIZATION="$1" echo "$NEW_ORGANIZATION" >$ORGANIZATION}create_innconf_newsfeeds_distrib() { dialog --backtitle "$TITLE" --infobox "Creo i files di configurazione principali di InterNet News (inn)..." 0 0# File: inn.conf INNCONF=~news/inn.conf save $INNCONF cat <<EOF >$INNCONF## $Revision: 1.3 $## inn.conf -- inn configuration data## Format:## <parameter>:<whitespace><value>## Used by various programs and libinn. The following parameters are defined:## domain Local domain, without leading period.## fromhost What to put in the From line; default is FQDN## of the local host.## moderatormailer Where to mail moderated postings, if not found## in the moderators file; see moderators(5).## pathhost What to put in the Path and Xref headers; default## is FQDN of the local host.## organization If $ORGANIZATION doesn't exist. What to put in## the Organization header if blank.## server If $NNTPSERVER doesn't exist. Local NNTP server## host to connect to.##server: $HOST.$DOMAINdomain: $DOMAINpathhost: $HOSTEOF chmod 444 $INNCONF chown news.news $INNCONF# File: newsfeeds NEWSFEEDS=~news/newsfeeds save $NEWSFEEDS echo -e "ME:*::\n" >$NEWSFEEDS IAKA=1 OK=1 while [ "$OK" != 0 ] do AKA="`cut $AKASETUP -f$IAKA -d:`" if [ ! "$AKA" ] then OK=0 else if [ $IAKA != 1 ] then TMPAKA="`echo $AKA | cut -f-4 -d.`" SENDCRON="$SENDCRON $TMPAKA" echo -n "$TMPAKA/" >>$NEWSFEEDS fi TMPAKA="`echo $AKA | cut -f1-2 -d.`" if [ $IAKA = 1 ]; then SENDCRON="$SENDCRON $TMPAKA" fi echo -e "$TMPAKA\\" >>$NEWSFEEDS echo -e "\t:!*,`echo $AKA | cut -f4 -d.`.*\\" >>$NEWSFEEDS echo -e "\t:Tf,Wfb,B4096/1024:\n" >>$NEWSFEEDS fi IAKA=$[$IAKA+1] done chmod 444 $NEWSFEEDS chown news.news $NEWSFEEDS# File: distrib.pats DISTRIB=~news/distrib.pats save $DISTRIB IAKA=1 OK=1 while [ "$OK" != 0 ]; do AKA="`cut $AKASETUP -f$IAKA -d:`" IAKA=$[$IAKA+1] if [ "$AKA" = "" ]; then OK=0 else DOM="`echo $AKA | cut -f4 -d.`" echo "10:$DOM.*:$DOM" >>$DISTRIB fi done chmod 444 $DISTRIB chown news.news $DISTRIB}# Args: num_of_dayscreate_expirectl() { dialog --backtitle "$TITLE" --infobox "Imposto il periodo di transito dei messaggi..." 0 0 EXPIRECTL=~news/expire.ctl save $EXPIRECTL EXPIRE_DAYS=$1 echo -e "/remember/:14\n\n*:A:2:$EXPIRE_DAYS:$EXPIRE_DAYS" >$EXPIRECTL chmod 440 $EXPIRECTL chown news.news $EXPIRECTL}create_nnrpaccess() { dialog --backtitle "$TITLE" --infobox "Rendo accessibili le news in lettura..." 0 0 NNRPACCESS=~news/nnrp.access save $NNRPACCESS cat <<EOF >$NNRPACCESS## $Revision: 1.3 $## nnrp.access - access file for on-campus NNTP sites## Format:## <host>:<perm>:<user>:<pass>:<groups>## Connecting host must be found in this file; the last match found is## used, so put defaults first.## <host> Wildcard name or IP address## <perm> R to read; P to post## <user> Username for authentication before posting## <pass> Password, for same reason## <groups> Newsgroup patterns that can be read or not read## To disable posting put a space in the <user> and <pass> fields, since## there is no way for client to enter one.#### Default is no access, no way to authentication, and no groups.# *:: -no- : -no- :!*## Foo, Incorporated, hosts have no password, can read anything.# *.foo.com:Read Post:::**:: -no- : -no- :!*localhost.$DOMAIN:Read Post:::*$HOST.$DOMAIN:Read Post:::*EOF chmod 440 $NNRPACCESS chown news.news $NNRPACCESS }create_hostsnntp() { dialog --backtitle "$TITLE" --infobox "Rendo accessibili le news in scrittura..." 0 0 HOSTSNNTP=~news/hosts.nntp save $HOSTSNNTP cat <<EOF >$HOSTSNNTP## $Revision: 1.3 $## hosts.nntp - names and addresses that feed us news## Format## <host>:## <host>:<password>## <host> can be a name or IP address; no wildcards. Any hosts not## listed here are handed off to nnrpd.$HOST.$DOMAIN:EOF chmod 440 $HOSTSNNTP chown news.news $HOSTSNNTP }create_dirs_and_files() { CURMASK=`umask` . ./copi.wheel pushd /var/log >/dev/null mkdir -p news -m 755; chown news.news news cd /var/log/news; mkdir -p OLD -m 755; chown news.news OLD cd /var/spool; mkdir -p news -m 775; chown news.news news cd /var/spool/news; umask 02 mkdir -p out.going control junk in.coming chown news.news out.going control junk in.coming cd in.coming; mkdir -p bad tmp; chown news.news bad tmp; umask $CURMASK ln -sf ~news /usr/local/lib/ ln -sf ~news/inews /usr/bin/ chmod 1777 /var/tmp cd /var/spool mkdir -p uucppublic chown uucp.uucp uucppublic chmod 1777 uucppublic cd ~news touch history history.dir history.pag errlog log chown news.news history* log errlog chmod 664 history* log errlog save active echo "control 0000000000 0000000001 y" > active echo "junk 0000000000 0000000001 y" >> active chown news.news active
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -