├── .gitignore ├── LICENSE ├── README.md ├── functions ├── define_colors.func ├── download.func ├── help.func ├── read_options.func └── update.func ├── packagecache └── .gitempty ├── settings └── update.sh /.gitignore: -------------------------------------------------------------------------------- 1 | packagecache/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Bernhard Kaszt 2 | 3 | The Software shall be used for Good, not Evil. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **This project is not actively maintained anymore, please fork this** 2 | 3 | Sourcemod updater 4 | ================= 5 | 6 | Updates or installs the latest Sourcemod stable release or snapshots. 7 | 8 | ![alt text](https://i.imgur.com/5vymVpT.png "Screenshot") 9 | 10 | # Features 11 | 12 | * Installs/updates stable releases or snapshots 13 | * Custom files and plugins won't get overwritten (except you modified core files) 14 | * Configuration will not be touched (You have to update them yourself) 15 | * Downloaded packages will be cached and not downloaded the next time 16 | * Can fix the permission afterwards (--fixpermissions) 17 | 18 | # Installation 19 | 20 | ```shell 21 | # Change to any directory where you want to install it first 22 | aptitude install lynx wget findutils rsync 23 | wget https://github.com/bcserv/sourcemod-updater/archive/master.zip -O sourcemod-updater.zip 24 | unzip sourcemod-updater.zip 25 | mv sourcemod-updater-master sourcemod-updater 26 | cd sourcemod-updater 27 | chmod u+x update.sh 28 | chmod u+w packagecache 29 | ./update.sh 30 | ``` 31 | 32 | # Usage 33 | 34 | ### Syntax 35 | ```shell 36 | ./update.sh [] --snapshot-stable --snapshot-dev --install --dontask --fixpermissions 37 | ``` 38 | 39 | ### Options 40 | 41 | #### --snapshot-stable 42 | 43 | Updates or installs the latest Sourcemod STABLE snapshot. 44 | 45 | #### --snapshot-dev 46 | 47 | Updates or installs the latest Sourcemod DEV snapshot. 48 | 49 | #### --install 50 | 51 | Installs sourcemod instead of updating. 52 | CAUTION: this will overwrite any existing sourcemod files. 53 | 54 | #### --dontask 55 | 56 | Never ask for anything during execution. 57 | This affects the situation when no package URL was found or 58 | the security check before continuing the update 59 | 60 | #### --fixpermissions 61 | 62 | Reads the owner and the group of the game directory of the srcds after the update 63 | and applies them recursively to the sourcemod files. 64 | This is needed if the update is executed by root and the srcds doesn't run as root. 65 | 66 | #### --smdir 67 | 68 | Sets an alternative name for the addons/sourcemod directory. 69 | If you are using srcds forks and need multiple sourcemod installations, 70 | you have to set this. 71 | 72 | ### Examples 73 | ```shell 74 | ./update.sh /game/css/cstrike 75 | 76 | ./update.sh /srcds/css/cstrike --install --fixpermissions # Install sourcemod and fix the file permissions afterwards 77 | ./update.sh /srcds/css/cstrike --snapshot-stable # Update sourcemod to the latest STABLE snapshot 78 | ./update.sh /srcds/css/cstrike --snapshot-dev # Update sourcemod to the latest DEV snapshot 79 | ./update.sh /srcds/css/cstrike --dontask # Never ask for anything 80 | ``` 81 | 82 | # Behavior on updating 83 | 84 | * bin - full replace 85 | * configs - replaces geoip and sql-init-scripts, doesn't touch anything else 86 | * data - not touched 87 | * extensions - overwrites core files; custom files won't be touched 88 | * gamedata - fully replaces core.games/, sdktools.games/ and sm-*.txt files 89 | * logs - not touched 90 | * plugins - overwrites core files; custom files won't be touched; new core plugins go to disabled/ 91 | * scripting - overwrites core files; custom files won't be touched 92 | * translations - overwrites core files; custom files won't be touched 93 | 94 | full replace means also deleting files that are not in the update package 95 | 96 | # Settings 97 | 98 | ```bash 99 | # The source code of this page will be searched for the latest sourcemod package 100 | # We assume that the last one is the latest 101 | SNAPSHOT_STABLE_MIRROR="http://www.sourcemod.net/smdrop/1.10/" 102 | SNAPSHOT_STABLE_SEARCHPATTER="http:.*sourcemod-.*-linux.*gz" 103 | 104 | SNAPSHOT_DEV_MIRROR="http://www.sourcemod.net/smdrop/1.11/" 105 | SNAPSHOT_DEV_SEARCHPATTER="http:.*sourcemod-.*-linux.*gz" 106 | ``` 107 | -------------------------------------------------------------------------------- /functions/define_colors.func: -------------------------------------------------------------------------------- 1 | function define_colors 2 | { 3 | header='\E[33;44m\033[1m' 4 | red='\E[31;40m' 5 | green='\E[32;40m' 6 | yellow='\E[33;40m' 7 | blue='\E[34;40m' 8 | magenta='\E[35;40m' 9 | cyan='\E[36;40m' 10 | white='\E[37;40m' 11 | orange='\E[01;40m' 12 | reset='\E[0m' 13 | } 14 | -------------------------------------------------------------------------------- /functions/download.func: -------------------------------------------------------------------------------- 1 | function download 2 | { 3 | if [[ $url_sourcemod_package == "" ]]; then 4 | echo -e "You didn't specify an URL as argument to download sourcemod from." 5 | echo -e "I will try to get the latest sourcemod release automatically..." 6 | echo "" 7 | 8 | if [[ ${options[snapshot-stable]} == "1" ]]; then 9 | sourcemod_mirror="$SNAPSHOT_STABLE_MIRROR" 10 | search_pattern="$SNAPSHOT_STABLE_SEARCHPATTER" 11 | else 12 | if [[ ${options[snapshot-dev]} == "1" ]]; then 13 | sourcemod_mirror="$SNAPSHOT_DEV_MIRROR" 14 | search_pattern="$SNAPSHOT_DEV_SEARCHPATTER" 15 | else 16 | sourcemod_mirror="$SNAPSHOT_STABLE_MIRROR" 17 | search_pattern="$SNAPSHOT_STABLE_SEARCHPATTER" 18 | fi 19 | fi 20 | 21 | sourcemod_latest_basename=`wget -qO- "$sourcemod_mirror/sourcemod-latest-linux"` 22 | 23 | if [[ ${#sourcemod_latest_basename} -gt "0" ]]; then 24 | url_sourcemod_package="$sourcemod_mirror$sourcemod_latest_basename" 25 | elif hash lynx 2>/dev/null; then 26 | echo "Attempting to scrape the download mirror for the package using lynx..." 27 | url_sourcemod_package=`lynx -dump "$sourcemod_mirror" | egrep -o "$search_pattern" | tail -1` 28 | else 29 | echo -e "${red}Error: Could not retrieve latest version of Sourcemod. Please install lynx for scraping.$reset" 30 | fi 31 | 32 | if [[ $url_sourcemod_package == "" ]]; then 33 | echo -e "${red}Error: Scanning for the latest sourcemod package failed.$reset" 34 | 35 | if [[ ${options[dontask]} != "1" ]]; then 36 | echo -e "${cyan}Please enter a direct URL for downloading Sourcemod:$reset" 37 | read url_sourcemod_package 38 | fi 39 | 40 | if [[ $url_sourcemod_package == "" ]]; then 41 | echo -e "${red}URL empty, aborting.$reset" 42 | return 0 43 | fi 44 | fi 45 | else 46 | package_url="$1" 47 | fi 48 | 49 | 50 | filename=$(basename "$url_sourcemod_package") 51 | 52 | if [[ $filename != *.tar.gz ]]; then 53 | echo -e "${red}Error: File doesn't end with '.tar.gz', aborting.$reset" 54 | return 0 55 | fi 56 | 57 | echo -e "${green}Found sourcemod package:$reset" 58 | echo -e "${cyan}URL: $yellow$url_sourcemod_package$reset" 59 | echo -e "Trying to download file $yellow$filename$reset now.$reset" 60 | echo "" 61 | 62 | wget --directory-prefix="packagecache" --no-clobber --verbose "$url_sourcemod_package" 63 | 64 | echo -e "${green}File downloaded successfully :)$reset" 65 | 66 | return 1 67 | } 68 | -------------------------------------------------------------------------------- /functions/help.func: -------------------------------------------------------------------------------- 1 | function help 2 | { 3 | echo -e "${cyan}[ USAGE ]$reset" 4 | echo "" 5 | echo -e "${cyan}Syntax:$reset $0 [ --snapshot-stable --snapshot-dev --install --dontask --fixpermissions --smdir=\"\"]" 6 | echo "" 7 | echo -e "${cyan}Options:$reset" 8 | echo -e "--snapshot-stable Updates or installs the latest Sourcemod STABLE snapshot." 9 | echo -e "--snapshot-dev Updates or installs the latest Sourcemod DEV snapshot." 10 | echo -e "--install Installs sourcemod instead of updating." 11 | echo -e "--dontask Never ask for anything during execution." 12 | echo -e "--fixpermissions Fix file permissions afterwards." 13 | echo -e "--smdir="" Sets an alternative name for the addons/sourcemod directory." 14 | echo "" 15 | echo -e "${cyan}Examples:$reset" 16 | echo -e "$0 /game/css/cstrike" 17 | echo -e "$0 /srcds/css/cstrike --install --fixpermissions # Install sourcemod and fix the file permissions afterwards" 18 | echo -e "$0 /srcds/css/cstrike --snapshot-stable # Update sourcemod to the latest STABLE snapshot" 19 | echo -e "$0 /srcds/css/cstrike --snapshot-dev # Update sourcemod to the latest DEV snapshot" 20 | echo -e "$0 /srcds/css/cstrike --dontask # Never ask for anything" 21 | 22 | exit 1 23 | } 24 | -------------------------------------------------------------------------------- /functions/read_options.func: -------------------------------------------------------------------------------- 1 | function read_options 2 | { 3 | for argument in "$@" 4 | do 5 | # if it starts with --, 6 | # then it's an option 7 | if [[ $argument == --* ]]; then 8 | option=${argument:2} 9 | 10 | if [[ $option == *=* ]]; then 11 | option_name=${option%=*} 12 | option_value=${option#*=} 13 | 14 | options["$option_name"]=$option_value; 15 | else 16 | options["$option"]=1; 17 | fi 18 | fi 19 | done 20 | 21 | export options 22 | } 23 | -------------------------------------------------------------------------------- /functions/update.func: -------------------------------------------------------------------------------- 1 | function update 2 | { 3 | # Ceate a temporary directory 4 | temp=$(mktemp -d) 5 | tar xzf "packagecache/$filename" -C "$temp" 6 | 7 | sourcemod_dirname="sourcemod" 8 | 9 | if [[ ${options[smdir]} ]]; then 10 | sourcemod_dirname="${options[smdir]}" 11 | fi 12 | 13 | if [[ ! -f "$directory_game/steam.inf" ]]; then 14 | echo -e "${red}Error: ${cyan}steam.inf$red missing in '${yellow}$directory_game$red', are you sure this is the right directory?$reset" 15 | return 0 16 | fi 17 | 18 | if [[ ${options[install]} != "1" && ! -d "$directory_game/addons/$sourcemod_dirname" ]]; then 19 | echo -e "${red}Error: directory '${yellow}addons/$sourcemod_dirname$red' not found, ${cyan}try with --install$reset." 20 | return 0 21 | fi 22 | 23 | # Validate sourcemod package files 24 | if [[ ! -d "$temp/addons/sourcemod" ]]; then 25 | echo -e "${red}Error: Sourcemod package corrupt or not compatible, '${yellow}addons/sourcemod$red' doesn't exist." 26 | return 0 27 | fi 28 | 29 | if [[ ${options[install]} == "1" ]]; then 30 | echo -e "${cyan}Installing Sourcemod now...$reset" 31 | 32 | # If an other sourcemod directory name has been 33 | # specified, rename it from the stock name. 34 | if [[ $sourcemod_dirname != "sourcemod" ]]; then 35 | mv "$temp/addons/sourcemod" "$temp/addons/$sourcemod_dirname" 36 | fi 37 | 38 | cp -R "$temp/"* "$directory_game" 39 | 40 | echo -e "$green[SUCCESS] Sourcemod installed into '${yellow}$directory_game/addons/$sourcemod_dirname$green'.$reset" 41 | else 42 | echo -e "${cyan}Updating Sourcemod now...$reset" 43 | 44 | # Update Sourcemod 45 | 46 | # bin - rm, mv 47 | # configs - rm geoip, sql-init-scripts; mv 48 | # data - don't touch 49 | # extensions - overwrite 50 | # gamedata - rm core.games, sdktools.games, sm-*.txt; overwrite 51 | # logs - don't touch 52 | # plugins - replace & update in / and disabled/, new plugins -> disabled/ 53 | # scripting - overwrite 54 | # translations - overwrite 55 | 56 | directory_source="$temp/addons/sourcemod" 57 | directory_target="$directory_game/addons/$sourcemod_dirname" 58 | attributes="--checksum" 59 | 60 | echo -e "${cyan}Updating bin/$reset" 61 | rsync --recursive --delete-during $attributes --out-format="%o %n" "$directory_source/bin/" "$directory_target/bin/" 62 | 63 | echo -e "${cyan}Updating configs/$reset" 64 | rsync --recursive --delete-during $attributes --out-format="%o %n" "$directory_source/configs/geoip/" "$directory_target/configs/geoip/" 65 | rsync --recursive --delete-during $attributes --out-format="%o %n" "$directory_source/configs/sql-init-scripts/" "$directory_target/configs/sql-init-scripts/" 66 | 67 | echo -e "${cyan}Updating extensions/$reset" 68 | rsync --recursive $attributes --out-format="%o %n" "$directory_source/extensions/" "$directory_target/extensions/" 69 | 70 | echo -e "${cyan}Updating gamedata/$reset" 71 | rsync $attributes --out-format="%o %n" "$directory_source/gamedata/"* "$directory_target/gamedata/" | grep -v "skipping directory " 72 | rsync --recursive --delete-during $attributes --out-format="%o %n" "$directory_source/gamedata/sdktools.games/" "$directory_target/gamedata/sdktools.games/" 73 | rsync --recursive --delete-during $attributes --out-format="%o %n" "$directory_source/gamedata/core.games/" "$directory_target/gamedata/core.games/" 74 | rsync --recursive --delete-during $attributes --out-format="%o %n" "$directory_source/gamedata/sm-cstrike.games/" "$directory_target/gamedata/sm-cstrike.games/" 75 | 76 | echo -e "${cyan}Updating plugins/$reset" 77 | for f in $(find "$directory_source/plugins/" -name '*.smx'); do 78 | plugin=$(basename "$f") 79 | 80 | # If the plugin exists in plugins/, then copy it there 81 | if [[ -f "$directory_target/plugins/$plugin" ]]; then 82 | rsync $attributes --out-format="%o %n" "$f" "$directory_target/plugins/$plugin" 83 | else 84 | # otherwise copy it to plugins/disabled/ 85 | rsync $attributes --out-format="%o %n" "$f" "$directory_target/plugins/disabled/$plugin" 86 | fi 87 | done 88 | 89 | echo -e "${cyan}Updating scripting/$reset" 90 | rsync --recursive $attributes --out-format="%o %n" "$directory_source/scripting/" "$directory_target/scripting/" 91 | 92 | echo -e "${cyan}Updating translations/$reset" 93 | rsync --recursive $attributes --out-format="%o %n" "$directory_source/translations/" "$directory_target/translations/" 94 | 95 | echo -e "${cyan}Updating *.txt's$reset" 96 | rsync $attributes --out-format="%o %n" "$directory_source/"* "$directory_target/" | grep -v "skipping directory " 97 | 98 | echo -e "$green[SUCCESS] Sourcemod updated.$reset" 99 | fi 100 | 101 | if [[ ${options[fixpermissions]} == "1" ]]; then 102 | owner_group=`stat --format="%u:%g" "$directory_game"` 103 | echo -en "${cyan}Fixing permissions using $owner_group from game directory...$reset" 104 | 105 | chown -R $owner_group "$directory_game/addons/$sourcemod_dirname" 106 | chown -R $owner_group "$directory_game/addons/metamod/sourcemod.vdf" 107 | chown -R $owner_group "$directory_game/cfg/sourcemod" 108 | 109 | echo -e "${cyan}done$reset" 110 | fi 111 | 112 | return 1 113 | } 114 | -------------------------------------------------------------------------------- /packagecache/.gitempty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bcserv/sourcemod-updater/0698e678aae2f4f23300586d2d99c7d1a6c28206/packagecache/.gitempty -------------------------------------------------------------------------------- /settings: -------------------------------------------------------------------------------- 1 | # The source code of this page will be searched for the latest sourcemod package 2 | # We assume that the last one is the latest 3 | SNAPSHOT_STABLE_MIRROR="http://www.sourcemod.net/smdrop/1.10/" 4 | SNAPSHOT_STABLE_SEARCHPATTER="http:.*sourcemod-.*-linux.*gz" 5 | 6 | SNAPSHOT_DEV_MIRROR="http://www.sourcemod.net/smdrop/1.11/" 7 | SNAPSHOT_DEV_SEARCHPATTER="http:.*sourcemod-.*-linux.*gz" 8 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Usage: ./update /path/cstrike/ --snapshot-dev --snapshot-stable --install --dontask --fixpermissions 4 | 5 | # change to the script's directory 6 | cd $(dirname "$(readlink -f "$0")") 7 | 8 | # load all functions 9 | for f in $(find functions/ -name '*.func'); do 10 | . "$f" 11 | done 12 | 13 | define_colors 14 | 15 | echo -e "$header Bcserv Sourcemod updater $reset" 16 | echo "" 17 | 18 | # declare associative array for the options, as bash can't 19 | # serialize this into the ENV, it is defined here. 20 | declare -A options 21 | # read the options in 22 | read_options $* 23 | 24 | # load settings 25 | . "settings" 26 | 27 | directory_game="$1" 28 | 29 | if [[ $2 != "" && ${2:0:2} != "--" ]]; then 30 | url_sourcemod_package="$2" 31 | fi 32 | 33 | if [[ ${options[help]} == "1" || $directory_game == "" ]]; then 34 | help 35 | exit 0 36 | fi 37 | 38 | download 39 | 40 | if [[ $? == 1 ]]; then 41 | 42 | if [[ ${options[dontask]} != "1" ]]; then 43 | echo -e "${cyan}I will do the update now, press any key to continue${reset}, $red'CTRL + C' to exit$reset" 44 | echo "" 45 | stty -echo 46 | read -n 1 47 | stty echo 48 | fi 49 | 50 | update 51 | 52 | if [[ $? == 0 ]]; then 53 | echo -e "${red}Error found, aborting." 54 | fi 55 | 56 | # Cleanup 57 | rm -R "$temp" 58 | fi 59 | --------------------------------------------------------------------------------