diff --git a/Makefile b/Makefile index ff9fa75..827b153 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,15 @@ -OUT=out -CONTRIBOUT=contribs.txt -CONTRIBOUTTCL=src/contribs.tcl +ifndef CSGOSL_ROOT +$(error CSGOSL_ROOT is not set, source env.sh in root directory) +endif + +OUT=$(CSGOSL_ROOT)/out +CONTRIBOUT=$(CSGOSL_ROOT)/contribs.txt +CONTRIBOUTTCL=$(CSGOSL_ROOT)/src/contribs.tcl all: clean contribs windows linux tag: - git tag -a v1.0.5 -m "Fixed autoupdateonstart bug" + git tag -a v1.1 -m "Sourcemod plugins page + updated sourcemod" install: $(MAKE) -C devtools/linux diff --git a/devtools/build.sh b/devtools/build.sh index f380cee..5de9e2c 100755 --- a/devtools/build.sh +++ b/devtools/build.sh @@ -64,16 +64,17 @@ TCLKIT=$ROOT/devtools/linux/tclkit case $TARGET in linux) installdir $DEST/csgosl $DEST/bin $DEST/mods - install $DEST/mods "$ROOT"/mods/linux/mods.zip + install $DEST/mods "$ROOT"/mods/linux/mods.zip "$ROOT"/mods/linux/mods-risky.zip install $DEST/bin "$ROOT"/src/*.tcl "$ROOT"/src/pics/*.jpg "$ROOT"/src/pics/*.png install $DEST "$ROOT"/src/linux/csgosl.sh install $DEST/bin "$ROOT"/src/linux/server.sh + touch $DEST/bin/needsupgrade (cd "$DEST"/.. ; zip -r csgosl.zip csgosl) || error "Failed to zip" (cd "$DEST"/.. ; mv csgosl.zip csgosl-linux.zip) ;; windows) installdir $DEST/csgosl.vfs $DEST/csgosl.vfs/lib $DEST/bin $DEST/mods - install $DEST/mods "$ROOT"/mods/linux/mods.zip + install $DEST/mods "$ROOT"/mods/windows/mods.zip "$ROOT"/mods/windows/mods-risky.zip install $DEST/csgosl.vfs "$ROOT"/src/*.tcl "$ROOT"/src/pics/*.jpg "$ROOT"/src/pics/*.png $TCLKIT $SDX unwrap "$ROOT"/devtools/windows/img.kit || error "Failed to unwrap img.kit" install $DEST/csgosl.vfs/lib img.vfs/lib/Img/* @@ -87,8 +88,11 @@ case $TARGET in "$ROOT"/src/windows/server-status.bat \ "$ROOT"/src/windows/server-stop.bat \ "$ROOT"/src/windows/csgoslw.bat \ - "$ROOT"/devtools/windows/unzip.exe $ROOT/devtools/windows/tclkit.exe + "$ROOT"/devtools/windows/unzip.exe \ + "$ROOT"/devtools/windows/wget.exe \ + $ROOT/devtools/windows/tclkit.exe install $DEST "$ROOT"/src/windows/csgosl.vbs + touch $DEST/bin/needsupgrade (cd "$DEST"/.. ; zip -r csgosl.zip csgosl) || error "Failed to zip" (cd "$DEST"/.. ; mv csgosl.zip csgosl-windows.zip) ;; diff --git a/devtools/windows/Makefile b/devtools/windows/Makefile index 4e38c6a..0ef8033 100644 --- a/devtools/windows/Makefile +++ b/devtools/windows/Makefile @@ -13,14 +13,18 @@ UNZIP_VERSION="6.00" IMG_HOME_URL="http://www.tcl.tk/starkits/" IMG_URL="http://www.tcl.tk/starkits/img.kit" IMG_VERSION="1.3" +WGET_HOME_URL="https://www.gnu.org/software/wget" +WGET_URL="https://eternallybored.org/misc/wget/releases/wget-1.17.1-win32.zip" +WGET_VERSION="1.17.1-win32" -all: tclkit sdx img unzip +all: wget tclkit sdx img unzip contribs: @echo "$(TARGET) tclkit $(TCLKIT_VERSION) $(TCLKIT_HOME_URL) $(TCLKIT_URL)" @echo "$(TARGET) sdx $(SDX_VERSION) $(SDX_HOME_URL) $(SDX_URL)" @echo "$(TARGET) unzip $(UNZIP_VERSION) $(UNZIP_HOME_URL) $(UNZIP_URL)" @echo "$(TARGET) img $(IMG_VERSION) $(IMG_HOME_URL) $(IMG_URL)" + @echo "$(TARGET) wget $(WGET_VERSION) $(WGET_HOME_URL) $(WGET_URL)" tclkit: wget $(TCLKIT_URL) -O tclkit.exe @@ -38,6 +42,12 @@ unzip: cp exclude_me/unzip.exe . chmod +x unzip.exe +wget: + wget $(WGET_URL) -O wget.zip + unzip -o wget.zip -d exclude_me + cp exclude_me/wget.exe . + chmod +x wget.exe + clean: \rm -f tclkit.exe sdx.kit img.kit unzip-self-extract.exe unzip.exe \rm -rf exclude_me diff --git a/env.sh b/env.sh new file mode 100755 index 0000000..b45a927 --- /dev/null +++ b/env.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +export CSGOSL_ROOT=`pwd` diff --git a/mods/common.mk b/mods/common.mk new file mode 100644 index 0000000..036c888 --- /dev/null +++ b/mods/common.mk @@ -0,0 +1,4 @@ +MODS_ROOT=$(CSGOSL_ROOT)/mods/$(TARGET)/mods +MODS_CONFIGS=$(MODS_ROOT)/addons/sourcemod/configs +MODS_PLUGINS=$(MODS_ROOT)/addons/sourcemod/plugins +MODS_TRANSLATIONS=$(MODS_ROOT)/addons/sourcemod/translations diff --git a/mods/linux/Makefile b/mods/linux/Makefile index 835c44b..a8e155d 100644 --- a/mods/linux/Makefile +++ b/mods/linux/Makefile @@ -1,33 +1,43 @@ #Linux TARGET=linux +include ../common.mk METAMOD_HOME_URL="http://www.metamodsource.net/" METAMOD_URL="http://www.gsptalk.com/mirror/sourcemod/mmsource-1.10.6-linux.tar.gz" METAMOD_VERSION="1.10.6" SOURCEMOD_HOME_URL="http://www.sourcemod.net/" -SOURCEMOD_URL="http://www.sourcemod.net/smdrop/1.7/sourcemod-1.7.3-git5302-linux.tar.gz" -SOURCEMOD_VERSION="1.7.3-git5302" +SOURCEMOD_URL="http://www.sourcemod.net/smdrop/1.7/sourcemod-1.7.3-git5303-linux.tar.gz" +SOURCEMOD_VERSION="1.7.3-git5303" +export all: mods contribs: @echo "$(TARGET) metamod $(METAMOD_VERSION) $(METAMOD_HOME_URL) $(METAMOD_URL)" @echo "$(TARGET) sourcemod $(SOURCEMOD_VERSION) $(SOURCEMOD_HOME_URL) $(SOURCEMOD_URL)" + $(MAKE) -C ../mods/franug-knifes contrib + $(MAKE) -C ../mods/franug-weapon-paint contrib -metamod: +dl-metamod: wget $(METAMOD_URL) -O metamod.tar.gz -sourcemod: +dl-sourcemod: wget $(SOURCEMOD_URL) -O sourcemod.tar.gz -mods: metamod sourcemod - \rm -rf mods >/dev/null 2>&1 - mkdir mods - (cd mods ; tar xzvpf ../metamod.tar.gz) - (cd mods ; tar xzvpf ../sourcemod.tar.gz) - cp ../metamod.vdf mods/addons/ - (cd mods ; zip -r ../mods.zip *) - \rm -rf mods >/dev/null 2>&1 +mods: dl-metamod dl-sourcemod + \rm -rf $(MODS_ROOT) mods*.zip >/dev/null 2>&1 + mkdir -p $(MODS_ROOT) + (cd $(MODS_ROOT) ; tar xzvpf ../metamod.tar.gz) + (cd $(MODS_ROOT) ; tar xzvpf ../sourcemod.tar.gz) + (cd $(MODS_ROOT) ; zip -r ../mods.zip *) + \rm -rf $(MODS_ROOT) >/dev/null 2>&1 + mkdir -p $(MODS_ROOT) + $(MAKE) -C ../mods/franug-knifes + $(MAKE) -C ../mods/franug-weapon-paint + (cd $(MODS_ROOT) ; zip -r ../mods-risky.zip *) + \rm -rf $(MODS_ROOT) >/dev/null 2>&1 clean: - \rm -f metamod.tar.gz sourcemod.tar.gz mods.zip + $(MAKE) -C ../mods/franug-knifes clean + $(MAKE) -C ../mods/franug-weapon-paint clean + \rm -f metamod.tar.gz sourcemod.tar.gz mods*.zip diff --git a/mods/metamod.vdf b/mods/metamod.vdf deleted file mode 100644 index e747e99..0000000 --- a/mods/metamod.vdf +++ /dev/null @@ -1,4 +0,0 @@ -"Plugin" -{ - "file" "../csgo/addons/metamod/bin/server" -} diff --git a/mods/mods/franug-knifes/Makefile b/mods/mods/franug-knifes/Makefile new file mode 100644 index 0000000..ba9fe40 --- /dev/null +++ b/mods/mods/franug-knifes/Makefile @@ -0,0 +1,21 @@ +FRANUG_KNIFES_HOME_URL="https://github.com/Franc1sco/Franug-Knifes" +FRANUG_KNIFES_URL="https://github.com/Franc1sco/Franug-Knifes/archive/ff449c6.zip" +FRANUG_KNIFES_VERSION="sha-ff449c6-2016-05-05" + +all: build + +contrib: + @echo "$(TARGET) franug_knifes $(FRANUG_KNIFES_VERSION) $(FRANUG_KNIFES_HOME_URL) $(FRANUG_KNIFES_URL)" + +dl: + wget $(FRANUG_KNIFES_URL) -O franug-knifes.zip + +build: dl + unzip -o franug-knifes.zip + (cd Franug-Knifes-* ; mkdir -p $(MODS_CONFIGS) && cp -f csgo_knives.cfg $(MODS_CONFIGS)/) + (cd Franug-Knifes-* ; mkdir -p $(MODS_PLUGINS)/disabled && cp -f sm_franugknife.smx $(MODS_PLUGINS)/disabled/) + \rm -rf Franug-Knifes-* + +clean: + \rm -f franug-knifes.zip + \rm -rf Franug-Knifes-* diff --git a/mods/mods/franug-weapon-paint/Makefile b/mods/mods/franug-weapon-paint/Makefile new file mode 100644 index 0000000..bebd46e --- /dev/null +++ b/mods/mods/franug-weapon-paint/Makefile @@ -0,0 +1,23 @@ +FRANUG_WEAPON_PAINTS_HOME_URL="https://github.com/Franc1sco/Franug-Weapon_Paints" +FRANUG_WEAPON_PAINTS_URL="https://github.com/Franc1sco/Franug-Weapon_Paints/archive/fc7178d.zip" +FRANUG_WEAPON_PAINTS_VERSION="sha-fc7178d-2016-05-05" + +all: build + +contrib: + @echo "$(TARGET) franug_weapon_paints $(FRANUG_WEAPON_PAINTS_VERSION) $(FRANUG_WEAPON_PAINTS_HOME_URL) $(FRANUG_WEAPON_PAINTS_URL)" + +dl: + wget $(FRANUG_WEAPON_PAINTS_URL) -O franug-weapon-paint.zip + +build: dl + unzip -o franug-weapon-paint.zip + cp -f databases.cfg $(MODS_CONFIGS)/ + (cd Franug-Weapon_Paints-* ; mkdir -p $(MODS_CONFIGS) && cp -f csgo_wpaints.cfg $(MODS_CONFIGS)/) + (cd Franug-Weapon_Paints-* ; mkdir -p $(MODS_PLUGINS)/disabled && cp -f franug_weaponpaints_public.smx $(MODS_PLUGINS)/disabled/) + (cd Franug-Weapon_Paints-* ; mkdir -p $(MODS_TRANSLATIONS) && cp -f franug_weaponpaints.phrases.txt $(MODS_TRANSLATIONS)/) + \rm -rf Franug-Weapon_Paints-* + +clean: + \rm -f franug-weapon-paint.zip + \rm -rf Franug-Weapon_Paints-* diff --git a/mods/mods/franug-weapon-paint/databases.cfg b/mods/mods/franug-weapon-paint/databases.cfg new file mode 100644 index 0000000..66a4556 --- /dev/null +++ b/mods/mods/franug-weapon-paint/databases.cfg @@ -0,0 +1,40 @@ +"Databases" +{ + "driver_default" "mysql" + + // When specifying "host", you may use an IP address, a hostname, or a socket file path + + "default" + { + "driver" "default" + "host" "localhost" + "database" "sourcemod" + "user" "root" + "pass" "" + //"timeout" "0" + //"port" "0" + } + + "storage-local" + { + "driver" "sqlite" + "database" "sourcemod-local" + } + + "clientprefs" + { + "driver" "sqlite" + "host" "localhost" + "database" "clientprefs-sqlite" + "user" "root" + "pass" "" + //"timeout" "0" + //"port" "0" + } + + "weaponpaints" + { + "driver" "sqlite" + "database" "weaponpaints" + } +} diff --git a/mods/windows/Makefile b/mods/windows/Makefile index c9b626b..f302e68 100644 --- a/mods/windows/Makefile +++ b/mods/windows/Makefile @@ -1,32 +1,42 @@ #Windows TARGET=windows +include ../common.mk METAMOD_HOME_URL="http://www.metamodsource.net/" METAMOD_URL="http://mirror.pointysoftware.net/alliedmodders/mmsource-1.10.6-windows.zip" METAMOD_VERSION="1.10.6" SOURCEMOD_HOME_URL="http://www.sourcemod.net/" -SOURCEMOD_URL="https://www.sourcemod.net/smdrop/1.7/sourcemod-1.7.3-git5302-windows.zip" -SOURCEMOD_VERSION="1.7.3-git5302" +SOURCEMOD_URL="https://www.sourcemod.net/smdrop/1.7/sourcemod-1.7.3-git5303-windows.zip" +SOURCEMOD_VERSION="1.7.3-git5303" +export all: mods contribs: @echo "$(TARGET) metamod $(METAMOD_VERSION) $(METAMOD_HOME_URL) $(METAMOD_URL)" @echo "$(TARGET) sourcemod $(SOURCEMOD_VERSION) $(SOURCEMOD_HOME_URL) $(SOURCEMOD_URL)" + $(MAKE) -C ../mods/franug-knifes contrib + $(MAKE) -C ../mods/franug-weapon-paint contrib -metamod: +dl-metamod: wget $(METAMOD_URL) -O metamod.zip -sourcemod: +dl-sourcemod: wget $(SOURCEMOD_URL) -O sourcemod.zip -mods: metamod sourcemod - \rm -rf mods >/dev/null 2>&1 - mkdir mods - (cd mods ; unzip -o ../metamod.zip) - (cd mods ; unzip -o ../sourcemod.zip) - cp ../metamod.vdf mods/addons/ - (cd mods ; zip -r ../mods.zip *) - \rm -rf mods >/dev/null 2>&1 +mods: dl-metamod dl-sourcemod + \rm -rf $(MODS_ROOT) mods*.zip >/dev/null 2>&1 + mkdir -p $(MODS_ROOT) + (cd $(MODS_ROOT) ; unzip -o ../metamod.zip) + (cd $(MODS_ROOT) ; unzip -o ../sourcemod.zip) + (cd $(MODS_ROOT) ; zip -r ../mods.zip *) + \rm -rf $(MODS_ROOT) >/dev/null 2>&1 + mkdir -p $(MODS_ROOT) + $(MAKE) -C ../mods/franug-knifes + $(MAKE) -C ../mods/franug-weapon-paint + (cd $(MODS_ROOT) ; zip -r ../mods-risky.zip *) + \rm -rf $(MODS_ROOT) >/dev/null 2>&1 clean: - \rm -f metamod.zip sourcemod.zip mods.zip + $(MAKE) -C ../mods/franug-knifes clean + $(MAKE) -C ../mods/franug-weapon-paint clean + \rm -f metamod.zip sourcemod.zip mods*.zip diff --git a/src/config_file.tcl b/src/config_file.tcl index 1e3d348..5ac00db 100755 --- a/src/config_file.tcl +++ b/src/config_file.tcl @@ -129,6 +129,55 @@ proc SaveMapGroupsMapper {filename} { close $fileId } +proc IsValidIp {ip} { + if {[scan $ip %d.%d.%d.%d a b c d] == 4 + && 0 <= $a && $a <= 255 && 0 <= $b && $b <= 255 + && 0 <= $c && $c <= 255 && 0 <= $d && $d <= 255} { + return true + } else { + return false + } +} + +proc SaveSimpleAdminsFile {filename admins} { + set fp [open "$filename" "w"] + puts $fp "//Autogenerated by csgosl at [clock format [clock seconds]]" + puts $fp "//DON'T EDIT, WILL BE OVERWRITTEN NEXT TIME YOU SAVE!!!" + foreach admin $admins { + if { [IsValidIp $admin] } { + puts $fp "\"!$admin\" \"98:z\"" + } else { + puts $fp "\"$admin\" \"98:z\"" + } + } + close $fp +} + +proc SaveMaps {filename maps} { + set fp [open "$filename" "w"] + puts $fp "//Autogenerated by csgosl at [clock format [clock seconds]]" + puts $fp "//DON'T EDIT, WILL BE OVERWRITTEN NEXT TIME YOU SAVE!!!" + foreach map $maps { + puts $fp $map + } + close $fp +} + +proc SaveMapListTxt {filename} { + global allMaps + SaveMaps $filename $allMaps +} + +proc SaveMapCycleTxt {filename selectedMapGroup} { + global mapGroupsMapper + if { [dict exists $mapGroupsMapper $selectedMapGroup] } { + SaveMaps $filename [dict get $mapGroupsMapper $selectedMapGroup] + } else { + global allMaps + SaveMaps $filename $allMaps + } +} + proc SaveConfigFile {configName} { global $configName set config [set $configName] @@ -137,18 +186,21 @@ proc SaveConfigFile {configName} { set values [dict get $config values] set meta [dict get $config meta] + global ValueToSkip set fileId [open $fileName "w"] dict for {key value} $values { set valueName [GetGlobalConfigVariableName $prefix $key] global $valueName set value [set $valueName] - set values [dict set values $key "$value"] - set metaItem [dict get $meta $key] - set type [dict get $metaItem type] - if {$type == "line"} { - puts $fileId $value - } else { - puts $fileId "$key \"$value\"" + if { $value != $ValueToSkip } { + set values [dict set values $key "$value"] + set metaItem [dict get $meta $key] + set type [dict get $metaItem type] + if {$type == "line"} { + puts $fileId $value + } else { + puts $fileId "$key \"$value\"" + } } } set $configName [dict set config values $values] @@ -208,8 +260,11 @@ proc SaveSourceModAdmins {configName} { if {$makeMeAdmin != "1" || $steamUserName == "" || $steamId == ""} { return 0 } - global serverFolder - set fileName $serverFolder/csgo/addons/sourcemod/configs/admins.cfg + global modsFolder + if { ! [file exists "$modsFolder/sourcemod"] } { + return 0 + } + set fileName "$modsFolder/sourcemod/configs/admins.cfg" set fileid [open "$fileName" "w"] puts $fileid "//Autogenerated by csgosl at [clock format [clock seconds]]" puts $fileid "//DON'T EDIT, WILL BE OVERWRITTEN NEXT TIME YOU SAVE!!!" diff --git a/src/config_page.tcl b/src/config_page.tcl index 7407369..ac22799 100755 --- a/src/config_page.tcl +++ b/src/config_page.tcl @@ -53,6 +53,11 @@ proc CreateConfigPageText {at parms} { pack [label $at -text "$text" -anchor w] -side top -fill x -expand true } +proc CreateConfigPageWarning {at parms} { + set text [lindex $parms 0] + pack [label $at -text "$text" -anchor w -foreground red] -side top -fill x -expand true +} + proc CreateConfigPageLine {at parms} { pack [frame $at -relief groove -borderwidth 2 -width 2 -height 2] -fill x } @@ -131,6 +136,8 @@ proc CreateConfigPageFromLayout {at layout} { CreateConfigPageUrl $page.url$widgetIx $args } elseif {$type == "text"} { CreateConfigPageText $page.h2$widgetIx $args + } elseif {$type == "warning"} { + CreateConfigPageWarning $page.h2$widgetIx $args } elseif {$type == "line"} { CreateConfigPageLine $page.line$widgetIx $args } elseif {$type == "space"} { diff --git a/src/contribs.tcl b/src/contribs.tcl index d5c9434..2c2ef6b 100644 --- a/src/contribs.tcl +++ b/src/contribs.tcl @@ -14,15 +14,30 @@ set windows_unzip_url "ftp://ftp.info-zip.org/pub/infozip/win32/unz600xn.exe" set windows_img_version "1.3" set windows_img_home_url "http://www.tcl.tk/starkits/" set windows_img_url "http://www.tcl.tk/starkits/img.kit" +set windows_wget_version "1.17.1-win32" +set windows_wget_home_url "https://www.gnu.org/software/wget" +set windows_wget_url "https://eternallybored.org/misc/wget/releases/wget-1.17.1-win32.zip" set linux_metamod_version "1.10.6" set linux_metamod_home_url "http://www.metamodsource.net/" set linux_metamod_url "http://www.gsptalk.com/mirror/sourcemod/mmsource-1.10.6-linux.tar.gz" -set linux_sourcemod_version "1.7.3-git5302" +set linux_sourcemod_version "1.7.3-git5303" set linux_sourcemod_home_url "http://www.sourcemod.net/" -set linux_sourcemod_url "http://www.sourcemod.net/smdrop/1.7/sourcemod-1.7.3-git5302-linux.tar.gz" +set linux_sourcemod_url "http://www.sourcemod.net/smdrop/1.7/sourcemod-1.7.3-git5303-linux.tar.gz" +set linux_franug_knifes_version "sha-ff449c6-2016-05-05" +set linux_franug_knifes_home_url "https://github.com/Franc1sco/Franug-Knifes" +set linux_franug_knifes_url "https://github.com/Franc1sco/Franug-Knifes/archive/ff449c6.zip" +set linux_franug_weapon_paints_version "sha-fc7178d-2016-05-05" +set linux_franug_weapon_paints_home_url "https://github.com/Franc1sco/Franug-Weapon_Paints" +set linux_franug_weapon_paints_url "https://github.com/Franc1sco/Franug-Weapon_Paints/archive/fc7178d.zip" set windows_metamod_version "1.10.6" set windows_metamod_home_url "http://www.metamodsource.net/" set windows_metamod_url "http://mirror.pointysoftware.net/alliedmodders/mmsource-1.10.6-windows.zip" -set windows_sourcemod_version "1.7.3-git5302" +set windows_sourcemod_version "1.7.3-git5303" set windows_sourcemod_home_url "http://www.sourcemod.net/" -set windows_sourcemod_url "https://www.sourcemod.net/smdrop/1.7/sourcemod-1.7.3-git5302-windows.zip" +set windows_sourcemod_url "https://www.sourcemod.net/smdrop/1.7/sourcemod-1.7.3-git5303-windows.zip" +set windows_franug_knifes_version "sha-ff449c6-2016-05-05" +set windows_franug_knifes_home_url "https://github.com/Franc1sco/Franug-Knifes" +set windows_franug_knifes_url "https://github.com/Franc1sco/Franug-Knifes/archive/ff449c6.zip" +set windows_franug_weapon_paints_version "sha-fc7178d-2016-05-05" +set windows_franug_weapon_paints_home_url "https://github.com/Franc1sco/Franug-Weapon_Paints" +set windows_franug_weapon_paints_url "https://github.com/Franc1sco/Franug-Weapon_Paints/archive/fc7178d.zip" diff --git a/src/csgosl.tcl b/src/csgosl.tcl index 3852609..4e770fd 100755 --- a/src/csgosl.tcl +++ b/src/csgosl.tcl @@ -17,6 +17,7 @@ source [file join $starkit::topdir version.tcl] source [file join $starkit::topdir os.tcl] source [file join $starkit::topdir unzip.tcl] source [file join $starkit::topdir untar.tcl] +source [file join $starkit::topdir latest_release.tcl] source [file join $starkit::topdir config.tcl] source [file join $starkit::topdir config_file.tcl] source [file join $starkit::topdir config_page.tcl] @@ -28,10 +29,15 @@ source [file join $starkit::topdir server_support.tcl] source [file join $starkit::topdir wget.tcl] source [file join $starkit::topdir trace.tcl] source [file join $starkit::topdir sframe.tcl] +source [file join $starkit::topdir browser.tcl] proc RunAssync {command} { global executorCommand set executorCommand "$command" + if { [IsDryRun] } { + Trace "*** THIS IS A DRY RUN! ***" + return 0 + } ExecutorRun } @@ -40,6 +46,11 @@ proc Every {ms body} { after $ms [list after idle [info level 0]] } +proc IsDryRun {} { + global applicationConfig + GetConfigValue $applicationConfig dryrun +} + proc SaveProcDummy {} { } @@ -53,6 +64,7 @@ proc SaveAll {} { if { $serverPresent } { SaveConfigFileMapGroups SaveConfigFileRun + SaveConfigFileSourcemod SaveConfigFileApplication SaveConfigFileGameModeAll SaveConfigFileGameModeArmsrace @@ -77,6 +89,8 @@ proc SetStartStopServerButtonText {} { #main +set ValueToSkip "--skip--" + #Default value until config is read set traceEnabled 0 @@ -88,10 +102,13 @@ if { $currentOs == "windows" } { } set installFolder [pwd] +set NeedsUpgradeFileName "$installFolder/bin/needsupgrade" +set needsUpgrade [file exists "$NeedsUpgradeFileName"] set serverFolder "$installFolder/server" set serverPresent [DetectServerInstalled "$serverFolder"] set serverCfgPath "$serverFolder/csgo/cfg" set steamcmdFolder "$installFolder/steamcmd" +set modsFolder "$serverFolder/csgo/addons" if { !$serverPresent } { tk_dialog .w "No installed server detected..." \ @@ -126,6 +143,10 @@ proc SaveConfigFileApplication {} { set traceEnabled [GetConfigValue $applicationConfig trace] +if { $needsUpgrade } { + Trace "This is the first run after upgrade, upgrading..." +} + set tclConsoleEnabled [GetConfigValue $applicationConfig tclconsole] if { $tclConsoleEnabled } { @@ -156,15 +177,25 @@ variable serverOrigConfig [CreateConfig \ saveProc "SaveConfigFileOrigServer" \ ] \ [list \ - "int" [list sv_maxrate "0" "dc"]\ - "int" [list sv_minrate "100000" "dc"]\ - "int" [list sv_maxupdaterate "128" "dc"]\ - "int" [list sv_minupdaterate "128" "dc"]\ - "int" [list sv_maxcmdrate "128" "dc"]\ - "int" [list sv_mincmdrate "128" "dc"]\ - "int" [list net_splitpacket_maxrate "30000" "dc"]\ - "string" [list rcon_password "" "dc"]\ - "line" [list netmaxfilesize "sm_cvar net_maxfilesize 64" "dc"]\ + "int" [list sv_maxrate "" ""]\ + "int" [list sv_minrate "" ""]\ + "int" [list sv_maxupdaterate "" ""]\ + "int" [list sv_minupdaterate "" ""]\ + "int" [list sv_maxcmdrate "" ""]\ + "int" [list sv_mincmdrate "" ""]\ + "int" [list net_splitpacket_maxrate "" ""]\ + "string" [list rcon_password "" ""]\ + "line" [list netmaxfilesize "" ""]\ + "bool" [list sm_mapvote_endvote "" ""]\ + "int" [list sm_mapvote_voteduration "" ""]\ + "int" [list sm_mapvote_include "" ""]\ + "int" [list sm_mapvote_exclude "" ""]\ + "bool" [list sm_weaponpaints_onlyadmin "" ""]\ + "bool" [list sm_weaponpaints_c4 "" ""]\ + "int" [list sm_weaponpaints_saytimer "" ""]\ + "int" [list sm_weaponpaints_roundtimer "" ""]\ + "bool" [list sm_weaponpaints_rmenu "" ""]\ + "bool" [list sm_weaponpaints_zombiesv "" ""]\ ] \ ] @@ -194,6 +225,39 @@ proc SaveConfigFileOrigServer {} { set netmaxfilesizeName [GetGlobalConfigVariableName ServerOrig netmaxfilesize] global $netmaxfilesizeName set $netmaxfilesizeName "sm_cvar net_maxfilesize $netmaxfilesize" + + global sourcemodConfig + global runConfig + global ValueToSkip + set maps [GetActiveMaps] + if { [IsSourcemodPluginEnabled [GetConfigItem $sourcemodConfig sm_mapchooser_enable] [GetConfigItem $sourcemodConfig sm_mapchooser_lanonly]] } { + SetConfigItem $serverOrigConfig sm_mapvote_endvote [GetConfigItem $sourcemodConfig sm_mapchooser_mapvote_endvote] + SetConfigItem $serverOrigConfig sm_mapvote_voteduration [GetConfigItem $runConfig roundtime] + SetConfigItem $serverOrigConfig sm_mapvote_include [llength $maps] + SetConfigItem $serverOrigConfig sm_mapvote_exclude 0 + } else { + SetConfigItem $serverOrigConfig sm_mapvote_endvote $ValueToSkip + SetConfigItem $serverOrigConfig sm_mapvote_voteduration $ValueToSkip + SetConfigItem $serverOrigConfig sm_mapvote_include $ValueToSkip + SetConfigItem $serverOrigConfig sm_mapvote_exclude $ValueToSkip + } + + if { [IsSourcemodPluginEnabled [GetConfigItem $sourcemodConfig sm_franug_weaponpaints_enable] [GetConfigItem $sourcemodConfig sm_franug_weaponpaints_lanonly]] } { + SetConfigItem $serverOrigConfig sm_weaponpaints_c4 [GetConfigItem $sourcemodConfig sm_franug_weaponpaints_c4] + SetConfigItem $serverOrigConfig sm_weaponpaints_saytimer [GetConfigItem $sourcemodConfig sm_franug_weaponpaints_saytimer] + SetConfigItem $serverOrigConfig sm_weaponpaints_roundtimer [GetConfigItem $sourcemodConfig sm_franug_weaponpaints_roundtimer] + SetConfigItem $serverOrigConfig sm_weaponpaints_rmenu [GetConfigItem $sourcemodConfig sm_franug_weaponpaints_rmenu] + SetConfigItem $serverOrigConfig sm_weaponpaints_onlyadmin [GetConfigItem $sourcemodConfig sm_franug_weaponpaints_onlyadmin] + SetConfigItem $serverOrigConfig sm_weaponpaints_zombiesv [GetConfigItem $sourcemodConfig sm_franug_weaponpaints_zombiesv] + } else { + SetConfigItem $serverOrigConfig sm_weaponpaints_c4 $ValueToSkip + SetConfigItem $serverOrigConfig sm_weaponpaints_saytimer $ValueToSkip + SetConfigItem $serverOrigConfig sm_weaponpaints_roundtimer $ValueToSkip + SetConfigItem $serverOrigConfig sm_weaponpaints_rmenu $ValueToSkip + SetConfigItem $serverOrigConfig sm_weaponpaints_onlyadmin $ValueToSkip + SetConfigItem $serverOrigConfig sm_weaponpaints_zombiesv $ValueToSkip + } + SaveConfigFile serverOrigConfig } @@ -207,6 +271,31 @@ proc SaveConfigFileSteam {} { SaveSourceModAdmins steamConfig } +## Sourcemod config +source [file join $starkit::topdir page_sourcemod.tcl] + +EnsureConfigFile sourcemodConfig +LoadConfigFile sourcemodConfig +proc SaveConfigFileSourcemod {} { + + #Disable all risky plugins if banprotection is enabled + global sourcemodConfig + if {[GetConfigItem $sourcemodConfig banprotection]} { + global sourcemodPlugins + foreach {plugin pluginParms} $sourcemodPlugins { + set pluginRisky [lindex $pluginParms 0] + if { $pluginRisky } { + set pluginEnabledName [lindex $pluginParms 1] + SetConfigItem $sourcemodConfig $pluginEnabledName 0 + } + } + } + + SaveConfigFile sourcemodConfig + EnforceSourcemodConfig + SaveSimpleAdmins [GetConfigItem $sourcemodConfig admins] +} + ## Maps config SetTitle "$name $version - loading maps..." variable allMaps @@ -225,6 +314,9 @@ proc SaveConfigFileMapGroups {} { global serverFolder SaveConfigFile mapGroupsConfig SaveMapGroupsMapper "$configFolder/mapGroupsMapper.cfg" + SaveMapListTxt "$serverFolder/csgo/maplist.txt" + global runConfig + SaveMapCycleTxt "$serverFolder/csgo/mapcycle.txt" [GetConfigValue $runConfig mapgroup] SaveGameModesServer "$serverFolder/csgo/gamemodes_server.txt" } variable mapGroupsMapper [dict create] @@ -426,6 +518,9 @@ set serverPage [CreateConfigPageFromLayout $cp.server $serverLayout] CreateConfigPageTabFromLayout $cp.steam $steamLayout $enableTab set steamPage [CreateConfigPageFromLayout $cp.steam $steamLayout] +CreateConfigPageTabFromLayout $cp.sourcemod $sourcemodLayout $enableTab +set steamPage [CreateConfigPageFromLayout $cp.sourcemod $sourcemodLayout] + CreateConfigPageTabFromLayout $cp.maps $mapsLayout $enableTab set mapsPage [CreateConfigPageFromLayout $cp.maps $mapsLayout] @@ -526,6 +621,43 @@ if {$serverPresent} { Every 2000 StoreChangedMainWinGeometry } +proc UpgradeCheck {} { + global applicationConfig + global version + if { [GetConfigItem $applicationConfig updatecheck] } { + set latestRelease [GetLatestRelease] + if { $latestRelease != "" } { + if { $latestRelease != $version } { + set reply [tk_dialog .w "csgosl update $latestRelease is available!" \ + "A new csgosl version $latestRelease is available!\n\nDo you want to update your version $version to $latestRelease?\n\nThis dialog box will go away when you update.\nYou can also disable this check in the Application Page." \ + questhead 0 "Of course!" "Not now"] + if { $reply == 0 } { + Browser "https://github.com/lenosisnickerboa/csgosl/releases" + Browser "https://github.com/lenosisnickerboa/csgosl/wiki/Upgrade%20a%20server" + } + } else { + Trace "Running latest release." + } + } else { + Trace "Failed to get latest release!" + } + } + +} + +if {$serverPresent} { + after 10000 UpgradeCheck +} + +if { $serverPresent && $needsUpgrade } { + UpdateMods + if { [file exists "$NeedsUpgradeFileName"] } { + file delete -force "$NeedsUpgradeFileName" + } +} + + + #bind . {puts "You pressed the key named: %K "} #bind . {puts "You pressed button: %b at %x %y"} diff --git a/src/latest_release.tcl b/src/latest_release.tcl new file mode 100755 index 0000000..c1a07c3 --- /dev/null +++ b/src/latest_release.tcl @@ -0,0 +1,24 @@ +#!/bin/sh +# -*- tcl -*- +# The next line is executed by /bin/sh, but not tcl \ +exec wish "$0" ${1+"$@"} + +source [file join $starkit::topdir trace.tcl] +source [file join $starkit::topdir wget.tcl] + +proc GetLatestRelease {} { + Trace "Getting latest release..." + set releaseFileName "release-info.txt" + Wget "https://github.com/lenosisnickerboa/csgosl/releases/latest" $releaseFileName + set fp [open "$releaseFileName" r] + set fileData [read $fp] + close $fp + set data [split $fileData "\n"] + foreach line $data { + if { [regexp {.*\/lenosisnickerboa\/csgosl\/releases\/download\/v(.*)\/csgosl-linux\.zip.*} $line -> version] } { + Trace "Found latest release $version" + return $version + } + } + return "" +} diff --git a/src/maps_support.tcl b/src/maps_support.tcl index 28dfaa8..869250b 100755 --- a/src/maps_support.tcl +++ b/src/maps_support.tcl @@ -149,3 +149,15 @@ proc CacheMaps {maps mapsMeta} { } } } + +proc GetActiveMaps {} { + global mapGroupsMapper + global runConfig + set selectedMapGroup [GetConfigValue $runConfig mapgroup] + if { [dict exists $mapGroupsMapper $selectedMapGroup] } { + return [dict get $mapGroupsMapper $selectedMapGroup] + } else { + global allMaps + return $allMaps + } +} diff --git a/src/page_about.tcl b/src/page_about.tcl index 8f43ec4..615fc98 100755 --- a/src/page_about.tcl +++ b/src/page_about.tcl @@ -43,7 +43,11 @@ proc GetContributors {} { windows_sdx_version windows_sdx_home_url windows_sdx_url \ windows_sourcemod_version windows_sourcemod_home_url windows_sourcemod_url\ windows_metamod_version windows_metamod_home_url windows_metamod_url\ - windows_unzip_version windows_unzip_home_url windows_unzip_url + windows_unzip_version windows_unzip_home_url windows_unzip_url \ + windows_wget_version windows_wget_home_url windows_wget_url \ + windows_franug_weapon_paints_version windows_franug_weapon_paints_home_url windows_franug_weapon_paints_url \ + windows_franug_knifes_version windows_franug_knifes_home_url windows_franug_knifes_url + set contribs \ [list \ h2 [list "Sourcemod $windows_sourcemod_version"] \ @@ -51,6 +55,16 @@ proc GetContributors {} { url [list "Homepage" "$windows_sourcemod_home_url"] \ url [list "Download $windows_sourcemod_version" "$windows_sourcemod_url"] \ space [list] \ + h2 [list "Sourcemod plugin: Franug-Weapon_Paints $windows_franug_weapon_paints_version"] \ + line [list] \ + url [list "Homepage" "$windows_franug_weapon_paints_home_url"] \ + url [list "Download $windows_franug_weapon_paints_version" "$windows_franug_weapon_paints_url"] \ + space [list] \ + h2 [list "Sourcemod plugin: Franug-Knifes $windows_franug_knifes_version"] \ + line [list] \ + url [list "Homepage" "$windows_franug_knifes_home_url"] \ + url [list "Download $windows_franug_knifes_version" "$windows_franug_knifes_url"] \ + space [list] \ h2 [list "Metamod $windows_metamod_version"] \ line [list] \ url [list "Homepage" "$windows_metamod_home_url"] \ @@ -61,6 +75,11 @@ proc GetContributors {} { url [list "Homepage" "$windows_unzip_home_url"] \ url [list "Download $windows_unzip_version" "$windows_unzip_url"] \ space [list] \ + h2 [list "Wget $windows_wget_version"] \ + line [list] \ + url [list "Homepage" "$windows_wget_home_url"] \ + url [list "Download $windows_wget_version" "$windows_wget_url"] \ + space [list] \ h2 [list "Tclkit $windows_tclkit_version"] \ line [list] \ url [list "Homepage" "$windows_tclkit_home_url"] \ @@ -74,7 +93,9 @@ proc GetContributors {} { } else { global \ linux_sourcemod_version linux_sourcemod_home_url linux_sourcemod_url \ - linux_metamod_version linux_metamod_home_url linux_metamod_url + linux_metamod_version linux_metamod_home_url linux_metamod_url \ + linux_franug_weapon_paints_version linux_franug_weapon_paints_home_url linux_franug_weapon_paints_url \ + linux_franug_knifes_version linux_franug_knifes_home_url linux_franug_knifes_url set contribs \ [list \ h2 [list "Sourcemod $linux_sourcemod_version"] \ @@ -82,6 +103,16 @@ proc GetContributors {} { url [list "Homepage" "$linux_sourcemod_home_url"] \ url [list "Download $linux_sourcemod_version" "$linux_sourcemod_url"] \ space [list] \ + h2 [list "Sourcemod plugin: Franug-Weapon_Paints $linux_franug_weapon_paints_version"] \ + line [list] \ + url [list "Homepage" "$linux_franug_weapon_paints_home_url"] \ + url [list "Download $linux_franug_weapon_paints_version" "$linux_franug_weapon_paints_url"] \ + space [list] \ + h2 [list "Sourcemod plugin: Franug-Knifes $linux_franug_knifes_version"] \ + line [list] \ + url [list "Homepage" "$linux_franug_knifes_home_url"] \ + url [list "Download $linux_franug_knifes_version" "$linux_franug_knifes_url"] \ + space [list] \ h2 [list "Metamod $linux_metamod_version"] \ line [list] \ url [list "Homepage" "$linux_metamod_home_url"] \ diff --git a/src/page_application.tcl b/src/page_application.tcl index fa92383..9728363 100755 --- a/src/page_application.tcl +++ b/src/page_application.tcl @@ -14,7 +14,9 @@ variable applicationConfig [CreateConfig \ [list \ "bool" [list fullconfig "0" "Enable this option to be able to fine tune all csgo server parameters.\nA number of new configuration pages, one per game mode, will be displayed.\nYou need to restart csgosl after this change."]\ "bool" [list tclconsole "0" "Open tcl console when starting csgosl.\nWindows only"]\ - "bool" [list trace "0" "Control tracing. Traces are printed to the terminal (linux) and in the console tab (Windows)."]\ + "bool" [list trace "1" "Control tracing. Traces are printed to the terminal (linux) and in the console tab (Windows)."]\ + "bool" [list dryrun "0" "Performs everything except actually starting the server.\nSometimes convenient when troubleshooting or testing.\nCommand line is traced."]\ + "bool" [list updatecheck "1" "Checks for csgosl updates after program has started."]\ "string" [list mainwingeometry "800x600+100+100" "last saved windows size and location."]\ ] \ ] @@ -36,6 +38,8 @@ variable applicationLayout [CreateLayout \ h2 [list "Troubleshooting"] \ line [list] \ space [list] \ + parm [list dryrun] \ + parm [list updatecheck] \ parm [list tclconsole] \ parm [list trace] \ space [list] \ diff --git a/src/page_server.tcl b/src/page_server.tcl index e95a54a..33cb1bb 100755 --- a/src/page_server.tcl +++ b/src/page_server.tcl @@ -15,6 +15,7 @@ variable serverConfig [CreateConfig \ "string" [list name "Your server at $hostName operated by $name" "This is the server name which is presented in the list of servers in the csgo game."]\ "string" [list password "" "Your server password which anyone connecting to your server must enter to log in and play.\nWhen running a LAN only server this can be left empty for no password.\nIf you run a public server it is *HIGHLY* recommended to set a password."]\ "bool" [list autorestart "0" "If enabled the server is auto restarted if it crashes (or is closed down, so you need to kill cmd.exe using ps/task manager prior to killing the server window)"]\ + "string" [list bindip "" "IP address which your server should bind to.\nLeave blank if you don't have a problem with connecting to the server.\nMay e.g. be used when running on a VLAN to force the server to bind to the VLAN."]\ "int" [list port "27015" "Your server port."]\ "bool" [list lanonly "1" "If enabled server is only available on your LAN. Default enabled for security reasons, disable when you want to play with friends over the Internet."]\ "int" [list tickrate "128" "Server tickrate, that is the frequency with which the server and connecting clients communicate. Connecting clients are automatically instructed to use this frequency."]\ @@ -50,6 +51,7 @@ variable serverLayout [CreateLayout \ h2 [list "Misc"] \ line [list] \ space [list] \ + parm [list bindip] \ parm [list autorestart] \ parm [list tickrate] \ parm [list netmaxfilesize] \ diff --git a/src/page_sourcemod.tcl b/src/page_sourcemod.tcl new file mode 100755 index 0000000..669c4b6 --- /dev/null +++ b/src/page_sourcemod.tcl @@ -0,0 +1,116 @@ +#!/bin/sh +# -*- tcl -*- +# The next line is executed by /bin/sh, but not tcl \ +exec wish "$0" ${1+"$@"} + +#First flag states if plugin is risky or not +variable sourcemodPlugins [list \ + mapchooser [list false sm_mapchooser_enable sm_mapchooser_lanonly mapchooser.smx] \ + nominations [list false sm_nominations_enable sm_nominations_lanonly nominations.smx] \ + rockthevote [list false sm_rockthevote_enable sm_rockthevote_lanonly rockthevote.smx] \ + nextmap [list false sm_nextmap_enable sm_nextmap_lanonly nextmap.smx] \ + randomcycle [list false sm_randomcycle_enable sm_randomcycle_lanonly randomcycle.smx] \ + franug_weaponpaints [list true sm_franug_weaponpaints_enable sm_franug_weaponpaints_lanonly franug_weaponpaints_public.smx] \ + franug_knifes [list true sm_franug_knifes_enable sm_franug_knifes_lanonly sm_franugknife.smx] \ +] + +## Sourcemod config +variable sourcemodConfig [CreateConfig \ + [list \ + name "sourcemodConfig" \ + prefix "Sourcemod" \ + fileName "$configFolder/sourcemod.cfg" \ + saveProc "SaveConfigFileSourcemod" \ + ] \ + [list \ + "bool" [list enable "1" "Controls if sourcemod functionality is enabled. If disabled ALL other plugins below are also disabled."]\ + "bool" [list lanonly "0" "Only enable sourcemod in lanonly mode"]\ + "bool" [list banprotection "1" "Disables all known unsafe plugins and sets FollowCSGOServerGuidelines to \"yes\".\nWhen you disable ban protection FollowCSGOServerGuidelines is set to \"no\" to allow plugins full access.\nDO NOT DISABLE THIS OPTION UNLESS YOU HAVE READ THE HELP PAGE FIRST!\nYOUR SERVER MAY BE BANNED!"]\ + "string" [list admins "" "List all users (separated by space) you want to give admin permissions on your server\nA user is identified by their steam id (e.g STEAM_1:1:12345678) or ip address (e.g. 192.168.1.123).\nSee help page for more information about how to obtain your steam id or find users ip address."]\ + "bool" [list sm_mapchooser_enable "0" "Controls if this sourcemod plugin is enabled."]\ + "bool" [list sm_mapchooser_lanonly "1" "Only enable this sourcemod plugin in lanonly mode"]\ + "bool" [list sm_mapchooser_mapvote_endvote "1" "Specifies if MapChooser should run an end of map vote."]\ + "bool" [list sm_nominations_enable "0" "Controls if this sourcemod plugin is enabled.\nRequires mapchooser enabled."]\ + "bool" [list sm_nominations_lanonly "1" "Only enable this sourcemod plugin in lanonly mode"]\ + "bool" [list sm_rockthevote_enable "0" "Controls if this sourcemod plugin is enabled.\nRequires mapchooser enabled."]\ + "bool" [list sm_rockthevote_lanonly "1" "Only enable this sourcemod plugin in lanonly mode"]\ + "bool" [list sm_nextmap_enable "0" "Controls if this sourcemod plugin is enabled."]\ + "bool" [list sm_nextmap_lanonly "1" "Only enable this sourcemod plugin in lanonly mode"]\ + "bool" [list sm_randomcycle_enable "0" "Controls if this sourcemod plugin is enabled."]\ + "bool" [list sm_randomcycle_lanonly "1" "Only enable this sourcemod plugin in lanonly mode"]\ + "bool" [list sm_franug_weaponpaints_enable "0" "Controls if this sourcemod plugin is enabled.\nType !ws in chat to use."]\ + "bool" [list sm_franug_weaponpaints_lanonly "1" "Only enable this sourcemod plugin in lanonly mode"]\ + "bool" [list sm_franug_weaponpaints_onlyadmin "1" "This feature is only for admins. 1 = enabled, 0 = disabled.\n(Use the value 1 and try to keep this plugin secret for the normal users because they can report it)"]\ + "bool" [list sm_franug_weaponpaints_c4 "1" "Enable or disable that people can apply paints to the C4. 1 = enabled, 0 = disabled"]\ + "int" [list sm_franug_weaponpaints_saytimer "-1" "Time in seconds for block that show the plugin commands in chat when someone type a command.\n-1 = never show the commands in chat"]\ + "int" [list sm_franug_weaponpaints_roundtimer "-1" "Time in seconds roundstart for can use the commands for change the paints.\n-1 = always can use the command"]\ + "bool" [list sm_franug_weaponpaints_rmenu "0" "Re-open the menu when you select a option. 1 = enabled, 0 = disabled."]\ + "bool" [list sm_franug_weaponpaints_zombiesv "1" "Enable this for prevent crashes in zombie and 1v1 servers for knifes.\n1 = enabled, 0 = disabled. (Use the value 1 if you use my knife plugin)"]\ + "bool" [list sm_franug_knifes_enable "0" "Controls if this sourcemod plugin is enabled.\nType !knife in chat to use."]\ + "bool" [list sm_franug_knifes_lanonly "1" "Only enable this sourcemod plugin in lanonly mode"]\ + ] \ +] + +variable sourcemodLayout [CreateLayout \ + [list \ + configName "sourcemodConfig" \ + tabName "Sourcemod" \ + help "Sourcemod" \ + ] \ + [list \ + h1 [list "Sourcemod settings"] \ + space [list] \ + h2 [list "General"] \ + line [list] \ + space [list] \ + parm [list enable] \ + parm [list lanonly] \ + parm [list admins] \ + space [list] \ + h2 [list "Plugin: mapchooser"] \ + parm [list sm_mapchooser_enable] \ + parm [list sm_mapchooser_lanonly] \ + parm [list sm_mapchooser_mapvote_endvote] \ + space [list] \ + h2 [list "Plugin: nominations"] \ + parm [list sm_nominations_enable] \ + parm [list sm_nominations_lanonly] \ + space [list] \ + h2 [list "Plugin: rockthevote"] \ + parm [list sm_rockthevote_enable] \ + parm [list sm_rockthevote_lanonly] \ + space [list] \ + h2 [list "Plugin: nextmap"] \ + parm [list sm_nextmap_enable] \ + parm [list sm_nextmap_lanonly] \ + space [list] \ + h2 [list "Plugin: randomcycle"] \ + parm [list sm_randomcycle_enable] \ + parm [list sm_randomcycle_lanonly] \ + space [list] \ + warning [list "All plugins below this line require the banprotection to be disabled. Read the help page carefully before"] \ + warning [list "disabling banprotection. Running misbehaving sourcemod plugins may cause your server to be banned by Valve."] \ + warning [list "*** I take no responsibility for if your server gets banned ***"] \ + line [list] \ + space [list] \ + parm [list banprotection] \ + warning [list "The first time you enable banprotection you need to update the server by clicking the \"Update Server\" button"] \ + warning [list "above. This will install the plugins below. The plugins will still be disabled until you enable them below. If you"] \ + warning [list "decide to reenable banprotection read the help page for instructions on how to ensure that plugins below are"] \ + warning [list "completely removed from the file system."] \ + space [list] \ + h2 [list "Plugin: Franug-Weapon_Paints"] \ + parm [list sm_franug_weaponpaints_enable] \ + parm [list sm_franug_weaponpaints_lanonly] \ + parm [list sm_franug_weaponpaints_onlyadmin] \ + parm [list sm_franug_weaponpaints_c4] \ + parm [list sm_franug_weaponpaints_saytimer] \ + parm [list sm_franug_weaponpaints_roundtimer] \ + parm [list sm_franug_weaponpaints_rmenu] \ + parm [list sm_franug_weaponpaints_zombiesv] \ + space [list] \ + h2 [list "Plugin: Franug-Knifes"] \ + parm [list sm_franug_knifes_enable] \ + parm [list sm_franug_knifes_lanonly] \ + ] \ +] diff --git a/src/sed.tcl b/src/sed.tcl new file mode 100755 index 0000000..d1adc56 --- /dev/null +++ b/src/sed.tcl @@ -0,0 +1,63 @@ +#!/bin/sh +# -*- tcl -*- +# The next line is executed by /bin/sh, but not tcl \ +exec wish "$0" ${1+"$@"} + +#source: sed taken from http://wiki.tcl.tk/9382, sedf is my wrapper around sed + +proc ::sed {script input} { + set sep [string index $script 1] + foreach {cmd from to flag} [split $script $sep] break + switch -- $cmd { + "s" { + set cmd regsub + if {[string first "g" $flag]>=0} { + lappend cmd -all + } + if {[string first "i" [string tolower $flag]]>=0} { + lappend cmd -nocase + } + set idx [regsub -all -- {[a-zA-Z]} $flag ""] + if { [string is integer -strict $idx] } { + set cmd [lreplace $cmd 0 0 regexp] + lappend cmd -inline -indices -all -- $from $input + set res [eval $cmd] + set which [lindex $res $idx] + return [string replace $input [lindex $which 0] [lindex $which 1] $to] + } + # Most generic case + lappend cmd -- $from $input $to + return [eval $cmd] + } + "e" { + set cmd regexp + if { $to eq "" } { set to 0 } + if {![string is integer -strict $to]} { + return -error code "No proper group identifier specified for extraction" + } + lappend cmd -inline -- $from $input + return [lindex [eval $cmd] $to] + } + "y" { + return [string map [list $from $to] $input] + } + } + return -code error "not yet implemented" +} + +#My added wrapper for operating on a file +proc sedf {script fileName} { + set fp [open "$fileName" r] + set fileData [read $fp] + close $fp + set data [split $fileData "\n"] + + set fp [open "$fileName" "w"] + + foreach line $data { + set line [sed $script $line] + puts $fp $line + } + close $fp +} + diff --git a/src/server_support.tcl b/src/server_support.tcl index 8a29d1b..4bcfdec 100755 --- a/src/server_support.tcl +++ b/src/server_support.tcl @@ -3,6 +3,8 @@ # The next line is executed by /bin/sh, but not tcl \ exec wish "$0" ${1+"$@"} +source [file join $starkit::topdir sed.tcl] + proc StartServer {} { global configPages global runPage @@ -17,26 +19,38 @@ proc StartServer {} { FlashConfigItem $serverPage name return } - set serverLanOption [GetConfigValue $serverConfig lanonly] - set serverLan "+sv_lan 0" - if { "$serverLanOption" == "1" } { - set serverLan "+sv_lan 1" - } - set serverPortOption [GetConfigValue $serverConfig port] - set serverPort "-port 27015" - if { "$serverPortOption" != "" } { - set serverPort "-port $serverPortOption" + + global sourcemodConfig + set banProtection [GetConfigValue $sourcemodConfig banprotection] + set steamAccountOption "" + set apiAuthKeyOption "" + set serverLanOption "+sv_lan 1" + if { $banProtection == 0 } { + Trace "=====================================================================" + Trace "Sourcemod banprotection is disabled, enforcing GSLT-less lanonly mode" + Trace "=====================================================================" + } else { + set serverLan [GetConfigValue $serverConfig lanonly] + set serverLanOption "+sv_lan $serverLan" + if { $serverLan == 0 } { + set steamAccount [GetConfigValue $steamConfig gameserverlogintoken] + if {$steamAccount != ""} { + set steamAccountOption "+sv_setsteamaccount $steamAccount" + } + set apiAuthKey [GetConfigValue $steamConfig apiauthkey] + set apiAuthKeyOption "" + if {$apiAuthKey != ""} { + set apiAuthKeyOption "-authkey $apiAuthKey" + } + } } + set serverPort [GetConfigValue $serverConfig port] - global executorCommand - set steamAccount [GetConfigValue $steamConfig gameserverlogintoken] - if {$steamAccount != ""} { - set steamAccount "+sv_setsteamaccount $steamAccount" - } - set apiAuthKey [GetConfigValue $steamConfig apiauthkey] - if {$apiAuthKey != ""} { - set apiAuthKey "-authkey $apiAuthKey" + set serverPortOption "-port 27015" + if { "$serverPort" != "" } { + set serverPortOption "-port $serverPort" } + global runConfig set gameModeTypeString [GetConfigValue $runConfig gamemodetype] global gameModeMapper @@ -71,15 +85,20 @@ proc StartServer {} { if { $password != "" } { set passwordOption "+sv_password $password" } + + global currentOs + set bindIp [GetConfigValue $serverConfig bindip] set rconEnable [GetConfigValue $serverConfig rcon] set rconCommand "" if { $rconEnable == "1" } { - #setting -ip 0.0.0.0 is a workaround on linux - set rconCommand "-usercon -condebug -ip 0.0.0.0" + set rconCommand "-usercon -condebug" + if { $currentOs == "linux" && $bindIp == "" } { + #setting -ip 0.0.0.0 is a workaround to get rcon working on linux servers + set rconCommand "$rconCommand -ip 0.0.0.0" + } } - global currentOs set consoleCommand "" if { $currentOs == "windows" } { set consoleCommand "-console" @@ -96,6 +115,11 @@ proc StartServer {} { set srcdsName "srcds" } + set ipOption "" + if { $bindIp != "" } { + set ipOption "-ip $bindIp" + } + global serverControlScript if { $currentOs == "windows" } { RunAssync "$serverControlScript-start.bat \"$serverFolder/$srcdsName\" \ @@ -103,11 +127,12 @@ proc StartServer {} { +game_type $gameType +game_mode $gameMode \ $mapGroupOption \ $mapOption \ - $steamAccount $apiAuthKey \ + $steamAccountOption $apiAuthKeyOption \ -maxplayers_override $players \ -tickrate $tickRate \ $passwordOption \ - +hostname \"$serverName\" $serverPort $serverLan \ + $ipOption \ + +hostname \"$serverName\" $serverPortOption $serverLanOption \ $options" } else { chan configure stdout -buffering none @@ -118,23 +143,31 @@ proc StartServer {} { +game_type $gameType +game_mode $gameMode \ $mapGroupOption \ $mapOption \ - $steamAccount $apiAuthKey \ + $steamAccountOption $apiAuthKeyOption \ -maxplayers_override $players \ -tickrate $tickRate \ $passwordOption \ - +hostname \"$serverName\" $serverPort $serverLan \ + $ipOption \ + +hostname \"$serverName\" $serverPortOption $serverLanOption \ $options" + + if { [IsDryRun] } { + Trace "*** THIS IS A DRY RUN! ***" + return 0 + } + exec >@stdout 2>@stderr "$serverControlScript" $control \ $serverFolder/$srcdsName \ -game csgo $consoleCommand $rconCommand \ +game_type $gameType +game_mode $gameMode \ $mapGroupOption \ $mapOption \ - $steamAccount $apiAuthKey \ + $steamAccountOption $apiAuthKeyOption \ -maxplayers_override $players \ -tickrate $tickRate \ $passwordOption \ - +hostname \"$serverName\" $serverPort $serverLan \ + $ipOption \ + +hostname \"$serverName\" $serverPortOption $serverLanOption \ $options } } @@ -153,6 +186,12 @@ proc StopServer {} { } proc UpdateServer {} { + set status [DetectServerRunning] + if { $status == "running" } { + Trace "Server is running! Stop server first and retry update!" + return 1 + } + global consolePage global currentOs if {$currentOs == "windows"} { @@ -242,12 +281,8 @@ proc UpdateServer {} { exec >@stdout 2>@stderr "$steamcmdFolder/$steamCmdExe" +runscript "$filename" } - set modsArchive "$installFolder/mods/mods.zip" - Trace "Looking for mods $modsArchive..." - if { [file exists "$modsArchive"] == 1 } { - Trace "Installing mods..." - Unzip "$modsArchive" "$serverFolder/csgo/" - } + UpdateMods + Trace "----------------" Trace "UPDATE FINISHED!" Trace "----------------" @@ -274,3 +309,187 @@ proc DetectServerRunning {} { exec "$serverControlScript" status } } + +proc IsSourcemodEnabled {} { + global serverConfig + set lanOnly [GetConfigValue $serverConfig lanonly] + global sourcemodConfig + set sourcemodEnabled [GetConfigValue $sourcemodConfig enable] + set sourcemodEnabledLanOnly [GetConfigValue $sourcemodConfig lanonly] + if { $sourcemodEnabled && $lanOnly == 0 && $sourcemodEnabledLanOnly == 1 } { +# Trace "Sourcemod is configured for lanonly mode, not running lanonly now, disabling sourcemod." + set sourcemodEnabled 0 + } + return $sourcemodEnabled +} + +proc SetSourcemodInstallStatus {sourcemodEnabled} { + global modsFolder + if { ! $sourcemodEnabled } { + Trace "Sourcemod functionality is disabled." + if { [file exists "$modsFolder/sourcemod"] } { + file rename -force "$modsFolder/sourcemod" "$modsFolder/sourcemod.DISABLED" + } + if { [file exists "$modsFolder/metamod"] } { + file rename -force "$modsFolder/metamod" "$modsFolder/metamod.DISABLED" + } + } else { + Trace "Sourcemod functionality is enabled." + if { [file exists "$modsFolder/sourcemod.DISABLED"] } { + file rename -force "$modsFolder/sourcemod.DISABLED" "$modsFolder/sourcemod" + } + if { [file exists "$modsFolder/metamod.DISABLED"] } { + file rename -force "$modsFolder/metamod.DISABLED" "$modsFolder/metamod" + } + } +} + +#Fix for pre 1.1 version installing Linux Metamod binaries on Windows +proc UpdateModsFixForMetamodSourcemodInstallBug {} { + global currentOs + if { $currentOs != "windows" } { + return 0 + } + global serverFolder + set addonsFolder "$serverFolder/csgo/addons" + if { [file exists "$addonsFolder/metamod/bin/server.so"] } { + Trace "Applying metamod install bug fix #1" + file delete -force "$addonsFolder/metamod/bin" + } + if { [file exists "$addonsFolder/sourcemod/bin/sourcemod.logic.so"] } { + Trace "Applying sourcemod install bug fix #1" + file delete -force "$addonsFolder/sourcemod/bin" + } + if { [file exists "$addonsFolder/sourcemod/extensions/bintools.ext.so"] } { + Trace "Applying sourcemod install bug fix #2" + file delete -force "$addonsFolder/sourcemod/extensions" + } +} + +proc UpdateMods {} { + global installFolder + global serverFolder + #Make sure sourcemod is enabled to be able to update it + SetSourcemodInstallStatus true + + UpdateModsFixForMetamodSourcemodInstallBug + + set modsArchive "$installFolder/mods/mods.zip" + Trace "Looking for mods $modsArchive..." + if { [file exists "$modsArchive"] == 1 } { + Trace "Installing mods..." + Unzip "$modsArchive" "$serverFolder/csgo/" + } + + global sourcemodConfig + if { [GetConfigValue $sourcemodConfig banprotection] == 0 } { + set modsArchive "$installFolder/mods/mods-risky.zip" + Trace "Looking for risky mods $modsArchive..." + if { [file exists "$modsArchive"] == 1 } { + Trace "Installing risky mods..." + Unzip "$modsArchive" "$serverFolder/csgo/" + } + } + + SaveAll + #Restore sourcemod conf after update + EnforceSourcemodConfig +} + +proc SaveSimpleAdmins {admins} { + global modsFolder + set configFolder "$modsFolder/sourcemod/configs" + if { ! [file exists $configFolder] } { + set configFolder "$modsFolder/sourcemod.DISABLED/configs" + } + if { [file exists $configFolder] } { + SaveSimpleAdminsFile "$configFolder/admins_simple.ini" $admins + } +} + +proc IsSourcemodPluginEnabled {pluginEnabled pluginLanOnly} { + global serverConfig + set lanOnly [GetConfigValue $serverConfig lanonly] + if { $pluginEnabled && $lanOnly == 0 && $pluginLanOnly == 1 } { + return 0 + } else { + return $pluginEnabled + } +} + +proc SetSourcemodPluginsInstallStatus {} { + global sourcemodConfig + global sourcemodPlugins + foreach {plugin pluginParms} $sourcemodPlugins { + set pluginRisky [lindex $pluginParms 0] + set pluginEnabledName [lindex $pluginParms 1] + set pluginEnabled [GetConfigValue $sourcemodConfig $pluginEnabledName] + set pluginLanOnlyName [lindex $pluginParms 2] + set pluginLanOnly [GetConfigValue $sourcemodConfig $pluginLanOnlyName] + set pluginSmxName [lindex $pluginParms 3] + set pluginEnabled [IsSourcemodPluginEnabled $pluginEnabled $pluginLanOnlyName] + EnforceSourcemodPluginConfig $pluginSmxName $pluginEnabled + } +} + +proc SetFollowCSGOServerGuidelines {} { + global modsFolder + global sourcemodConfig + set FollowCSGOServerGuidelines "yes" + set sourcemodBanProtectionEnabled [GetConfigValue $sourcemodConfig banprotection] + if { $sourcemodBanProtectionEnabled == 0 } { + set FollowCSGOServerGuidelines "no" + } + set configFolder "$modsFolder/sourcemod/configs" + if { ! [file exists $configFolder] } { + set configFolder "$modsFolder/sourcemod.DISABLED/configs" + } + if { [file exists $configFolder] } { + sedf "s/.*FollowCSGOServerGuidelines.*/\"FollowCSGOServerGuidelines\" \"$FollowCSGOServerGuidelines\"/g" "$configFolder/core.cfg" + } +} + +proc EnforceSourcemodConfig {} { + set status [DetectServerRunning] + if { $status == "running" } { + Trace "Server is running! Stop server first and retry!" + return 1 + } + + set sourcemodEnabled [IsSourcemodEnabled] + SetSourcemodInstallStatus $sourcemodEnabled + + if { ! $sourcemodEnabled } { + return 0 + } + + SetSourcemodPluginsInstallStatus + + SetFollowCSGOServerGuidelines +} + +proc EnforceSourcemodPluginConfig {pluginFileName pluginEnabled} { + global modsFolder + set sourcemodPluginFolder "$modsFolder/sourcemod/plugins" + if { $pluginEnabled } { + Trace "Plugin $pluginFileName is enabled" + if { [file exists "$sourcemodPluginFolder/disabled/$pluginFileName"] } { + #Could be an updated plugin which is always installed into the disabled folder by default + if { [file exists "$sourcemodPluginFolder/$pluginFileName"] } { + file delete -force "$sourcemodPluginFolder/$pluginFileName" + } + file rename -force "$sourcemodPluginFolder/disabled/$pluginFileName" "$sourcemodPluginFolder/$pluginFileName" + } + } else { + Trace "Plugin $pluginFileName is disabled" + if { [file exists "$sourcemodPluginFolder/$pluginFileName"] } { + #If target file exists in disabled folder keep it, and just remove the plugin from the active folder + #Might be an updated plugin... + if { [file exists "$sourcemodPluginFolder/disabled/$pluginFileName"] } { + file delete -force "$sourcemodPluginFolder/$pluginFileName" + } else { + file rename -force "$sourcemodPluginFolder/$pluginFileName" "$sourcemodPluginFolder/disabled/$pluginFileName" + } + } + } +} diff --git a/src/version.tcl b/src/version.tcl index 9adb3aa..32f1dfd 100755 --- a/src/version.tcl +++ b/src/version.tcl @@ -3,5 +3,5 @@ # The next line is executed by /bin/sh, but not tcl \ exec wish "$0" ${1+"$@"} -set version "1.0.5" +set version "1.1" diff --git a/src/wget.tcl b/src/wget.tcl index b8bdcda..0cce133 100755 --- a/src/wget.tcl +++ b/src/wget.tcl @@ -3,21 +3,31 @@ # The next line is executed by /bin/sh, but not tcl \ exec wish "$0" ${1+"$@"} -#source: http://wiki.tcl.tk/12871 - -#: minimal wget - wiki.tcl.tk/12871 / Radio-edition - 2012-12-28 package require http source [file join $starkit::topdir trace.tcl] +#Keep, but doesn't support https +#proc Wget {url filename} { +# Trace "Wget: $url -> $filename" +# set r [http::geturl $url -binary 1] +# set fo [open $filename w] +# fconfigure $fo -translation binary +# puts -nonewline $fo [http::data $r] +# close $fo +# ::http::cleanup $r +# Trace "Wget: $url -> $filename OK" +#} + proc Wget {url filename} { Trace "Wget: $url -> $filename" - set r [http::geturl $url -binary 1] - set fo [open $filename w] - fconfigure $fo -translation binary - puts -nonewline $fo [http::data $r] - close $fo - ::http::cleanup $r - Trace "Wget: $url -> $filename OK" + global currentOs + if { $currentOs == "windows" } { + global installFolder + exec "$installFolder/bin/wget" "$url" --quiet -O "$filename" + } else { + exec "wget" "$url" --quiet -O "$filename" + } + Trace "Wget: $url -> $filename OK" } \ No newline at end of file