added no-clobber option

added no-clobber option

preventing overwriting of already existing configs

#!/bin/bash
# LGSM install_config.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
# Description: Creates default server configs.

local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"

# Checks if server cfg dir exists, creates it if it doesn't
fn_check_cfgdir(){
	if [ ! -d "${servercfgdir}" ]; then
		echo "creating ${servercfgdir} config directory."
		fn_script_log_info "creating ${servercfgdir} config directory."
		mkdir -pv "${servercfgdir}"
	fi
}

# Downloads default configs from Game-Server-Configs repo to lgsm/default-configs
fn_fetch_default_config(){
	mkdir -pv "${lgsmdir}/default-configs"
	githuburl="https://github.com/GameServerManagers/Game-Server-Configs/master"
	for config in "${array_configs[@]}"; do
		fileurl="https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/master/${gamedirname}/${config}"; filedir="${lgsmdir}/default-configs"; filename="${config}";  executecmd="noexecute" run="norun"; force="noforce"
		fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
	done
}

# Copys default configs from Game-Server-Configs repo to server config location
fn_default_config_remote(){
	for config in "${array_configs[@]}"; do
		# every config is copied
		echo "copying ${config} config file."
		fn_script_log_info "copying ${servercfg} config file."
		if [ "${config}" == "${servercfgdefault}" ]; then
			cp -nv "${lgsmdir}/default-configs/${config}" "${servercfgfullpath}"
		elif [ "${gamename}" == "ARMA 3" ]&&[ "${config}" == "${networkcfgdefault}" ]; then
			cp -nv "${lgsmdir}/default-configs/${config}" "${networkcfgfullpath}"
		elif [ "${gamename}" == "Don't Starve Together" ]&&[ "${config}" == "${clustercfgdefault}" ]; then
			cp -nv "${lgsmdir}/default-configs/${clustercfgdefault}" "${clustercfgfullpath}"
		else
			cp -nv "${lgsmdir}/default-configs/${config}" "${servercfgdir}/${config}"
		fi
	done
	sleep 1
}

# Changes some variables within the default configs
# SERVERNAME to LinuxGSM
# PASSWORD to random password
fn_set_config_vars(){
	if [ -f "${servercfgfullpath}" ]; then
		random=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 8 | tr -d '\n'; echo)
		servername="LinuxGSM"
		rconpass="admin$random"
		echo "changing hostname."
		fn_script_log_info "changing hostname."
		sleep 1
		sed -i "s/SERVERNAME/${servername}/g" "${servercfgfullpath}"
		echo "changing rcon/admin password."
		fn_script_log_info "changing rcon/admin password."
		sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgfullpath}"
		sleep 1
	else
		fn_script_log_warn "Config file not found, cannot alter it."
		echo "Config file not found, cannot alter it."
		sleep 1
	fi
}

# Changes some variables within the default Don't Starve Together configs
fn_set_dst_config_vars(){
	## cluster.ini
	if grep -Fq "SERVERNAME" "${clustercfgfullpath}"; then
		echo "changing server name."
		fn_script_log_info "changing server name."
		sed -i "s/SERVERNAME/LinuxGSM/g" "${clustercfgfullpath}"
		sleep 1
		echo "changing shard mode."
		fn_script_log_info "changing shard mode."
		sed -i "s/USESHARDING/${sharding}/g" "${clustercfgfullpath}"
		sleep 1
		echo "randomizing cluster key."
		fn_script_log_info "randomizing cluster key."
		randomkey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
		sed -i "s/CLUSTERKEY/${randomkey}/g" "${clustercfgfullpath}"
		sleep 1
	else
		echo "${clustercfg} is already configured."
		fn_script_log_info "${clustercfg} is already configured."
	fi

	## server.ini
	# removing unnecessary options (dependent on sharding & shard type)
	if [ "${sharding}" == "false" ]; then
		sed -i "s/ISMASTER//g" "${servercfgfullpath}"
		sed -i "/SHARDNAME/d" "${servercfgfullpath}"
	elif [ "${master}" == "true" ]; then
		sed -i "/SHARDNAME/d" "${servercfgfullpath}"
	fi

	echo "changing shard name."
	fn_script_log_info "changing shard name."
	sed -i "s/SHARDNAME/${shard}/g" "${servercfgfullpath}"
	sleep 1
	echo "changing master setting."
	fn_script_log_info "changing master setting."
	sed -i "s/ISMASTER/${master}/g" "${servercfgfullpath}"
	sleep 1

	## worldgenoverride.lua
	if [ "${cave}" == "true" ]; then
		echo "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
		fn_script_log_info "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
		echo 'return { override_enabled = true, preset = "DST_CAVE", }' > "${servercfgdir}/worldgenoverride.lua"
	fi
	sleep 1
	echo ""
}

echo ""
echo "Downloading ${gamename} Config"
echo "================================="
echo "default configs from https://github.com/GameServerManagers/Game-Server-Configs"
sleep 2
if [ "${gamename}" == "7 Days To Die" ]; then
	gamedirname="7DaysToDie"
	array_configs+=( serverconfig.xml )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "ARK: Survival Evolved" ]; then
	gamedirname="ARKSurvivalEvolved"
	fn_check_cfgdir
	array_configs+=( GameUserSettings.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "ARMA 3" ]; then
	gamedirname="Arma3"
	fn_check_cfgdir
	array_configs+=( server.cfg network.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Battlefield: 1942" ]; then
	gamedirname="Battlefield1942"
	array_configs+=( serversettings.con )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Blade Symphony" ]; then
	gamedirname="BladeSymphony"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "BrainBread 2" ]; then
	gamedirname="BrainBread2"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Black Mesa: Deathmatch" ]; then
	gamedirname="BlackMesa"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Call of Duty" ]; then
	gamedirname="CallOfDuty"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Call of Duty: United Offensive" ]; then
	gamedirname="CallOfDutyUnitedOffensive"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Call of Duty 2" ]; then
	gamedirname="CallOfDuty2"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Call of Duty 4" ]; then
	gamedirname="CallOfDuty4"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Call of Duty: World at War" ]; then
	gamedirname="CallOfDutyWorldAtWar"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Codename CURE" ]; then
	gamedirname="CodenameCURE"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Counter-Strike 1.6" ]; then
	gamedirname="CounterStrike"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Counter-Strike: Condition Zero" ]; then
	gamedirname="CounterStrikeConditionZero"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Counter-Strike: Global Offensive" ]; then
	gamedirname="CounterStrikeGlobalOffensive"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Counter-Strike: Source" ]; then
	gamedirname="CounterStrikeSource"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Day of Defeat" ]; then
	gamedirname="DayOfDefeat"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Day of Defeat: Source" ]; then
	gamedirname="DayOfDefeatSource"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Day of Infamy" ]; then
	gamedirname="DayOfInfamy"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Deathmatch Classic" ]; then
	gamedirname="DeathmatchClassic"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Don't Starve Together" ]; then
	gamedirname="DontStarveTogether"
	fn_check_cfgdir
	array_configs+=( cluster.ini server.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_dst_config_vars
elif [ "${gamename}" == "Double Action: Boogaloo" ]; then
	gamedirname="DoubleActionBoogaloo"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Factorio" ]; then
	gamedirname="Factorio"
	array_configs+=( server-settings.json )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Fistful of Frags" ]; then
	gamedirname="FistfulofFrags"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Garry's Mod" ]; then
	gamedirname="GarrysMod"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "GoldenEye: Source" ]; then
	gamedirname="GoldenEyeSource"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Half Life: Deathmatch" ]; then
	gamedirname="HalfLifeDeathmatch"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Half-Life Deathmatch: Source" ]; then
	gamedirname="HalfLifeDeathmatchSource"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Half-Life: Opposing Force" ]; then
	gamedirname="OpposingForce"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Half Life 2: Deathmatch" ]; then
	gamedirname="HalfLife2Deathmatch"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Insurgency" ]; then
	gamedirname="Insurgency"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Just Cause 2" ]; then
	gamedirname="JustCause2"
	array_configs+=( config.lua )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Killing Floor" ]; then
	gamedirname="KillingFloor"
	array_configs+=( Default.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Left 4 Dead" ]; then
	gamedirname="Left4Dead"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Left 4 Dead" ]; then
	gamedirname="Left4Dead"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Left 4 Dead 2" ]; then
	gamedirname="Left4Dead2"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Minecraft" ]; then
	gamedirname="Minecraft"
	array_configs+=( server.properties )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "No More Room in Hell" ]; then
	gamedirname="NoMoreRoominHell"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Multi Theft Auto" ]; then
	gamedirname="MultiTheftAuto"
	fn_check_cfgdir
	array_configs+=( acl.xml mtaserver.conf vehiclecolors.conf )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Mumble" ]; then
	gamedirname="Mumble"
	array_configs+=( murmur.ini )
	fn_fetch_default_config
	fn_default_config_remote
elif [ "${gamename}" == "Natural Selection 2" ]; then
	:
elif [ "${gamename}" == "NS2: Combat" ]; then
	:
elif [ "${gamename}" == "Pirates, Vikings, and Knights II" ]; then
	gamedirname="PiratesVikingandKnightsII"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Project Zomboid" ]; then
	gamedirname="ProjectZomboid"
	fn_check_cfgdir
	array_configs+=( server.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Quake 2" ]; then
	gamedirname="Quake2"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Quake 3: Arena" ]; then
	gamedirname="Quake3Arena"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Quake Live" ]; then
	gamedirname="QuakeLive"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "QuakeWorld" ]; then
	gamedirname="QuakeWorld"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Red Orchestra: Ostfront 41-45" ]; then
	:
elif [ "${gamename}" == "Ricochet" ]; then
	gamedirname="Ricochet"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Rust" ]; then
	gamedirname="Rust"
	fn_check_cfgdir
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
elif [ "${gamename}" == "Serious Sam 3: BFE" ]; then
	gamedirname="SeriousSam3BFE"
	array_configs+=( server.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Starbound" ]; then
	gamedirname="Starbound"
	array_configs+=( starbound_server.config )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Sven Co-op" ]; then
	gamedirname="SvenCoop"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Team Fortress 2" ]; then
	gamedirname="TeamFortress2"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Team Fortress Classic" ]; then
	gamedirname="TeamFortressClassic"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "TeamSpeak 3" ]; then
	gamedirname="TeamSpeak3"
	array_configs+=( ts3server.ini )
	fn_fetch_default_config
	fn_default_config_remote
elif [ "${gamename}" == "Teeworlds" ]; then
	gamedirname="Teeworlds"
	array_configs+=( server.cfg ctf.cfg dm.cfg duel.cfg tdm.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Terraria" ]; then
	gamedirname="Terraria"
	array_configs+=( serverconfig.txt )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Unreal Tournament" ]; then
	gamedirname="UnrealTournament"
	array_configs+=( Game.ini Engine.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Unreal Tournament 2004" ]; then
	gamedirname="UnrealTournament2004"
	array_configs+=( UT2004.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Unreal Tournament 3" ]; then
	gamedirname="UnrealTournament3"
	array_configs+=( UTGame.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Unreal Tournament 99" ]; then
	gamedirname="UnrealTournament99"
	array_configs+=( Default.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then
	gamedirname="WolfensteinEnemyTerritory"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
fi

#!/bin/bash
# LGSM install_config.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
# Description: Creates default server configs.

local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"

# Checks if server cfg dir exists, creates it if it doesn't
fn_check_cfgdir(){
	if [ ! -d "${servercfgdir}" ]; then
		echo "creating ${servercfgdir} config directory."
		fn_script_log_info "creating ${servercfgdir} config directory."
		mkdir -pv "${servercfgdir}"
	fi
}

# Downloads default configs from Game-Server-Configs repo to lgsm/default-configs
fn_fetch_default_config(){
	mkdir -pv "${lgsmdir}/default-configs"
	githuburl="https://github.com/GameServerManagers/Game-Server-Configs/master"
	for config in "${array_configs[@]}"; do
		fileurl="https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/master/${gamedirname}/${config}"; filedir="${lgsmdir}/default-configs"; filename="${config}";  executecmd="noexecute" run="norun"; force="noforce"
		fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
	done
}

# Copys default configs from Game-Server-Configs repo to server config location
fn_default_config_remote(){
	for config in "${array_configs[@]}"; do
		# every config is copied
		echo "copying ${config} config file."
		fn_script_log_info "copying ${servercfg} config file."
		if [ "${config}" == "${servercfgdefault}" ]; then
			cp -v "${lgsmdir}/default-configs/${config}" "${servercfgfullpath}"
		elif [ "${gamename}" == "ARMA 3" ]&&[ "${config}" == "${networkcfgdefault}" ]; then
			cp -v "${lgsmdir}/default-configs/${config}" "${networkcfgfullpath}"
		elif [ "${gamename}" == "Don't Starve Together" ]&&[ "${config}" == "${clustercfgdefault}" ]; then
			cp -nv "${lgsmdir}/default-configs/${clustercfgdefault}" "${clustercfgfullpath}"
		else
			cp -v "${lgsmdir}/default-configs/${config}" "${servercfgdir}/${config}"
		fi
	done
	sleep 1
}

# Changes some variables within the default configs
# SERVERNAME to LinuxGSM
# PASSWORD to random password
fn_set_config_vars(){
	if [ -f "${servercfgfullpath}" ]; then
		random=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 8 | tr -d '\n'; echo)
		servername="LinuxGSM"
		rconpass="admin$random"
		echo "changing hostname."
		fn_script_log_info "changing hostname."
		sleep 1
		sed -i "s/SERVERNAME/${servername}/g" "${servercfgfullpath}"
		echo "changing rcon/admin password."
		fn_script_log_info "changing rcon/admin password."
		sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgfullpath}"
		sleep 1
	else
		fn_script_log_warn "Config file not found, cannot alter it."
		echo "Config file not found, cannot alter it."
		sleep 1
	fi
}

# Changes some variables within the default Don't Starve Together configs
fn_set_dst_config_vars(){
	## cluster.ini
	if grep -Fq "SERVERNAME" "${clustercfgfullpath}"; then
		echo "changing server name."
		fn_script_log_info "changing server name."
		sed -i "s/SERVERNAME/LinuxGSM/g" "${clustercfgfullpath}"
		sleep 1
		echo "changing shard mode."
		fn_script_log_info "changing shard mode."
		sed -i "s/USESHARDING/${sharding}/g" "${clustercfgfullpath}"
		sleep 1
		echo "randomizing cluster key."
		fn_script_log_info "randomizing cluster key."
		randomkey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
		sed -i "s/CLUSTERKEY/${randomkey}/g" "${clustercfgfullpath}"
		sleep 1
	else
		echo "${clustercfg} is already configured."
		fn_script_log_info "${clustercfg} is already configured."
	fi

	## server.ini
	# removing unnecessary options (dependent on sharding & shard type)
	if [ "${sharding}" == "false" ]; then
		sed -i "s/ISMASTER//g" "${servercfgfullpath}"
		sed -i "/SHARDNAME/d" "${servercfgfullpath}"
	elif [ "${master}" == "true" ]; then
		sed -i "/SHARDNAME/d" "${servercfgfullpath}"
	fi

	echo "changing shard name."
	fn_script_log_info "changing shard name."
	sed -i "s/SHARDNAME/${shard}/g" "${servercfgfullpath}"
	sleep 1
	echo "changing master setting."
	fn_script_log_info "changing master setting."
	sed -i "s/ISMASTER/${master}/g" "${servercfgfullpath}"
	sleep 1

	## worldgenoverride.lua
	if [ "${cave}" == "true" ]; then
		echo "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
		fn_script_log_info "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
		echo 'return { override_enabled = true, preset = "DST_CAVE", }' > "${servercfgdir}/worldgenoverride.lua"
	fi
	sleep 1
	echo ""
}

echo ""
echo "Downloading ${gamename} Config"
echo "================================="
echo "default configs from https://github.com/GameServerManagers/Game-Server-Configs"
sleep 2
if [ "${gamename}" == "7 Days To Die" ]; then
	gamedirname="7DaysToDie"
	array_configs+=( serverconfig.xml )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "ARK: Survival Evolved" ]; then
	gamedirname="ARKSurvivalEvolved"
	fn_check_cfgdir
	array_configs+=( GameUserSettings.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "ARMA 3" ]; then
	gamedirname="Arma3"
	fn_check_cfgdir
	array_configs+=( server.cfg network.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Battlefield: 1942" ]; then
	gamedirname="Battlefield1942"
	array_configs+=( serversettings.con )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Blade Symphony" ]; then
	gamedirname="BladeSymphony"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "BrainBread 2" ]; then
	gamedirname="BrainBread2"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Black Mesa: Deathmatch" ]; then
	gamedirname="BlackMesa"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Call of Duty" ]; then
	gamedirname="CallOfDuty"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Call of Duty: United Offensive" ]; then
	gamedirname="CallOfDutyUnitedOffensive"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Call of Duty 2" ]; then
	gamedirname="CallOfDuty2"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Call of Duty 4" ]; then
	gamedirname="CallOfDuty4"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Call of Duty: World at War" ]; then
	gamedirname="CallOfDutyWorldAtWar"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Codename CURE" ]; then
	gamedirname="CodenameCURE"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Counter-Strike 1.6" ]; then
	gamedirname="CounterStrike"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Counter-Strike: Condition Zero" ]; then
	gamedirname="CounterStrikeConditionZero"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Counter-Strike: Global Offensive" ]; then
	gamedirname="CounterStrikeGlobalOffensive"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Counter-Strike: Source" ]; then
	gamedirname="CounterStrikeSource"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Day of Defeat" ]; then
	gamedirname="DayOfDefeat"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Day of Defeat: Source" ]; then
	gamedirname="DayOfDefeatSource"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Day of Infamy" ]; then
	gamedirname="DayOfInfamy"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Deathmatch Classic" ]; then
	gamedirname="DeathmatchClassic"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Don't Starve Together" ]; then
	gamedirname="DontStarveTogether"
	fn_check_cfgdir
	array_configs+=( cluster.ini server.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_dst_config_vars
elif [ "${gamename}" == "Double Action: Boogaloo" ]; then
	gamedirname="DoubleActionBoogaloo"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Factorio" ]; then
	gamedirname="Factorio"
	array_configs+=( server-settings.json )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Fistful of Frags" ]; then
	gamedirname="FistfulofFrags"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Garry's Mod" ]; then
	gamedirname="GarrysMod"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "GoldenEye: Source" ]; then
	gamedirname="GoldenEyeSource"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Half Life: Deathmatch" ]; then
	gamedirname="HalfLifeDeathmatch"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Half-Life Deathmatch: Source" ]; then
	gamedirname="HalfLifeDeathmatchSource"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Half-Life: Opposing Force" ]; then
	gamedirname="OpposingForce"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Half Life 2: Deathmatch" ]; then
	gamedirname="HalfLife2Deathmatch"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Insurgency" ]; then
	gamedirname="Insurgency"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Just Cause 2" ]; then
	gamedirname="JustCause2"
	array_configs+=( config.lua )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Killing Floor" ]; then
	gamedirname="KillingFloor"
	array_configs+=( Default.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Left 4 Dead" ]; then
	gamedirname="Left4Dead"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Left 4 Dead" ]; then
	gamedirname="Left4Dead"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Left 4 Dead 2" ]; then
	gamedirname="Left4Dead2"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Minecraft" ]; then
	gamedirname="Minecraft"
	array_configs+=( server.properties )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "No More Room in Hell" ]; then
	gamedirname="NoMoreRoominHell"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Mumble" ]; then
	gamedirname="Mumble"
	array_configs+=( murmur.ini )
	fn_fetch_default_config
	fn_default_config_remote
elif [ "${gamename}" == "Natural Selection 2" ]; then
	:
elif [ "${gamename}" == "NS2: Combat" ]; then
	:
elif [ "${gamename}" == "Pirates, Vikings, and Knights II" ]; then
	gamedirname="PiratesVikingandKnightsII"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Project Zomboid" ]; then
	gamedirname="ProjectZomboid"
	fn_check_cfgdir
	array_configs+=( server.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Quake 2" ]; then
	gamedirname="Quake2"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Quake 3: Arena" ]; then
	gamedirname="Quake3Arena"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Quake Live" ]; then
	gamedirname="QuakeLive"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "QuakeWorld" ]; then
	gamedirname="QuakeWorld"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Red Orchestra: Ostfront 41-45" ]; then
	:
elif [ "${gamename}" == "Ricochet" ]; then
	gamedirname="Ricochet"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Rust" ]; then
	gamedirname="Rust"
	fn_check_cfgdir
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
elif [ "${gamename}" == "Serious Sam 3: BFE" ]; then
	gamedirname="SeriousSam3BFE"
	array_configs+=( server.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Starbound" ]; then
	gamedirname="Starbound"
	array_configs+=( starbound_server.config )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Sven Co-op" ]; then
	gamedirname="SvenCoop"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Team Fortress 2" ]; then
	gamedirname="TeamFortress2"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Team Fortress Classic" ]; then
	gamedirname="TeamFortressClassic"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "TeamSpeak 3" ]; then
	gamedirname="TeamSpeak3"
	array_configs+=( ts3server.ini )
	fn_fetch_default_config
	fn_default_config_remote
elif [ "${gamename}" == "Teeworlds" ]; then
	gamedirname="Teeworlds"
	array_configs+=( server.cfg ctf.cfg dm.cfg duel.cfg tdm.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Terraria" ]; then
	gamedirname="Terraria"
	array_configs+=( serverconfig.txt )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Unreal Tournament" ]; then
	gamedirname="UnrealTournament"
	array_configs+=( Game.ini Engine.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Unreal Tournament 2004" ]; then
	gamedirname="UnrealTournament2004"
	array_configs+=( UT2004.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Unreal Tournament 3" ]; then
	gamedirname="UnrealTournament3"
	array_configs+=( UTGame.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Unreal Tournament 99" ]; then
	gamedirname="UnrealTournament99"
	array_configs+=( Default.ini )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then
	gamedirname="WolfensteinEnemyTerritory"
	array_configs+=( server.cfg )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
elif [ "${gamename}" == "Multi Theft Auto" ]; then
	gamedirname="MultiTheftAuto"
	fn_check_cfgdir
	array_configs+=( acl.xml mtaserver.conf vehiclecolors.conf )
	fn_fetch_default_config
	fn_default_config_remote
	fn_set_config_vars
fi


export-image: don't round up if already a multiple of 4MB

Fixes #156

#!/bin/bash -e

IMG_FILE="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}.img"

unmount_image ${IMG_FILE}

rm -f ${IMG_FILE}

rm -rf ${ROOTFS_DIR}
mkdir -p ${ROOTFS_DIR}

BOOT_SIZE=$(du --apparent-size -s ${EXPORT_ROOTFS_DIR}/boot --block-size=1 | cut -f 1)
TOTAL_SIZE=$(du --apparent-size -s ${EXPORT_ROOTFS_DIR} --exclude var/cache/apt/archives --block-size=1 | cut -f 1)

ROUND_SIZE="$((4 * 1024 * 1024))"
ROUNDED_ROOT_SECTOR=$(((2 * BOOT_SIZE + ROUND_SIZE) / ROUND_SIZE * ROUND_SIZE / 512 + 8192))
IMG_SIZE=$(((BOOT_SIZE + TOTAL_SIZE + (800 * 1024 * 1024) + ROUND_SIZE - 1) / ROUND_SIZE * ROUND_SIZE))

truncate -s ${IMG_SIZE} ${IMG_FILE}
fdisk -H 255 -S 63 ${IMG_FILE} <<EOF
o
n

8192
+$((BOOT_SIZE * 2 /512))
p
t
c
n

${ROUNDED_ROOT_SECTOR}

p
w
EOF

PARTED_OUT=$(parted -s ${IMG_FILE} unit b print)
BOOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^ 1'| xargs echo -n \
| cut -d" " -f 2 | tr -d B)
BOOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^ 1'| xargs echo -n \
| cut -d" " -f 4 | tr -d B)

ROOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^ 2'| xargs echo -n \
| cut -d" " -f 2 | tr -d B)
ROOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^ 2'| xargs echo -n \
| cut -d" " -f 4 | tr -d B)

BOOT_DEV=$(losetup --show -f -o ${BOOT_OFFSET} --sizelimit ${BOOT_LENGTH} ${IMG_FILE})
ROOT_DEV=$(losetup --show -f -o ${ROOT_OFFSET} --sizelimit ${ROOT_LENGTH} ${IMG_FILE})
echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH"
echo "/:     offset $ROOT_OFFSET, length $ROOT_LENGTH"

ROOT_FEATURES="^huge_file"
for FEATURE in metadata_csum 64bit; do
	if grep -q "$FEATURE" /etc/mke2fs.conf; then
	    ROOT_FEATURES="^$FEATURE,$ROOT_FEATURES"
	fi
done
mkdosfs -n boot -F 32 -v $BOOT_DEV > /dev/null
mkfs.ext4 -L rootfs -O $ROOT_FEATURES $ROOT_DEV > /dev/null

mount -v $ROOT_DEV ${ROOTFS_DIR} -t ext4
mkdir -p ${ROOTFS_DIR}/boot
mount -v $BOOT_DEV ${ROOTFS_DIR}/boot -t vfat

rsync -aHAXx --exclude var/cache/apt/archives ${EXPORT_ROOTFS_DIR}/ ${ROOTFS_DIR}/

#!/bin/bash -e

IMG_FILE="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}.img"

unmount_image ${IMG_FILE}

rm -f ${IMG_FILE}

rm -rf ${ROOTFS_DIR}
mkdir -p ${ROOTFS_DIR}

BOOT_SIZE=$(du --apparent-size -s ${EXPORT_ROOTFS_DIR}/boot --block-size=1 | cut -f 1)
TOTAL_SIZE=$(du --apparent-size -s ${EXPORT_ROOTFS_DIR} --exclude var/cache/apt/archives --block-size=1 | cut -f 1)

ROUND_SIZE="$((4 * 1024 * 1024))"
ROUNDED_ROOT_SECTOR=$(((2 * BOOT_SIZE + ROUND_SIZE) / ROUND_SIZE * ROUND_SIZE / 512 + 8192))
IMG_SIZE=$(((BOOT_SIZE + TOTAL_SIZE + (800 * 1024 * 1024) + ROUND_SIZE) / ROUND_SIZE * ROUND_SIZE))

truncate -s ${IMG_SIZE} ${IMG_FILE}
fdisk -H 255 -S 63 ${IMG_FILE} <<EOF
o
n

8192
+$((BOOT_SIZE * 2 /512))
p
t
c
n

${ROUNDED_ROOT_SECTOR}

p
w
EOF

PARTED_OUT=$(parted -s ${IMG_FILE} unit b print)
BOOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^ 1'| xargs echo -n \
| cut -d" " -f 2 | tr -d B)
BOOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^ 1'| xargs echo -n \
| cut -d" " -f 4 | tr -d B)

ROOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^ 2'| xargs echo -n \
| cut -d" " -f 2 | tr -d B)
ROOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^ 2'| xargs echo -n \
| cut -d" " -f 4 | tr -d B)

BOOT_DEV=$(losetup --show -f -o ${BOOT_OFFSET} --sizelimit ${BOOT_LENGTH} ${IMG_FILE})
ROOT_DEV=$(losetup --show -f -o ${ROOT_OFFSET} --sizelimit ${ROOT_LENGTH} ${IMG_FILE})
echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH"
echo "/:     offset $ROOT_OFFSET, length $ROOT_LENGTH"

ROOT_FEATURES="^huge_file"
for FEATURE in metadata_csum 64bit; do
	if grep -q "$FEATURE" /etc/mke2fs.conf; then
	    ROOT_FEATURES="^$FEATURE,$ROOT_FEATURES"
	fi
done
mkdosfs -n boot -F 32 -v $BOOT_DEV > /dev/null
mkfs.ext4 -L rootfs -O $ROOT_FEATURES $ROOT_DEV > /dev/null

mount -v $ROOT_DEV ${ROOTFS_DIR} -t ext4
mkdir -p ${ROOTFS_DIR}/boot
mount -v $BOOT_DEV ${ROOTFS_DIR}/boot -t vfat

rsync -aHAXx --exclude var/cache/apt/archives ${EXPORT_ROOTFS_DIR}/ ${ROOTFS_DIR}/


add prepare toolchain

add prepare toolchain

#!/bin/bash
set -e

PWD="`pwd`"
CWD=$(cd "$(dirname "$0")"; pwd)

source ${CWD}/fns.sh
TOOLCHAIN="${CWD}/toolchain/arm-2010.09"
export PATH=${TOOLCHAIN}/bin:$PATH

#arm-none-linux-gnueabi-gcc -print-search-dirs

crossCompilePCRE(){
    cd ${CWD}/lib/PCRE/
    # checkout the initial version
    git checkout 4a79e0108ca0c574533c5b66dd3b9188704275ea
    CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar CXX=arm-none-linux-gnueabi-g++ ./configure --host=arm-linux --target=arm-linux --prefix=${TOOLCHAIN}/arm-none-linux-gnueabi/libc/usr --cache-file=/dev/null
    make
    make install
    # checkout latest version
    git checkout PCRE-8.32 -f
    git clean -df
    cd $PWD
}

crossCompileNcurses(){
    cd ${CWD}/lib/ncurses
    # checkout the initial version
    git checkout 5c8c4639c74c95041d7e57bf97a38e40d62aa9f6
    CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar CXX=arm-none-linux-gnueabi-g++ ./configure --host=arm-linux --target=arm-linux --prefix=${TOOLCHAIN}/arm-none-linux-gnueabi/libc/usr --cache-file=/dev/null
    make
    make install
    # checkout latest version
    git checkout ncurses-5.9 -f
    git clean -df
    cd $PWD
}

crossCompileAPR(){
    cd ${CWD}/lib/APR
    git checkout ecb4ce0eb7d8d6b3ff31dd2c35efb0ed71133034
    CC=arm-none-linux-gnueabi-gcc \
    AR=arm-none-linux-gnueabi-ar \
    CXX=arm-none-linux-gnueabi-g++ \
    ./configure \
--prefix=${TOOLCHAIN}/arm-none-linux-gnueabi/apr \
--host=arm-linux-gnueabi \
--target=arm-linux \
--cache-file=/dev/null
    make
    #git checkout APR-1.4.6 -f
    #git clean -df
    #cd $PWD
}
crossCompileAPR
exit
# DO NOT call this function, the toolchain is already prepared
# if you clone this repo from github, just for history purpose
prepareToolchain(){
    crossCompilePCRE
    crossCompileNcurses
}

error: pathspec 'prepareToolchain.sh' did not match any file(s) known to git


minor changes

minor changes

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/gorcajo/GuilleScripts.git/'


[FEATURE] Initial version of parser of raw results.

#!/bin/bash
#$results = ls | grep result\.txt
for result in c*result.txt
do
 cat $result | grep -e '^HTTP/1.1,4' > $result._errors.txt
 cat $result | grep -e '^HTTP/1.1,5' >> $result._errors.txt
 cat $result | grep -e '^HTTP/1.1,3' > $result._redirects.txt
 cat $result | grep -e '^HTTP/1.1,200' | cut -d, -f 3,5,7 > $result._normal.txt
done

error: pathspec 'parseresults.sh' did not match any file(s) known to git


Automatically generated pdf profiling results

rm -rf perf/results
mkdir perf/results

CPUPROFILE_REALTIME=1 CPUPROFILE_FREQUENCY=1000 bundle exec ruby perf/profile.rb

for f in perf/results/*.profile
do
  echo "Creating pdf for $f..."
  pprof.rb --pdf $f > "$f.pdf"
done


Script determines the PAN SSH proxy timeout

#!/usr/bin/env bash -x

# ssh command:
# - port 2222 is the CF ssh-proxy port
# - turn off password auth so it doesn't hang on password entry
# - turn off key checking so it doesn't hang waiting for key
SSH_CMD="ssh \
 -p 2222 \
 -o PasswordAuthentication=no \
 -o StrictHostKeyChecking=no \
 api.run.haas-104.pez.pivotal.io"

# Start with a ten-minute timeout
TIMEOUT_SECS=600

while :; do
 $($SSH_CMD)
 RC=$?
 if [ $RC -eq 255 ]; then
   # no proxying was attempted
   echo "Timeout: $TIMEOUT_SECS, proxying not attempted"
 elif [ $RC -ne 0 ]; then
   # proxying was attempted
   echo "Timeout: $TIMEOUT_SECS, proxying attempted"
   break
 else
   echo "Timeout: $TIMEOUT_SECS, shouldn't get here"
 fi
 TIMEOUT_SECS=$(( TIMEOUT_SECS + 120 ))
 echo "Upcoming timeout: $TIMEOUT_SECS"
 sleep $TIMEOUT_SECS
done

error: pathspec 'pan_timeout.sh' did not match any file(s) known to git


some updates and fixes

some updates and fixes

###############################################################################

pushd /etc/pacman.d

pacman -Syu --noconfirm --needed pacman-contrib

cp mirrorlist mirrorlist.bak
curl \
    "https://www.archlinux.org/mirrorlist/?country=$MIRROR_COUNTRY&protocol=http&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on"\
    > mirrorlist.$MIRROR_COUNTRY
sed -i 's/^#Server/Server/' mirrorlist.$MIRROR_COUNTRY
rankmirrors -n 10 mirrorlist.$MIRROR_COUNTRY > mirrorlist

popd

###############################################################################

error: pathspec 'modules/fast_mirror.sh' did not match any file(s) known to git


Search for the phpspec binary on more places

#!/bin/sh

function fixFormattingOnPhpSpecFiles ()
{
    echo -ne "Fixing SPEC files... \033[36mcleaning\033[0m"\\r

    IS_VISIBILITY_REQUIRED=`bin/php-cs-fixer help fix | grep visibility_required | wc -l`

    if [ $IS_VISIBILITY_REQUIRED -eq 0 ]; then
        VISIBILITY_FIXER='--fixers=-visibility'
    else
        VISIBILITY_FIXER='--rules=-visibility_required'
    fi

    bin/php-cs-fixer fix $VISIBILITY_FIXER spec --quiet

    if [ $? -eq 0 ]; then
        echo -e "Fixing SPEC files... \033[32mclean   \033[0m"
        return 0
    else
        echo -e "Fixing SPEC files... \033[33mfixed   \033[0m"
        return 1
    fi
}

function getLastEditedSpecFile ()
{
    environment=`uname -s`
    if [ "${environment}" = "Darwin" ]; then
        echo $(find spec -type f -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -1 | cut -f2- -d" ")
    else
        echo $(find spec -type f -printf '%T@ %p\n' | sort -rn | head -1 | cut -f2- -d" ")
    fi
}

function phpspecBinary ()
{
    if [ -e bin/phpspec ]; then
        bin/phpspec "$@"
    elif [ -e vendor/bin/phpspec ]; then
        vendor/bin/phpspec "$@"
    elif [ -e vendor/phpspec/phpspec/bin/phpspec ]; then
        vendor/phpspec/phpspec/bin/phpspec "$@"
    else
        echo -e "\033[31mPhpSpec binary not found!\033[0m"
    fi
}

FORMATTING_TOOLS+=('fixFormattingOnPhpSpecFiles')

if [ -n "$ENABLE_ALIAS" ] && [ "$ENABLE_ALIAS" = true ]; then
    alias psr="phpspecBinary run"

    function psl ()
    {
        lastEdited=$(getLastEditedSpecFile)
        echo -e "Running phpspec for: \033[36m${lastEdited}\033[0m"
        phpspecBinary run "${lastEdited}"
    }

    function psd ()
    {
        file="$1"
        len=`expr "$file" : 'src/'`
        if [ $len -gt 0 ]; then
            file="${file#src/}"
        else
            len=`expr "$file" : 'spec/'`
            if [ $len -gt 0 ]; then
                file="${file#spec/}"
            fi
        fi

        phpspecBinary desc "$file"
    }
fi

#!/bin/sh

function fixFormattingOnPhpSpecFiles ()
{
    echo -ne "Fixing SPEC files... \033[36mcleaning\033[0m"\\r

    IS_VISIBILITY_REQUIRED=`bin/php-cs-fixer help fix | grep visibility_required | wc -l`

    if [ $IS_VISIBILITY_REQUIRED -eq 0 ]; then
        VISIBILITY_FIXER='--fixers=-visibility'
    else
        VISIBILITY_FIXER='--rules=-visibility_required'
    fi

    bin/php-cs-fixer fix $VISIBILITY_FIXER spec --quiet

    if [ $? -eq 0 ]; then
        echo -e "Fixing SPEC files... \033[32mclean   \033[0m"
        return 0
    else
        echo -e "Fixing SPEC files... \033[33mfixed   \033[0m"
        return 1
    fi
}

function getLastEditedSpecFile ()
{
    environment=`uname -s`
    if [ "${environment}" = "Darwin" ]; then
        echo $(find spec -type f -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -1 | cut -f2- -d" ")
    else
        echo $(find spec -type f -printf '%T@ %p\n' | sort -rn | head -1 | cut -f2- -d" ")
    fi
}

FORMATTING_TOOLS+=('fixFormattingOnPhpSpecFiles')

if [ -n "$ENABLE_ALIAS" ] && [ "$ENABLE_ALIAS" = true ]; then
    alias psr="bin/phpspec run"

    function psl ()
    {
        lastEdited=$(getLastEditedSpecFile)
        echo -e "Running phpspec for: \033[36m${lastEdited}\033[0m"
        bin/phpspec run "${lastEdited}"
    }

    function psd ()
    {
        file="$1"
        len=`expr "$file" : 'src/'`
        if [ $len -gt 0 ]; then
            file="${file#src/}"
        else
            len=`expr "$file" : 'spec/'`
            if [ $len -gt 0 ]; then
                file="${file#spec/}"
            fi
        fi

        bin/phpspec desc "$file"
    }
fi


Issue PeaceGeeksSociety/content#810 Fix typo

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/pg-irc/pathways-frontend.git/'


a small dispatch  for install

a small dispatch  for install

#!/bin/sh

 # create  inskcope location conf and scripts

INKPATHETC='/opt/inkscope/etc'
INKPATHBIN='/opt/inkscope/bin'
mkdir -pv $INKPATHETC $INKPATHBIN

mv cephprobe.conf $INKPATHETC
mv cephprobe.py $INKPATHBIN
mv sysprobe.conf $INKPATHETC
mv sysprobe.py  $INKPATHBIN

error: pathspec 'inkscopeCollect/install.sh' did not match any file(s) known to git


Added patchBaseURL file

Added patchBaseURL file

#!/bin/bash
set -e

FILE=$1
BASEPATH=$2

echo "Patching base url..."
sed -i "s/{{baseUrl}}/$BASEPATH/" $FILE

error: pathspec 'build/patchBaseURL.sh' did not match any file(s) known to git


add conda build script

add conda build script

#!/bin/bash

REPO="$@"

CONDA=`which conda`

sudo $CONDA install conda-build
$CONDA skeleton pypi $REPO
$CONDA build $REPO

error: pathspec 'build_python_conda.sh' did not match any file(s) known to git


Add source fetching script

Add source fetching script

#!/bin/bash

set -e
tempDir=$(mktemp -d)
checkoutDir="$tempDir/neovim"
git clone --quiet https://github.com/neovim/neovim "$checkoutDir"
tar -C "$tempDir" -cjf neovim.tar.bz2 neovim

lastTag=$(cd "$checkoutDir"; git describe --abbrev=0 | sed 's/^v//')
headCommit=$(cd "$checkoutDir"; git rev-list HEAD -n 1 | cut -c 1-7)

echo "%global gitdate $(date +%Y%m%d)"
echo "%global gitversion ${lastTag}"
echo "%global gitcommit ${headCommit}"

rm -rf "$tempDir"

error: pathspec 'TakeGitSnapshot.sh' did not match any file(s) known to git


java heap check for jvms

java heap check for jvms

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/estately/sensu-community-plugins.git/'


basic command line xcode functionality

basic command line xcode functionality

#xc function courtesy of http://gist.github.com/subdigital/5420709
function xc {
  xcode_proj=`find . -name "*.xc*" -d 1 | sort -r | head -1`
  if [[ `echo -n $xcode_proj | wc -m` == 0 ]]
  then
    echo "No xcworkspace/xcodeproj file found in the current directory."
  else
    echo "Found $xcode_proj"
    open "$xcode_proj"
  fi
}

function xcsel {
  sudo xcode-select --switch "$*"
}

alias xcb='xcodebuild'
alias xcp='xcode-select --print-path'

error: pathspec 'plugins/xcode/xcode.plugin.zsh' did not match any file(s) known to git


Load average trigger

Load average trigger

#!/bin/bash

SERVERNAME='your server'
EMAILS='me@home.net myself@work.com'

# This is a simple script to detect issues early
# It is not an IDS by any measure, but should help catch performance problems.

L_TRIGGER=90
CPU_COUNT=$(cat /proc/cpuinfo | grep "model name" | wc -l)

OVERALL_LOAD=$(python -c 'import sys; m=float(sys.argv[1]); n=float(sys.argv[2]); print int(100*(n+m)/('$CPU_COUNT'*2))' $(uptime | sed -r -e 's/^.+load average: //' -e 's/, / /g' | cut -d ' ' -f 2,1))

#echo CPU "$OVERALL_LOAD (max $L_TRIGGER)"

# ===========================================================================================
CPU_LOAD=$(echo $(uptime | sed -r -e 's/^.+load average: //' -e 's/, / /g' | cut -d ' ' -f 1)"/1" | bc)
if [[ $CPU_LOAD -gt $CPU_COUNT ]] && [[ $OVERALL_LOAD -gt $L_TRIGGER ]]; then
mail -s "Warning - high Load average on $SERVERNAME" $EMAILS <<EOMAIL

High Load average detected ($CPU_COUNT cores)

High load average occurs when processes are waiting for the CPU. This could be a CPU-intensive task, or
when the disk is busy (typically writing/reading lots)

The load average report consists of 3 numbers, the load for the last minute, 5 minutes, and 15 minutes.

Your max ideal CPU load threshold is $CPU_COUNT
A load average above this number, consistent for all three slots, needs attention.

$(uptime)

==================

Memory stats: (MB)

$(free -m)

=================

CONFIDENTIAL

Top set of CPU-using processes

$(top -b -n 1 | head -n 20)

$(ps aux | grep -E $(echo $(top -b -n 1 | head -n 30 | grep -E '^ *[0-9]' | cut -d ' ' -f 1) | sed -r -e 's/ /|/g' -e 's/^/^/' -e 's/$/$/'))

EOMAIL
fi

error: pathspec 'bin/load-trigger.sh' did not match any file(s) known to git


add set-versions.sh

add set-versions.sh

#!/usr/bin/env bash

#/ Version change helper.
#/
#/ This shell script will traverse all subprojects and change their
#/ versions to the one provided as argument.
#/
#/
#/ Arguments
#/ =========
#/
#/ <Version>
#/
#/   Base version number to set. When '--release' is used, this version will
#/   be used as-is; otherwise, a nightly/snapshot indicator will be appended.
#/
#/   <Version> should be in a format compatible with Semantic Versioning,
#/   such as "1.2.3" or, in general terms, "<Major>.<Minor>.<Patch>".
#/
#/ --release
#/
#/   Use version numbers intended for Release builds, such as "1.2.3". If this
#/   option is not given, a nightly/snapshot indicator is appended: "-SNAPSHOT".
#/
#/   Optional. Default: Disabled.
#/
#/ --git-add
#/
#/   Add changes to the Git stage area. Useful to leave everything ready for a
#/   commit.
#/
#/   Optional. Default: Disabled.

# Shell setup
# ===========

# Bash options for strict error checking.
set -o errexit -o errtrace -o pipefail -o nounset

# Check dependencies.
command -v mvn >/dev/null || {
    echo "ERROR: Dependency 'mvn' is not installed; please install it"
    exit 1
}

# Trace all commands.
set -o xtrace

# Parse call arguments
# ====================

CFG_VERSION=""
CFG_RELEASE="false"
CFG_GIT_ADD="false"

while [[ $# -gt 0 ]]; do
    case "${1-}" in
        --release)
            CFG_RELEASE="true"
            ;;
        --git-add)
            CFG_GIT_ADD="true"
            ;;
        *)
            CFG_VERSION="$1"
            ;;
    esac
    shift
done

# Config restrictions
# ===================

if [[ -z "$CFG_VERSION" ]]; then
    echo "ERROR: Missing <Version>"
    exit 1
fi

REGEX='^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'
[[ "$CFG_VERSION" =~ $REGEX ]] || {
    echo "ERROR: '$CFG_VERSION' must be compatible with Semantic Versioning: <Major>.<Minor>.<Patch>"
    exit 1
}

echo "CFG_VERSION=$CFG_VERSION"
echo "CFG_RELEASE=$CFG_RELEASE"
echo "CFG_GIT_ADD=$CFG_GIT_ADD"

# Internal variables
# ==================

if [[ "$CFG_RELEASE" == "true" ]]; then
    VERSION="$CFG_VERSION"
else
    VERSION="${CFG_VERSION}-SNAPSHOT"
fi

# Helper functions
# ================

# Add the given file(s) to the Git stage area.
function git_add() {
    [[ $# -ge 1 ]] || {
        echo "ERROR [git_add]: Missing argument(s): <file1> [<file2> ...]"
        return 1
    }

    if [[ "$CFG_GIT_ADD" == "true" ]]; then
        git add -- "$@"
    fi
}

# Apply version
# =============

# Update project version.
mvn versions:set \
    -DgenerateBackupPoms=false \
    -DnewVersion="$VERSION"

git_add \
    '*pom.xml'

echo "Done!"

error: pathspec 'bin/set-versions.sh' did not match any file(s) known to git


[libcxx] cleanup

[libcxx] cleanup

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/gnzlbg/unix_env.git/'


Added dumping IPS tables from MDS and CMA for global policy debugs Moved tderror_all_all to the command itself and no longer using export Not running mgmt debugs with fwm -d as the tderror handles it Fixed some vmalloc commands not being run Fixed slow policy install not working on R80.x

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/seiruss/policy-debug.git/'


Link to official doc

Link to official doc

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/petermbenjamin/dotfiles.git/'


initial commit

initial commit

#!/bin/bash

#define (and create) a main directory in which all packages will be downloaded and installed
maindir=$HOME/pathos_test

#define the python interpreter/version to be used
py=/usr/local/bin/python2.7

#the download repository
repository=dev.danse.us/packages

#create the directory into which the python packages are going to be installed and add it to the PYTHONPATH variable
mkdir -p $maindir/local/lib/python2.7/site-packages
export PYTHONPATH=$maindir/local/lib/python2.7/site-packages:$PYTHONPATH

#download the pathos package
wget $repository/pathos-0.2a.dev-20130811.zip -P $maindir

#unpack the pathos package
unzip $maindir/pathos* -d $maindir

#download some extra dependencies
wget $repository/dill-0.2.4.zip -P $maindir/pathos*/external
wget $repository/pox-0.2.2.zip -P $maindir/pathos*/external

#unpack all the dependencies
for archive in $maindir/pathos*/external/*.zip; do
	unzip $archive -d $maindir/pathos*/external;
done

#install the dependency packages
for dir in $maindir/pathos*/external/*/; do
	cd $dir;
	$py setup.py build;
	$py setup.py install --prefix=$maindir/local
done

#alternative installation using pip (was found to cause errors)
#$py /usr/local/bin/pip2.7 install --install-option="--prefix=${maindir}/local" dill pox
#$py /usr/local/bin/pip2.7 install --user --upgrade --install-option="--prefix${maindir}/local" dill pox

#install pathos
cd $maindir/pathos*
$py setup.py build
$py setup.py install --prefix=$maindir/local

#clean up
rm -rf $maindir/pathos*

echo please add the following line to your .bashrc:
echo "export PYTHONPATH=${maindir}/local/lib/python2.7/site-packages:$"PYTHONPATH
echo done

error: pathspec 'install/install_pathos.sh' did not match any file(s) known to git


Meteor App

Meteor App

MONGO_URL=mongodb://localhost:27017/meteor meteor --port 3000

error: pathspec 'meteor/pubsub/start.sh' did not match any file(s) known to git


Create after-install-ubuntu-14-04-trusty-tahr.sh

#!/bin/bash

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
#sudo apt-get install calibre -y
sudo apt-get install ubuntu-restricted-extras
sudo apt-get install vlc
sudo apt-get install rar
sudo apt-get install gimp
sudo apt-get install gnome-tweak-tool
sudo apt-get install unity-tweak-tool
sudo sh -c 'echo "deb http://archive.canonical.com/ quantal partner" >> /etc/apt/sources.list'
sudo apt-get update
sudo apt-get install skype
sudo apt-get install icedtea–7-plugin openjdk–7-jre
sudo apt-get install diodon diodon-plugins
sudo add-apt-repository ppa:atareao/atareao
sudo apt-get update
sudo apt-get install calendar-indicator
#sudo apt-get install dropbox
#sudo apt-get install libappindicator1
sudo add-apt-repository ppa:diesch/testing
sudo apt-get update
sudo apt-get install classicmenu-indicator
sudo apt-get install indicator-multiload
gsettings set com.canonical.Unity.Lenses disabled-scopes "['more_suggestions-amazon.scope', 'more_suggestions-u1ms.scope', 'more_suggestions-populartracks.scope', 'music-musicstore.scope', 'more_suggestions-ebay.scope', 'more_suggestions-ubuntushop.scope', 'more_suggestions-skimlinks.scope']"
sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update
sudo apt-get install tlp tlp-rdw
sudo tlp start
sudo apt-get install dolphin -y
sudo apt-get install compizconfig-settings-manager
sudo apt-get install flashplugin-installer
sudo /usr/share/doc/libdvdread4/install-css.sh
echo "Downloading GetDeb and PlayDeb" &&
wget http://archive.getdeb.net/install_deb/getdeb-repository_0.1-1~getdeb1_all.deb http://archive.getdeb.net/install_deb/playdeb_0.3-1~getdeb1_all.deb &&

echo "Installing GetDeb" &&
sudo dpkg -i getdeb-repository_0.1-1~getdeb1_all.deb &&

echo "Installing PlayDeb" &&
sudo dpkg -i playdeb_0.3-1~getdeb1_all.deb &&

echo "Deleting Downloads" &&
rm -f getdeb-repository_0.1-1~getdeb1_all.deb &&
rm -f playdeb_0.3-1~getdeb1_all.deb
sudo add-apt-repository -y ppa:gnome3-team/gnome3
sudo add-apt-repository -y ppa:webupd8team/y-ppa-manager
echo 'deb http://download.videolan.org/pub/debian/stable/ /' | sudo tee -a /etc/apt/sources.list.d/libdvdcss.list &&
echo 'deb-src http://download.videolan.org/pub/debian/stable/ /' | sudo tee -a /etc/apt/sources.list.d/libdvdcss.list &&
wget -O - http://download.videolan.org/pub/debian/videolan-apt.asc|sudo apt-key add -
sudo apt-get install synaptic vlc gimp gimp-data gimp-plugin-registry gimp-data-extras y-ppa-manager bleachbit openjdk-7-jre oracle-java8-installer flashplugin-installer unace unrar zip unzip p7zip-full p7zip-rar sharutils rar uudeview mpack arj cabextract file-roller libxine1-ffmpeg mencoder flac faac faad sox ffmpeg2theora libmpeg2-4 uudeview libmpeg3-1 mpeg3-utils mpegdemux liba52-dev mpeg2dec vorbis-tools id3v2 mpg321 mpg123 libflac++6 totem-mozilla icedax lame libmad0 libjpeg-progs libdvdcss2 libdvdread4 libdvdnav4 libswscale-extra-2 ubuntu-restricted-extras ubuntu-wallpapers*
echo "Cleaning Up" &&
sudo apt-get -f install &&
sudo apt-get autoremove &&
sudo apt-get -y autoclean &&
sudo apt-get -y clean
sudo apt-get update

error: pathspec 'after-install-ubuntu-14-04-trusty-tahr.sh' did not match any file(s) known to git


Added a script to install the Nvidia GDK on a host.

This script can be used to install the Nvidia GPU Deployment Kit (GDK)
on a mesos development machine. The purpose of the GDK is to provide
stubs for compiling code against Nvidia's latest drivers.  It includes
all the necessary header files (nvml.h) and library files
(libnvidia-ml.so) necessary to build mesos with Nvidia GPU support.
However, it does not actually contain any driver code, and it can't be
used to interact with any GPUs installed on a system. For that, you
will have to find the latest released drivers themselves.

We provide this script only for convenience, so that developers
working on non-GPU equipped systems can build code with Nvidia GPU
support. It is a simple wrapper around the official GDK installer
script provided by Nvidia, which can be downloaded here:

  https://developer.nvidia.com/gpu-deployment-kit

The script itself takes a few parameters. Run it as
'support/install-nvidia-gdk.sh --help' to see its usage semantics.

Review: https://reviews.apache.org/r/44360/

#!/usr/bin/env bash

#  This script can be used to install the Nvidia GPU Deployment Kit
#  (GDK) on a Mesos development machine. The purpose of the GDK is to
#  provide stubs for compiling code against Nvidia's latest drivers. It
#  includes all the necessary header files (nvml.h) and library files
#  (libnvidia-ml.so) necessary to build Mesos with Nvidia GPU support.
#  However, it does not actually contain any driver code, and it can't
#  be used to interact with any GPUs installed on a system. For that,
#  you will have to find the latest released drivers themselves.
#
#  We provide this script only for convenience, so that developers
#  working on non-GPU equipped systems can build code with Nvidia GPU
#  support. It is a simple wrapper around the official GDK installer
#  script provided by Nvidia, which can be downloaded here:
#
#    https://developer.nvidia.com/gpu-deployment-kit
#
#  The script itself takes a few parameters. Run it as
#  'support/install-nvidia-gdk.sh --help' to see its usage semantics.
#
#  Unfortunately, the official GDK installer script does not provide a
#  means of uninstalling very easily. Because of this, we *highly*
#  encourage installing the GDK into a self-contained directory (e.g.
#  '/opt/nvidia-gdk'), so that uninstalling is as easy as removing that
#  single directory. If you chose to update the ldcache by passing the
#  --update-ldcache flag at installation time, you will also have to
#  remove the ${NVIDIA_GDK_CONF_FILE} file, and rerun 'sudo
#  ldconfig' to fully uninstall the GDK.

# The default install path of the Nvidia GDK.
NVIDIA_GDK_INSTALL_PATH="/opt/nvidia-gdk"

# Default value for deciding whether to run ldconfig after the installation or not.
UPDATE_LDCACHE="false"

# The location of the nvidia-gdk specific ld.so.conf file when running
# ldconfig after the installation. Its parent directory of
# /etc/ld.so.conf.d is standard across ubuntu, centos, and debian.
NVIDIA_GDK_CONF_FILE="/etc/ld.so.conf.d/nvidia-gdk.conf"

# The URL to the gdk installer.
NVIDIA_GDK_INSTALLER_URL="http://developer.download.nvidia.com/compute/cuda/7.5/Prod/gdk/gdk_linux_amd64_352_79_release.run"

# The checksum of the gdk installer.
NVIDIA_GDK_INSTALLER_SUM="3fa9d17cd57119d82d4088e5cfbfcad960f12e3384e3e1a7566aeb2441e54ce4"

# Define the scripts usage semantics.
usage()
{
cat << EOF
Usage:
  $(basename ${0}) (-h | --help)
  $(basename ${0}) [ --install-dir=<path> --update-ldcache ]

Options:
  -h --help         Show this screen.
  --install-dir     The location to install the Nvidia GDK.
                    [default: ${NVIDIA_GDK_INSTALL_PATH}]
  --update-ldcache  Install a custom ld.so.conf script and run
                    ldconfig to update the ldcache after installation.
                    The 'sudo' command is used to invoke this.
                    [default: false]

Description:
  This script can be used to install the Nvidia GPU Deployment Kit
  (GDK) on a Mesos development machine. The purpose of the GDK is to
  provide stubs for compiling code against Nvidia's latest drivers. It
  includes all the necessary header files (nvml.h) and library files
  (libnvidia-ml.so) necessary to build Mesos with Nvidia GPU support.
  However, it does not actually contain any driver code, and it can't
  be used to interact with any GPUs installed on a system. For that,
  you will have to find the latest released drivers themselves.

  Unfortunately, the official GDK installer script does not provide a
  means of uninstalling very easily. Because of this, we *highly*
  encourage installing the GDK into a self-contained directory (e.g.
  '/opt/nvidia-gdk'), so that uninstalling is as easy as removing that
  single directory. If you chose to update the ldcache by passing the
  --update-ldcache flag at installation time, you will also have to
  remove the '${NVIDIA_GDK_CONF_FILE}' file and rerun 'sudo
  ldconfig' to fully uninstall the GDK.
EOF
}

# Parse any incoming arguments.
for i in "${@}"; do
  case ${i} in
    -h|--help)
        usage
        exit 0
      ;;
    --install-dir=*)
        NVIDIA_GDK_INSTALL_PATH="${i#*=}"
        shift
      ;;
    --update-ldcache)
        UPDATE_LDCACHE="true"
        shift
      ;;
    *)
        echo "Unknown option: ${i}"
        echo ""
        usage
        exit 1
      ;;
  esac
done

# Before we do anything, verify that we are running on Linux.
if [ "$(uname)" != "Linux" ]; then
  echo "Error: The Nvidia GDK is only supported on Linux."
  exit 1;
fi

# Now verify that the install-dir specified actually exists and that
# we have access to it. If it doesn't exist, attempt to create it.
if [ ! -d "${NVIDIA_GDK_INSTALL_PATH}" ]; then
  mkdir -p "${NVIDIA_GDK_INSTALL_PATH}"
fi
if [ ! -d "${NVIDIA_GDK_INSTALL_PATH}" ] ||
   [ ! -w "${NVIDIA_GDK_INSTALL_PATH}" ]; then
  echo "Error: Inaccessible path: ${NVIDIA_GDK_INSTALL_PATH}"
  echo "       The installation directory is either inaccessable or"
  echo "       cannot be created because you do not have the proper"
  echo "       permissions to access it. Please select a different"
  echo "       location, or rerun this command as a user with the"
  echo "       proper permissions, e.g. using 'sudo'."
  exit 1;
fi

# Create a place for storing temporary files and make sure this
# directory gets deleted whenever this script exits.
NVIDIA_TEMP_DIR=$(mktemp -d)
trap "rm -rf ${NVIDIA_TEMP_DIR}" EXIT

# Download and run the Nvidia GDK installer.
# Verify the installer via it's checksum after download.
NVIDIA_GDK_INSTALLER_FILE="${NVIDIA_TEMP_DIR}/gdk"

wget -O ${NVIDIA_GDK_INSTALLER_FILE} -q ${NVIDIA_GDK_INSTALLER_URL}
RESULT="${?}"

if [ ${RESULT} != "0" ]; then
  echo "Failed to download the installer!"
  echo "Error running wget, please check your internet connection:"
  echo "  \$ wget ${NVIDIA_GDK_INSTALLER_URL}"
  exit ${RESULT}
fi

echo "${NVIDIA_GDK_INSTALLER_SUM}  ${NVIDIA_GDK_INSTALLER_FILE}" \
    | sha256sum -c --strict -
RESULT="${?}"

if [ ${RESULT} != "0" ]; then
  echo "Failed verifying the checksum of the downloaded Nvidia GDK installer!"
  echo "Please report this error to dev@mesos.apache.org."
  exit ${RESULT}
fi

# Remove a symbolic link so that running this script is idempotent.
# Without removing this symbolic link, the GDK installer script errors
# out with the line:
#   'ln: failed to create symbolic link <path_to_file>: File exists'
# Since we know the next thing we will do is run the installer,
# manually removing this file should be harmless.
rm -rf ${NVIDIA_GDK_INSTALL_PATH}/usr/bin/nvvs

# Run the installer.
# We pass the '--silent' flag here to make the GDK installer happy.
# Without it, it errors out with the line:
#  'The installer must be run in silent mode to use command-line options.'
chmod +x "${NVIDIA_GDK_INSTALLER_FILE}"
${NVIDIA_GDK_INSTALLER_FILE} --installdir="${NVIDIA_GDK_INSTALL_PATH}" --silent

# Optionally update the ld cache with the Nvidia GDK library path.
if [ "${UPDATE_LDCACHE}" = "true" ]; then
  sudo bash -c "cat > ${NVIDIA_GDK_CONF_FILE} << EOF
# nvidia-gdk default configuration
${NVIDIA_GDK_INSTALL_PATH}/usr/src/gdk/nvml/lib/
EOF"

  sudo ldconfig
  echo "Wrote '${NVIDIA_GDK_CONF_FILE}' and ran ldconfig"
fi

error: pathspec 'support/install-nvidia-gdk.sh' did not match any file(s) known to git


DOC: new script to test if c3d is installed and bash_profile configured. Extend it to other dependences.

Former-commit-id: d603e06377cf5076675f6f3cfa21767eb38d4754 [formerly 8fbadc75348d8c0695d504a2d1a56daefc9da58e]
Former-commit-id: 5c956ddf31bbca7539af71b7f4dbd2bb5db8ca90
Former-commit-id: f9a0a6ee9127aad957c1ad96f129eb607f7db9c3

#!/bin/bash
#
# Check .bash_profile for all dependences and modify it if necessary.
#

# And here we have Bash Patterns:
echo -n "Checking if c3d is installed...                   "
C3D=`find / -name "c3d" -type f -print -quit 2>/dev/null`
if [[ "$C3D" == *c3d ]]
then
    echo '[OK]'
else
    echo '[WARNING]: c3d is NOT installed. Please install it from there: http://www.itksnap.org/'
	exit
fi

echo -n "Checking if c3d is declared in .bash_profile...   "
PATHC3D=`which c3d`
if [[ $PATHC3D != '' ]]; then
  echo '[OK]'
else
  echo '[WARNING]: c3d not declared. Now modifying ~/.bash_profile...'
  echo "# C3D (added on $(date +%Y-%m-%d))" >> ~/.bash_profile
  echo "PATH=${PATH}:${C3D%????}" >> ~/.bash_profile
fi

echo "Done! Please restart your Terminal for changes to take effect."
echo

error: pathspec 'check_bash_profile.sh' did not match any file(s) known to git


added and implemented serverAlive.sh

added and implemented serverAlive.sh

#!/bin/bash
#URL of the server
SERVER_URL=$1

#Find the MAC adress
MAC_ADRESS=$(cat /sys/class/net/eth0/address)
#Find the CPU info
CPU=$(cat /proc/cpuinfo | grep model\ name | sort -u | cut -c 14-200)
#Find the VGA info
VGA=$(lspci | grep VGA | cut -c 36-200)

#Send data to server via POST
echo "Sending request to server..."
SERVER_ALIVE_STRING=$(curl -X POST -F "MAC=$MAC_ADRESS" -F "CPU=$CPU" -F "VGA=$VGA" $SERVER_URL -s > /dev/null)

if [ "$SERVER_ALIVE_STRING" = "true" ]
then
	echo "Request successfull. Server is alive."
else
	echo "Request failed, server might be offline."
fi

#echo $MAC_ADRESS
#echo $CPU
#echo $VGA

error: pathspec 'client/serverAlive.sh' did not match any file(s) known to git


commands: add provision

commands: add provision

#!/usr/bin/env bash

# Preps a docker machine for deployment,
# creating local folders and copying config files that will then be mounted.
# Beware: calling it on an existing machine will not erase user data BUT reset its config.
#
# With an argument, will only provision/reset the specified service/app

ensure DOM_NAME

# default to provisioning EVERYTHING
initial_list=$*
: ${initial_list:='+applications +services'}

setTargetList $initial_list
onlyAppsOrServices $target_list

for tgt in $target_list
do
  setAppTag $tgt
  if [ -e "./applications/$app/config/docker/provision.sh" ]; then
    echo "-- provisioning app $app"
    ./applications/$app/config/docker/provision.sh
  elif [ -e "./services/$app/provision.sh" ]; then
    echo "-- provisioning service $app"
    ./services/$app/provision.sh
  elif [ -e "./infra/$app/provision.sh" ]; then
    echo "-- provisioning infra $app"
    ./infra/$app/provision.sh
  else
    echo "-- no provisioning needed for $app, skipped"
  fi
done

error: pathspec 'commands/provision.sh' did not match any file(s) known to git


Script de instalación para Ruby on rails en Ubuntu 14.04

#!/bin/bash

# Script desarrollado por Francisco Sanchez
# Automatización para la instalacion de ruby on rails
# Ruby en la version: 2.2.3
# Rails en la version: 4.2.4
# Este script considera BASH, si utiliza ZSH debe modificar los parametros.

# Primero instalamos las dependencias de Ruby
echo -e "[+] Ejecutando update."
sudo apt-get update
echo -e "[+] Instalando dependencias."
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

# Sengundo, Instalamos "rbenv" y Ruby

# Install rbenv
echo -e "[+] Instalando rbenv y Ruby"

cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

# Install plugins
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

git clone https://github.com/rbenv/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash

# Instalando ruby
rbenv install 2.2.3
# Configurando global
rbenv global 2.2.3
# Verificando la version de ruby e instalación de Ruby
echo -e "Verificando la version e instalacion de Ruby"
ruby -v

# Tercero ejecutamos bundler
echo -e "[+] Ejecutando bundler"
gem install bundler

# Cuarto instalamos Rails
echo -e "Inicia instalacion de Rails"

echo -e "Instalando nodejs"
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

echo -e "Instalando rails en su version 4.2.4"
gem install rails -v 4.2.4

# Ejecutar luego de instalar un bin de Ruby o correr bundle en rbenv
rbenv rehash

echo -e "Verificando la version e instalacion de Rails"
rails -v

error: pathspec 'Instalacion_ruby_and_rails_ubuntu_14_04_LTS.sh' did not match any file(s) known to git


test/bench/shootout: remove dependency on C libraries in test mode
Fixes issue 3732.

R=golang-dev
CC=golang-dev
http://codereview.appspot.com/6335053

Committer: Russ Cox <5ad239cb8a44f659eaaee0aa1ea5b94947abe557@golang.org>

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/wesolows/golang-old.git/'


change docker iptables setting

change docker iptables setting

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/TOTVS/mdmpublic.git/'


Script to deploy JavaDocs

Script to deploy JavaDocs

#!/bin/bash

set -ex

REPO="git@github.com:segmentio/analytics-android.git"
GROUP_ID="com.segment.analytics.android"
ARTIFACT_ID="core"

DIR=temp-clone

# Delete any existing temporary website clone
rm -rf $DIR

# Clone the current repo into temp folder
git clone $REPO $DIR

# Move working directory into temp folder
cd $DIR

# Checkout and track the gh-pages branch
git checkout -t origin/gh-pages

# Delete everything
rm -rf *

# Download the latest javadoc
curl -L "http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=$GROUP_ID&a=$ARTIFACT_ID&v=LATEST&c=javadoc" > javadoc.zip
unzip javadoc.zip
rm javadoc.zip

# Stage all files in git and create a commit
git add .
git add -u
git commit -m "Website at $(date)"

# Push the new files up to GitHub
git push origin gh-pages

# Delete our temp folder
cd ..
rm -rf $DIR

error: pathspec 'deploy_javadocs.sh' did not match any file(s) known to git


Fix remote debugging configuration

Fix remote debugging configuration

Patch by blerer; reviewed by jmckenzie for CASSANDRA-9297

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

calculate_heap_sizes()
{
    case "`uname`" in
        Linux)
            system_memory_in_mb=`free -m | awk '/:/ {print $2;exit}'`
            system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo`
        ;;
        FreeBSD)
            system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'`
            system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
            system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
        ;;
        SunOS)
            system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'`
            system_cpu_cores=`psrinfo | wc -l`
        ;;
        Darwin)
            system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'`
            system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
            system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
        ;;
        *)
            # assume reasonable defaults for e.g. a modern desktop or
            # cheap server
            system_memory_in_mb="2048"
            system_cpu_cores="2"
        ;;
    esac

    # some systems like the raspberry pi don't report cores, use at least 1
    if [ "$system_cpu_cores" -lt "1" ]
    then
        system_cpu_cores="1"
    fi

    # set max heap size based on the following
    # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB))
    # calculate 1/2 ram and cap to 1024MB
    # calculate 1/4 ram and cap to 8192MB
    # pick the max
    half_system_memory_in_mb=`expr $system_memory_in_mb / 2`
    quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2`
    if [ "$half_system_memory_in_mb" -gt "1024" ]
    then
        half_system_memory_in_mb="1024"
    fi
    if [ "$quarter_system_memory_in_mb" -gt "8192" ]
    then
        quarter_system_memory_in_mb="8192"
    fi
    if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ]
    then
        max_heap_size_in_mb="$half_system_memory_in_mb"
    else
        max_heap_size_in_mb="$quarter_system_memory_in_mb"
    fi
    MAX_HEAP_SIZE="${max_heap_size_in_mb}M"

    # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size)
    max_sensible_yg_per_core_in_mb="100"
    max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores`

    desired_yg_in_mb=`expr $max_heap_size_in_mb / 4`

    if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ]
    then
        HEAP_NEWSIZE="${max_sensible_yg_in_mb}M"
    else
        HEAP_NEWSIZE="${desired_yg_in_mb}M"
    fi
}

# Determine the sort of JVM we'll be running on.

java_ver_output=`"${JAVA:-java}" -version 2>&1`

jvmver=`echo "$java_ver_output" | grep '[openjdk|java] version' | awk -F'"' 'NR==1 {print $2}'`
JVM_VERSION=${jvmver%_*}
JVM_PATCH_VERSION=${jvmver#*_}

if [ "$JVM_VERSION" \< "1.7" ] ; then
    echo "Cassandra 2.0 and later require Java 7 or later."
    exit 1;
fi

jvm=`echo "$java_ver_output" | grep -A 1 'java version' | awk 'NR==2 {print $1}'`
case "$jvm" in
    OpenJDK)
        JVM_VENDOR=OpenJDK
        # this will be "64-Bit" or "32-Bit"
        JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'`
        ;;
    "Java(TM)")
        JVM_VENDOR=Oracle
        # this will be "64-Bit" or "32-Bit"
        JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'`
        ;;
    *)
        # Help fill in other JVM values
        JVM_VENDOR=other
        JVM_ARCH=unknown
        ;;
esac

# Override these to set the amount of memory to allocate to the JVM at
# start-up. For production use you may wish to adjust this for your
# environment. MAX_HEAP_SIZE is the total amount of memory dedicated
# to the Java heap; HEAP_NEWSIZE refers to the size of the young
# generation. Both MAX_HEAP_SIZE and HEAP_NEWSIZE should be either set
# or not (if you set one, set the other).
#
# The main trade-off for the young generation is that the larger it
# is, the longer GC pause times will be. The shorter it is, the more
# expensive GC will be (usually).
#
# The example HEAP_NEWSIZE assumes a modern 8-core+ machine for decent pause
# times. If in doubt, and if you do not particularly want to tweak, go with
# 100 MB per physical CPU core.

#MAX_HEAP_SIZE="4G"
#HEAP_NEWSIZE="800M"

# Set this to control the amount of arenas per-thread in glibc
#export MALLOC_ARENA_MAX=4

if [ "x$MAX_HEAP_SIZE" = "x" ] && [ "x$HEAP_NEWSIZE" = "x" ]; then
    calculate_heap_sizes
else
    if [ "x$MAX_HEAP_SIZE" = "x" ] ||  [ "x$HEAP_NEWSIZE" = "x" ]; then
        echo "please set or unset MAX_HEAP_SIZE and HEAP_NEWSIZE in pairs (see cassandra-env.sh)"
        exit 1
    fi
fi

if [ "x$MALLOC_ARENA_MAX" = "x" ]
then
    export MALLOC_ARENA_MAX=4
fi

# Specifies the default port over which Cassandra will be available for
# JMX connections.
# For security reasons, you should not expose this port to the internet.  Firewall it if needed.
JMX_PORT="7199"

# Here we create the arguments that will get passed to the jvm when
# starting cassandra.

# enable assertions.  disabling this in production will give a modest
# performance benefit (around 5%).
JVM_OPTS="$JVM_OPTS -ea"

# add the jamm javaagent
JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"

# some JVMs will fill up their heap when accessed via JMX, see CASSANDRA-6541
JVM_OPTS="$JVM_OPTS -XX:+CMSClassUnloadingEnabled"

# enable thread priorities, primarily so we can give periodic tasks
# a lower priority to avoid interfering with client workload
JVM_OPTS="$JVM_OPTS -XX:+UseThreadPriorities"
# allows lowering thread priority without being root.  see
# http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workaround.html
JVM_OPTS="$JVM_OPTS -XX:ThreadPriorityPolicy=42"

# min and max heap sizes should be set to the same value to avoid
# stop-the-world GC pauses during resize, and so that we can lock the
# heap in memory on startup to prevent any of it from being swapped
# out.
JVM_OPTS="$JVM_OPTS -Xms${MAX_HEAP_SIZE}"
JVM_OPTS="$JVM_OPTS -Xmx${MAX_HEAP_SIZE}"
JVM_OPTS="$JVM_OPTS -Xmn${HEAP_NEWSIZE}"
JVM_OPTS="$JVM_OPTS -XX:+HeapDumpOnOutOfMemoryError"

# set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR
if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then
    JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof"
fi

startswith() { [ "${1#$2}" != "$1" ]; }

# Per-thread stack size.
JVM_OPTS="$JVM_OPTS -Xss256k"

# Larger interned string table, for gossip's benefit (CASSANDRA-6410)
JVM_OPTS="$JVM_OPTS -XX:StringTableSize=1000003"

# GC tuning options
JVM_OPTS="$JVM_OPTS -XX:+UseParNewGC"
JVM_OPTS="$JVM_OPTS -XX:+UseConcMarkSweepGC"
JVM_OPTS="$JVM_OPTS -XX:+CMSParallelRemarkEnabled"
JVM_OPTS="$JVM_OPTS -XX:SurvivorRatio=8"
JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=1"
JVM_OPTS="$JVM_OPTS -XX:CMSInitiatingOccupancyFraction=75"
JVM_OPTS="$JVM_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
JVM_OPTS="$JVM_OPTS -XX:+UseTLAB"

# note: bash evals '1.7.x' as > '1.7' so this is really a >= 1.7 jvm check
if { [ "$JVM_VERSION" \> "1.7" ] && [ "$JVM_VERSION" \< "1.8.0" ] && [ "$JVM_PATCH_VERSION" -ge "60" ]; } || [ "$JVM_VERSION" \> "1.8" ] ; then
    JVM_OPTS="$JVM_OPTS -XX:+CMSParallelInitialMarkEnabled -XX:+CMSEdenChunksRecordAlways"
fi

if [ "$JVM_ARCH" = "64-Bit" ] ; then
    JVM_OPTS="$JVM_OPTS -XX:+UseCondCardMark"
fi

# GC logging options -- uncomment to enable
# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"
# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDateStamps"
# JVM_OPTS="$JVM_OPTS -XX:+PrintHeapAtGC"
# JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution"
# JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"
# JVM_OPTS="$JVM_OPTS -XX:+PrintPromotionFailure"
# JVM_OPTS="$JVM_OPTS -XX:PrintFLSStatistics=1"
# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc-`date +%s`.log"
# If you are using JDK 6u34 7u2 or later you can enable GC log rotation
# don't stick the date in the log name if rotation is on.
# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc.log"
# JVM_OPTS="$JVM_OPTS -XX:+UseGCLogFileRotation"
# JVM_OPTS="$JVM_OPTS -XX:NumberOfGCLogFiles=10"
# JVM_OPTS="$JVM_OPTS -XX:GCLogFileSize=10M"

# Configure the following for JEMallocAllocator and if jemalloc is not available in the system
# library path (Example: /usr/local/lib/). Usually "make install" will do the right thing.
# export LD_LIBRARY_PATH=<JEMALLOC_HOME>/lib/
# JVM_OPTS="$JVM_OPTS -Djava.library.path=<JEMALLOC_HOME>/lib/"

# uncomment to have Cassandra JVM listen for remote debuggers/profilers on port 1414
# JVM_OPTS="$JVM_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1414"

# Prefer binding to IPv4 network intefaces (when net.ipv6.bindv6only=1). See
# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342561 (short version:
# comment out this entry to enable IPv6 support).
JVM_OPTS="$JVM_OPTS -Djava.net.preferIPv4Stack=true"

# jmx: metrics and administration interface
#
# add this if you're having trouble connecting:
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
#
# see
# https://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole
# for more on configuring JMX through firewalls, etc. (Short version:
# get it working with no firewall first.)
#
# Cassandra ships with JMX accessible  *only* from localhost.
# To enable remote JMX connections, change the setting below to enable JMX
# with authentication and/or ssl enabled. See https://wiki.apache.org/cassandra/JmxSecurity
#
LOCAL_JMX=yes

if [ "$LOCAL_JMX" = "yes" ]; then
  JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT -XX:+DisableExplicitGC"
else
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=true"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.password.file=/etc/cassandra/jmxremote.password"
fi

JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS"

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

calculate_heap_sizes()
{
    case "`uname`" in
        Linux)
            system_memory_in_mb=`free -m | awk '/:/ {print $2;exit}'`
            system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo`
        ;;
        FreeBSD)
            system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'`
            system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
            system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
        ;;
        SunOS)
            system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'`
            system_cpu_cores=`psrinfo | wc -l`
        ;;
        Darwin)
            system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'`
            system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
            system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
        ;;
        *)
            # assume reasonable defaults for e.g. a modern desktop or
            # cheap server
            system_memory_in_mb="2048"
            system_cpu_cores="2"
        ;;
    esac

    # some systems like the raspberry pi don't report cores, use at least 1
    if [ "$system_cpu_cores" -lt "1" ]
    then
        system_cpu_cores="1"
    fi

    # set max heap size based on the following
    # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB))
    # calculate 1/2 ram and cap to 1024MB
    # calculate 1/4 ram and cap to 8192MB
    # pick the max
    half_system_memory_in_mb=`expr $system_memory_in_mb / 2`
    quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2`
    if [ "$half_system_memory_in_mb" -gt "1024" ]
    then
        half_system_memory_in_mb="1024"
    fi
    if [ "$quarter_system_memory_in_mb" -gt "8192" ]
    then
        quarter_system_memory_in_mb="8192"
    fi
    if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ]
    then
        max_heap_size_in_mb="$half_system_memory_in_mb"
    else
        max_heap_size_in_mb="$quarter_system_memory_in_mb"
    fi
    MAX_HEAP_SIZE="${max_heap_size_in_mb}M"

    # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size)
    max_sensible_yg_per_core_in_mb="100"
    max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores`

    desired_yg_in_mb=`expr $max_heap_size_in_mb / 4`

    if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ]
    then
        HEAP_NEWSIZE="${max_sensible_yg_in_mb}M"
    else
        HEAP_NEWSIZE="${desired_yg_in_mb}M"
    fi
}

# Determine the sort of JVM we'll be running on.

java_ver_output=`"${JAVA:-java}" -version 2>&1`

jvmver=`echo "$java_ver_output" | grep '[openjdk|java] version' | awk -F'"' 'NR==1 {print $2}'`
JVM_VERSION=${jvmver%_*}
JVM_PATCH_VERSION=${jvmver#*_}

if [ "$JVM_VERSION" \< "1.7" ] ; then
    echo "Cassandra 2.0 and later require Java 7 or later."
    exit 1;
fi

jvm=`echo "$java_ver_output" | grep -A 1 'java version' | awk 'NR==2 {print $1}'`
case "$jvm" in
    OpenJDK)
        JVM_VENDOR=OpenJDK
        # this will be "64-Bit" or "32-Bit"
        JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'`
        ;;
    "Java(TM)")
        JVM_VENDOR=Oracle
        # this will be "64-Bit" or "32-Bit"
        JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'`
        ;;
    *)
        # Help fill in other JVM values
        JVM_VENDOR=other
        JVM_ARCH=unknown
        ;;
esac

# Override these to set the amount of memory to allocate to the JVM at
# start-up. For production use you may wish to adjust this for your
# environment. MAX_HEAP_SIZE is the total amount of memory dedicated
# to the Java heap; HEAP_NEWSIZE refers to the size of the young
# generation. Both MAX_HEAP_SIZE and HEAP_NEWSIZE should be either set
# or not (if you set one, set the other).
#
# The main trade-off for the young generation is that the larger it
# is, the longer GC pause times will be. The shorter it is, the more
# expensive GC will be (usually).
#
# The example HEAP_NEWSIZE assumes a modern 8-core+ machine for decent pause
# times. If in doubt, and if you do not particularly want to tweak, go with
# 100 MB per physical CPU core.

#MAX_HEAP_SIZE="4G"
#HEAP_NEWSIZE="800M"

# Set this to control the amount of arenas per-thread in glibc
#export MALLOC_ARENA_MAX=4

if [ "x$MAX_HEAP_SIZE" = "x" ] && [ "x$HEAP_NEWSIZE" = "x" ]; then
    calculate_heap_sizes
else
    if [ "x$MAX_HEAP_SIZE" = "x" ] ||  [ "x$HEAP_NEWSIZE" = "x" ]; then
        echo "please set or unset MAX_HEAP_SIZE and HEAP_NEWSIZE in pairs (see cassandra-env.sh)"
        exit 1
    fi
fi

if [ "x$MALLOC_ARENA_MAX" = "x" ]
then
    export MALLOC_ARENA_MAX=4
fi

# Specifies the default port over which Cassandra will be available for
# JMX connections.
# For security reasons, you should not expose this port to the internet.  Firewall it if needed.
JMX_PORT="7199"

# Here we create the arguments that will get passed to the jvm when
# starting cassandra.

# enable assertions.  disabling this in production will give a modest
# performance benefit (around 5%).
JVM_OPTS="$JVM_OPTS -ea"

# add the jamm javaagent
JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"

# some JVMs will fill up their heap when accessed via JMX, see CASSANDRA-6541
JVM_OPTS="$JVM_OPTS -XX:+CMSClassUnloadingEnabled"

# enable thread priorities, primarily so we can give periodic tasks
# a lower priority to avoid interfering with client workload
JVM_OPTS="$JVM_OPTS -XX:+UseThreadPriorities"
# allows lowering thread priority without being root.  see
# http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workaround.html
JVM_OPTS="$JVM_OPTS -XX:ThreadPriorityPolicy=42"

# min and max heap sizes should be set to the same value to avoid
# stop-the-world GC pauses during resize, and so that we can lock the
# heap in memory on startup to prevent any of it from being swapped
# out.
JVM_OPTS="$JVM_OPTS -Xms${MAX_HEAP_SIZE}"
JVM_OPTS="$JVM_OPTS -Xmx${MAX_HEAP_SIZE}"
JVM_OPTS="$JVM_OPTS -Xmn${HEAP_NEWSIZE}"
JVM_OPTS="$JVM_OPTS -XX:+HeapDumpOnOutOfMemoryError"

# set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR
if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then
    JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof"
fi

startswith() { [ "${1#$2}" != "$1" ]; }

# Per-thread stack size.
JVM_OPTS="$JVM_OPTS -Xss256k"

# Larger interned string table, for gossip's benefit (CASSANDRA-6410)
JVM_OPTS="$JVM_OPTS -XX:StringTableSize=1000003"

# GC tuning options
JVM_OPTS="$JVM_OPTS -XX:+UseParNewGC"
JVM_OPTS="$JVM_OPTS -XX:+UseConcMarkSweepGC"
JVM_OPTS="$JVM_OPTS -XX:+CMSParallelRemarkEnabled"
JVM_OPTS="$JVM_OPTS -XX:SurvivorRatio=8"
JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=1"
JVM_OPTS="$JVM_OPTS -XX:CMSInitiatingOccupancyFraction=75"
JVM_OPTS="$JVM_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
JVM_OPTS="$JVM_OPTS -XX:+UseTLAB"

# note: bash evals '1.7.x' as > '1.7' so this is really a >= 1.7 jvm check
if { [ "$JVM_VERSION" \> "1.7" ] && [ "$JVM_VERSION" \< "1.8.0" ] && [ "$JVM_PATCH_VERSION" -ge "60" ]; } || [ "$JVM_VERSION" \> "1.8" ] ; then
    JVM_OPTS="$JVM_OPTS -XX:+CMSParallelInitialMarkEnabled -XX:+CMSEdenChunksRecordAlways"
fi

if [ "$JVM_ARCH" = "64-Bit" ] ; then
    JVM_OPTS="$JVM_OPTS -XX:+UseCondCardMark"
fi

# GC logging options -- uncomment to enable
# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"
# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDateStamps"
# JVM_OPTS="$JVM_OPTS -XX:+PrintHeapAtGC"
# JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution"
# JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"
# JVM_OPTS="$JVM_OPTS -XX:+PrintPromotionFailure"
# JVM_OPTS="$JVM_OPTS -XX:PrintFLSStatistics=1"
# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc-`date +%s`.log"
# If you are using JDK 6u34 7u2 or later you can enable GC log rotation
# don't stick the date in the log name if rotation is on.
# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc.log"
# JVM_OPTS="$JVM_OPTS -XX:+UseGCLogFileRotation"
# JVM_OPTS="$JVM_OPTS -XX:NumberOfGCLogFiles=10"
# JVM_OPTS="$JVM_OPTS -XX:GCLogFileSize=10M"

# Configure the following for JEMallocAllocator and if jemalloc is not available in the system
# library path (Example: /usr/local/lib/). Usually "make install" will do the right thing.
# export LD_LIBRARY_PATH=<JEMALLOC_HOME>/lib/
# JVM_OPTS="$JVM_OPTS -Djava.library.path=<JEMALLOC_HOME>/lib/"

# uncomment to have Cassandra JVM listen for remote debuggers/profilers on port 1414
# JVM_OPTS="$JVM_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1414"

# Prefer binding to IPv4 network intefaces (when net.ipv6.bindv6only=1). See
# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342561 (short version:
# comment out this entry to enable IPv6 support).
JVM_OPTS="$JVM_OPTS -Djava.net.preferIPv4Stack=true"

# jmx: metrics and administration interface
#
# add this if you're having trouble connecting:
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
#
# see
# https://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole
# for more on configuring JMX through firewalls, etc. (Short version:
# get it working with no firewall first.)
#
# Cassandra ships with JMX accessible  *only* from localhost.
# To enable remote JMX connections, change the setting below to enable JMX
# with authentication and/or ssl enabled. See https://wiki.apache.org/cassandra/JmxSecurity
#
LOCAL_JMX=yes

if [ "$LOCAL_JMX" = "yes" ]; then
  JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT -XX:+DisableExplicitGC"
else
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=true"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.password.file=/etc/cassandra/jmxremote.password"
fi

JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS"


Add an element that just sets , this is needed now by the base element.

error: pathspec 'elements/fedora-distro/environment.d/00-fedora-distro.bash' did not match any file(s) known to git


Add simple script to build and install the application to a device

Signed-off-by: Simon Busch <e923d8431f09840b119134ca71ec8d74989d15cc@gravedo.de>

#!/bin/bash
node enyo/tools/deploy.js -o deploy/org.webosports.app.settings
adb push deploy/org.webosports.app.settings /usr/palm/applications/org.webosports.app.settings
adb push BUILD-armv7a-vfp-neon/plugin/WebosPortsSettingsAppPlugin.so /usr/palm/applications/org.webosports.app.settings/

error: pathspec 'build-and-deploy.sh' did not match any file(s) known to git