#!/usr/bin/tclsh # # Helga Fix Server Setup Scripts # # This scripts checks various things on the server, to ensure # a properly functioning Helga install when directories move. # set tclLibPath "/usr/share/tcltk" if { ![file writable $tclLibPath] } { puts "root privileges not detected. You must run this script as root." exit 1 } set version [lindex [file split [file normalize $argv0]] end-2] puts "Found version $version." puts -nonewline "Checking for correct environment settings in sudoers..." flush stdout if { [catch "exec grep !env_reset /etc/sudoers"] } { puts "failed." puts "Sudoers needs the !env_reset option in order to preserve your Helga environment" puts "for commands run with sudo. Consult your distribution documentation for instructions" puts "on setting this." exit } puts "done." set helgaRoot $::env(HELGAROOT) set confPath $helgaRoot/site/conf puts -nonewline "Checking for Helga configuration directory..." flush stdout if { ![file exists $confPath] } { file mkdir $confPath } puts "done." puts -nonewline "Checking for Helga configuration file..." flush stdout if { ![file exists $confPath/helga.conf] } { puts -nonewline "file not found, creating..." flush stdout set confText "HELGAROOT=$helgaRoot\n" append confText "HELGADOCROOT=\$HELGAROOT/public\n" append confText "HELGAVERSION=$version\n" append confText "SVNSERVER=localhost\n" append confText "SQLSERVER=localhost\n" append confText "SQLDB=helga\n" append confText "SESSION_LENGTH=1800" set fp [open $confPath/helga.conf w] puts $fp $confText close $fp } puts "done." puts -nonewline "Checking for Helga admin configuration file..." flush stdout if { ![file exists $confPath/admin.conf] } { puts -nonewline "file not found, creating..." flush stdout set confText "BASICSQLPASS=\n" append confText "ADVANCEDSQLPASS=\n" append confText "ADMINSQLPASS=" set fp [open $confPath/admin.conf w] puts $fp $confText close $fp } puts "done." # source Helga configuration set confFile "$confPath/helga.conf" set fp [open $confFile r] set data [read $fp] close $fp foreach line $data { set lineTrimmed [string trim $line] if { $lineTrimmed != "" && [string index $lineTrimmed 0] != "#" } { set lineSplit [split $lineTrimmed "="] set varName [string trim [lindex $lineSplit 0]] set varVal [string trim [lindex $lineSplit 1]] set ::$varName [subst $varVal] } } # get lib path, make sure Tcl can find it set libPath $::HELGAROOT/dist/$version/shell/lib puts -nonewline "Checking path to Helga Tcl libraries in $tclLibPath..." flush stdout file delete $tclLibPath/helga$version file link $tclLibPath/helga$version $libPath puts "done." puts -nonewline "Checking for proper sudoers configuration..." flush stdout set needSudo { helgaAuth.tclsh getSessionData.tclsh hpasswd.tclsh } set sudoersOk true foreach script $needSudo { set fullName $::HELGAROOT/dist/\\\\\*/shell/$script if { [catch "exec grep $fullName /etc/sudoers" out] } { set sudoersOk false } } if { !$sudoersOk } { puts "\nYour sudoers file is not configured to work with Helga. All Helga users need passwordless sudo on the following files:" foreach script $needSudo { set fullName $::HELGAROOT/dist/*/shell/$script puts $fullName } puts "Using a line like:" puts "ALL ALL=NOPASSWD:$fullName" exit } puts "done." puts -nonewline "Checking for Helga docroot directory..." flush stdout if { ![file exists $::HELGADOCROOT] } { puts -nonewline "directory $::HELGADOCROOT not found, creating..." flush stdout file mkdir $::HELGADOCROOT } puts "done." puts -nonewline "Checking that your install of Helga Web is web-accessible..." flush stdout # js lib file delete $::HELGADOCROOT/web file link $::HELGADOCROOT/web $::HELGAROOT/dist/$version/web # web app file delete $::HELGADOCROOT/app file link $::HELGADOCROOT/app $::HELGAROOT/dist/$version/webApp # php ui file delete $::HELGADOCROOT/php file link $::HELGADOCROOT/php $::HELGAROOT/dist/$version/webPHP puts "done." puts -nonewline "Checking for global index.html file..." flush stdout set indexPath $::HELGADOCROOT/index.html if { ![file exists $indexPath] } { puts -nonewline "file not found, creating..." set indexText "Helga Web App
Helga PHP UI" set fp [open $indexPath w] puts $fp $indexText close $fp } puts "done." puts "All checks complete."