# -*- tcl -*-
#
# Author:       James Brister <brister@vix.com> -- berkeley-unix --
# Start Date:   Sat, 24 Aug 1996 23:45:34 +0200
# Project:      INN
# File:         innshellvars.tcl
# Description:  Set up any and all variables that an INN tcl script
#               might need.  Also sets umask.
#
# Various bug fixes, code and documentation improvements since then
# in 1998-2003, 2005, 2007-2010, 2018, 2021, 2022, 2024.

set env(LC_CTYPE) "C"

set prefix "@prefix@"
set exec_prefix "@exec_prefix@"
eval [exec @bindir@/innconfval -t]

set inn_newshome "$inn_pathnews"
set inn_spooldir "$inn_pathspool"
set inn_most_logs "$inn_pathlog"
set env(NEWSHOME) "$inn_newshome"
set env(SPOOLDIR) "$inn_spooldir"
set env(MOST_LOGS) "$inn_most_logs"

set inn_newsbin "${inn_pathbin}"
set inn_newsetc "${inn_pathetc}"
set inn_newslib "@libdir@"
set inn_innddir "${inn_pathrun}"
set inn_locks "${inn_pathrun}"
set env(NEWSBIN) "$inn_newsbin"
set env(NEWSETC) "$inn_newsetc"
set env(NEWSLIB) "$inn_newslib"
set env(INNDDIR) "$inn_innddir"
set env(LOCKS) "$inn_locks"

set inn_errlog "${inn_most_logs}/errlog"
set inn_log "${inn_most_logs}/news"

set inn_archivedir "${inn_patharchive}"
set inn_spool "${inn_patharticles}"
set inn_batch "${inn_pathoutgoing}"
set inn_incoming "${inn_pathincoming}"
set inn_overviewdir "${inn_pathoverview}"
set inn_spoolnews "${inn_pathincoming}"
set inn_badnews "${inn_pathincoming}/bad"

set inn_active "${inn_pathdb}/active"
set inn_activetimes "${inn_pathdb}/active.times"
set inn_ctlfile "${inn_newsetc}/control.ctl"
set inn_ctlwatch "${inn_newsetc}/innwatch.ctl"
set inn_history "${inn_pathdb}/history"
set inn_newactive "${inn_pathdb}/active.tmp"
set inn_newsfeeds "${inn_newsetc}/newsfeeds"
set inn_newsgroups "${inn_pathdb}/newsgroups"
set inn_oldactive "${inn_pathdb}/active.old"
set inn_path_motd_innd "${inn_newsetc}/motd.innd"
set inn_path_motd_nnrpd "${inn_newsetc}/motd.nnrpd"
set inn_path_motd "${inn_path_motd_nnrpd}"
set inn_expirectl "${inn_newsetc}/expire.ctl"
set inn_localgroups "${inn_newsetc}/localgroups"

set inn_controlprogs "${inn_pathcontrol}"
set inn_innconfval "${inn_newsbin}/innconfval"
set inn_innd "${inn_newsbin}/innd"
set inn_innwatch "${inn_newsbin}/innwatch"
set inn_inews "${inn_newsbin}/inews"
set inn_rnews "${inn_newsbin}/rnews"
set inn_perl_startup_innd "${inn_pathfilter}/startup_innd.pl"
set inn_perl_filter_innd "${inn_pathfilter}/filter_innd.pl"
set inn_perl_filter_nnrpd "${inn_pathfilter}/filter_nnrpd.pl"
set inn_python_filter_innd "${inn_pathfilter}/filter_innd.py"
set inn_path_python_inn_module "${inn_pathfilter}/INN.py"
set inn_path_tcl_startup "${inn_pathfilter}/startup.tcl"
set inn_path_tcl_filter "${inn_pathfilter}/filter.tcl"

set inn_daily "${inn_locks}/locks/LOCK.news.daily"

set inn_newscontrol "${inn_innddir}/control"
set inn_nntpconnect "${inn_innddir}/nntpin"
set inn_serverpid "${inn_innddir}/innd.pid"
set inn_innwstatus "${inn_innddir}/innwatch.status"
set inn_watchpid "${inn_innddir}/innwatch.pid"

set inn_awk "@AWK@"
set inn_sed "@SED@"
set inn_inndf "${inn_newsbin}/inndf"
set inn_egrep "@EGREP@"
set inn_perl "@PERL@"
set inn_gpgv "@GPGV@"
set inn_gpg "@GPG@"
set inn_pgp "@PGP@"
set inn_sort "@SORT@"
set inn_getftp "@PATH_GETFTP@"
set inn_gethttp "@PATH_GETHTTP@"
set inn_uustat "@UUSTAT@"
set inn_uux "@UUX@"

set inn_bzip2 "@BZIP2@"
set inn_compress "@COMPRESS@"
set inn_gzip "@GZIP@"
set inn_uncompress "@UNCOMPRESS@"
set inn_log_compress "@LOG_COMPRESS@"
set inn_z "@LOG_COMPRESSEXT@"

if { $inn_ovmethod == "ovdb" } {
    set inn_db_home "${inn_pathoverview}"
    set env(DB_HOME) "${inn_db_home}"
}

set inn_tempsock [ eval exec basename ${inn_innddir}/ctlinndXXXXXX | $inn_sed -e {s/XXXXXX$/*/} ]
set inn_tempsockdir [ exec echo ${inn_innddir}/ctlinndXXXXXX | $inn_sed -e {s@/[^/]*$@@} ]

set inn_newsmaster "@NEWSMASTER@"
set inn_newsuser "${inn_runasuser}"
set inn_newsgroup "${inn_runasgroup}"

scan "@FILEMODE@" "%o" inn_filemode
scan "@INEWSMODE@" "%o" inn_inewsmode
scan "@RNEWSMODE@" "%o" inn_rnewsmode

set do_dbz_tagged_hash "@DO_DBZ_TAGGED_HASH@"
set inn_gpg_has_allow_weak_digest_algos_flag @GPG_HAS_ALLOW_WEAK_DIGEST_ALGOS_FLAG@

set inn_tmpdir "$inn_pathtmp"
set env(TMPDIR) "$inn_pathtmp"

set inn_spooltemp "$inn_pathtmp"

set inn_newslbin "${inn_newshome}/local"
set env(NEWSLBIN) "$inn_newslbin"

scan "@NEWSUMASK@" "%o" inn_umask
catch {umask @NEWSUMASK@}

set inn_syslog_facility [ exec echo [string tolower "@SYSLOG_FACILITY@"] | $inn_sed -e {s/log_//} ]

set inn_path "$inn_newslbin:$inn_newsbin:$env(PATH):/bin:/usr/bin"
set env(PATH) "$inn_path"

set inn_home "$inn_pathnews"


##  Load another script that can override or add variables.
if {[file executable "${inn_pathetc}/innshellvars.tcl.local"] == 1} {
    source "${inn_pathetc}/innshellvars.tcl.local"
}
