Steam Boiler / src / boiler.in

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
#!/bin/bash
# boiler - steam program wrapper
# Generated from boiler.in; do not edit by hand.
# Erik Southworth, 2008,2009,2010,2011,2012 (dvs)

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

NAME='@NAME@'
VERSION='@VERSION@'
BUGREPORT='@BUGREPORT@'
HOMEPAGE='@HOMEPAGE@'
RELEASE='@RELEASE@'
REVISION='@REVISION@'
PKGDATADIR='@PKGDATADIR@'

# [shopt]
#~ set -o errexit # Exit when simple command fails.
#~ set -o nounset # Trigger error when expanding unset variables.

# [colors]
if [ "$NOCOLOR" ] ; then
    NORMAL=""
    BOLD=""
    RED=""
    YELLOW=""
    GREEN=""
else
    NORMAL='\033[0m'
    BOLD='\033[01;1m'
    RED='\033[01;91m'
    YELLOW='\033[00;33m'
    GREEN='\033[01;92m'
fi

# [invoke path]
BINNAME="$0"
BINDIR=$(dirname "$BINNAME")
BIN=$(basename "$BINNAME")

# [real path]
FILENAME=$(readlink --canonicalize "$0")
FILEDIR=$(dirname "$FILENAME")
FILE=$(basename "$FILENAME")

# [current working dir]
CWD=$(pwd -P)

# [util]
: ${FIND="find"}
: ${GETOPT="getopt"}
: ${INSTALL="install"}
: ${INSTALL_DIR="${INSTALL} --directory"}
: ${INSTALL_DATA="${INSTALL} --mode=644"}
: ${INSTALL_PROGRAM="${INSTALL}"}
: ${IONICE="ionice -c 3"}
: ${REMOVE="rm"}
: ${REMOVE_EMPTY_DIR="rmdir"}
: ${SYMLINK="ln --symbolic --force --no-dereference"}
: ${UNPACK="tar -xvf"}

# [steam]
CONFDIR="$HOME"/Steam
OLDCONFDIR="$HOME"/.steam
HLDSUPDATETOOL=${PKGDATADIR}/hldsupdatetool
STEAMBIN=${CONFDIR}/steam

# [steamcmd]
STEAMCMD=${PKGDATADIR}/steamcmd.tar.gz
CONSOLEBIN=${CONFDIR}/steam.sh

usage()
{
cat << EOT
${usage_banner}

Main operation mode:
${usage_main}

Options:
${usage_options}

Example:
  ${BIN} update css /home/$USER/orange-box

  (Use --verbose to get a full option listing)
EOT
exit
}

usage_verbose()
{
cat << EOT
${usage_banner}

Main operation mode:
${usage_main}

Options:
${usage_options}
${usage_login}
${usage_other}

Mandatory or optional arguments to long options are also mandatory or
optional for any corresponding short options.

Report bugs to: <${BUGREPORT}>
${NAME} home page: <${HOMEPAGE}>
EOT
exit
}

betainfo()
{
cat << EOT
${usage_banner}

Betas:
  -g, --game=cstrike_beta	Counter-Strike 1.6 [19 Oct 2008]
  -g, --game=cssbeta	        Counter-Strike Source [11 May 2010]
  -b, --beta=hlbeta	        Half-Life 1 [9 July 2010]

  Betas come in two class types. One is total conversion and uses
  the --game option. Please note that you should install the total
  conversion beta game into a NEW directory, it will not co-exist with
  an existing server install. The other is an incremental update and
  uses the --beta option. Incremental beta updates can be applied to
  existing server installs.

Example:

  Installing the Counter-Strike: Source beta to a separate folder:

    ${BIN} update cssbeta /home/$USER/css-beta

  Updating an existing Counter-Strike 1.6 server with beta hlds engine:

    ${BIN} update cstrike /home/$USER/hlds --beta=hlbeta

EOT
exit
}

manual()
{
cat << EOT
NAME
  ${BIN} - steam program wrapper
SYNOPSIS
  ${BIN} < command > [ game ] [ dir ] [ options ]
DESCRIPTION
  The ${BIN} script is a wrapper for the steam program and as an alias
  for the the steam program, provides convenient extensions and gives
  users access to the steam program from a single, central installation.

  The ${BIN} program will install a copy of the steam program to the user
  configuation directory \$HOME/Steam, as required, then, execute and
  pass option arguments to the steam program.

  To enable automatic server updates; as when using the -autoupdate
  option of the hlds_run or srcds_run (run-script); ${BIN} will
  create the steam symbolic link, in the directory local to the
  run-script.
OPTIONS
  These are alternative extensions to steam(6):

${usage_main}
${usage_options}
${usage_login}
${usage_other}
EXAMPLE
  View listing of available games:

    $ steam list

  Install or update Counter-Strike Source located in user \$HOME/orange-box directory:

    $ steam update css ~/orange-box
FILES
  \$HOME/Steam/last-run-path  The last directory path that was processed.
AUTHOR
  Written by Erik Southworth
REPORTING BUGS
  ${BUGREPORT}
COPYRIGHT
  Copyright (c) Erik Southworth, ${RELEASE}  This is free software: see the
  source for copying conditions. You are free to change and redistribute
  it. There is NO WARRANTY, to the extent permitted by law. This is free
  documentation: copying and distribution of this manual, with or without
  modification, are permitted in any medium without royalty provided
  the copyright notice and this notice are preserved.
SEE ALSO
  steam(6)
EOT
exit
}

version()
{
cat << EOT
${NAME} ${VERSION}
Copyright (c) Erik Southworth, ${RELEASE}
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
EOT
exit
}

optparse()
{
	# usage banner
	usage_banner=$(cat << EOT
Half-Life Dedicated Server Update Tool (${NAME})

Usage:
  ${BIN} <command> [game] [dir] [options]
EOT
)

	usage_main=$(cat << EOT
  -c, --command=CMD, CMD
          update <game>     install or update dedicated server
          version           display installed versions
          list              show available games

  -g, --game=NAME, NAME     name of game (use --command=list to see available games)
  -d, --dir=PATH, PATH      path to install directory (default=last-run-path)
EOT
)

	usage_options=$(cat << EOT
  -a, --verify_all          verifies all files are up to date (over-write control)
  -r, --retry               retry every 30sec if Steam Network is busy
  -s, --nobootstrapupdate   do not check for updates to the update tool
  -i, --interactive, console  drop into the Steam Console Client (c) Valve Corporation
EOT
)

	usage_login=$(cat << EOT
  -u, --username=USERNAME   steam account username (only needed to access limited content)
  -p, --password=PASSWORD   steam account password (only needed to access limited content)
  -f, --remember_password   remember password (if a username is supplied)
EOT
)

	usage_other=$(cat << EOT
  -h, --help, help          display usage guide
  -V, --version             display version and copyright information
  -w, --wipe, wipe [PATH]   remove blob files (ClientRegistry, InstallRecord from PATH)
  -b, --beta=NAME           name of beta update
  -e, --info                beta help information
  -m, --manual              output manual text
  -v, --verbose             verbose operation
  -n, --noionice            disable ionice operation
EOT
)

	# policy: acceptable options
	_short_opts=c:g:d:arsu:p:fhVwb:emvni
	_long_opts=command:,game:,dir:,verify_all,retry,nobootstrapupdate,username:,password:,remember_password,help,version,wipe,beta:,info,manual,verbose,noionice,interactive

	# disable shell errexit
	if test -o errexit; then set +e; _errexit=1; fi

	# test getopt(1)
	if $($GETOPT -T &>/dev/null); [ $? = 4 ]
	then 	# Enhanced getopt(1)
	    _opts=$($GETOPT -a -o ${_short_opts} -l ${_long_opts} -n ${BIN} -- "$@")
	else 	# Old getopt(1)
	    _opts=$($GETOPT ${_short_opts} "$@")
	fi

	# getopt(1) err handle
	if [ $? != 0 ]; then echo "Try \`${BIN} --help' for more information." >/dev/stderr; exit 1; fi

	# opt flags
	opt_is_help= opt_is_verbose= opt_has_update= opt_has_game= opt_has_dir= opt_is_wipe= opt_is_version= opt_is_noionice=

	# parse options
	eval set -- "${_opts}"
	while true; do
	    case "${1}" in
	    -c|--command)
		cmd+=("-command" "${2}")
		# for steam_version()
		test "${2}" = "version" && opt_is_version=1
		# for steam_symlink()
		test "${2}" = "update" && opt_has_update=1
		shift 2;;
	    -g|--game)
		if test "${2}" = "css"; then
		    cmd+=("-game" "counter-strike source")
		else
		    cmd+=("-game" "${2}")
		fi
		opt_has_game=1; shift 2;;
	    -d|--dir) _enforce_abs_path "${2}"; opt_has_dir=1; shift 2;;
	    -a|--verify_all) cmd+=("-verify_all"); shift;;
	    -r|--retry) cmd+=("-retry"); shift;;
	    -s|--nobootstrapupdate) cmd+=("-nobootstrapupdate"); shift;;
	    -u|--username) cmd+=("-username" "${2}"); shift 2;;
	    -p|--password) cmd+=("-password" "${2}"); shift 2;;
	    -f|--remember_password) cmd+=("-remember_password"); shift;;
	    -h|--help) opt_is_help=1; shift;;
	    -V|--version) version;;
	    -w|--wipe) cmd+=("-wipe"); opt_is_wipe=1; shift;;
	    -b|--beta) cmd+=("-beta" "${2}"); shift 2;;
	    -e|--info) betainfo;;
	    -m|--manual) manual;;
	    -v|--verbose) opt_is_verbose=1; shift;;
	    -n|--noionice) opt_is_noionice=1; shift;;
	    -i|--interactive) steam_console;;
	       --) shift; break;;
	    *) echo "internal error: uncaught option \`${1}'" >/dev/stderr; exit 2;;
	    esac
	done

	# parse positional arguments
	if test $# -gt 0; then
	    case "${1}" in
	    console) steam_console;;
	    help) opt_is_help=1; shift;;
	    wipe)
		cmd+=("-wipe"); opt_is_wipe=1;
		if test "${2}" -a ! ${opt_has_dir}; then
		    _enforce_abs_path "${2}"; opt_has_dir=1; shift
		fi
		shift;;
	    update)
		cmd+=("-command" "update"); opt_has_update=1
		if test "${2}" -a ! ${opt_has_game}; then
		    if test "${2}" = "css"; then
			cmd+=("-game" "counter-strike source")
		    else
			cmd+=("-game" "${2}")
		    fi
		    opt_has_game=1; shift
		fi

		if test "${2}" -a ! ${opt_has_dir}; then
		    _enforce_abs_path "${2}"; opt_has_dir=1; shift
		fi
		shift;;
	    version)
		opt_is_version=1
		if test "${2}" -a ! ${opt_has_dir}; then
		    _enforce_abs_path "${2}"; opt_has_dir=1; shift
		fi
		shift;;
	    list) cmd+=("-command" "list"); opt_has_update=; shift;;
	    esac
	fi

	if test "$*"; then
	    echo "unrecognized arguments: \`$*'" >/dev/stderr
	    echo "Try \`${BIN} --help' for more information." >/dev/stderr
	    exit 1
	fi

	# re-enable errexit
	test ${_errexit} && set -o errexit

	# if we call usage
	test ${opt_is_help} && test ${opt_is_verbose} && usage_verbose
	test ${opt_is_help} && usage

        # if we call wipe
	test ${opt_is_wipe} && steam_wipe

	# if we call version
	test ${opt_is_version} && steam_version

	# policy: enforce: game is mandatory when doing an update
	test ${opt_has_update} -a ! ${opt_has_game} && opt_has_update=
}

# policy: enforce absolute PATH
_enforce_abs_path()
{
	if [ "${1}" != "." ]; then
		case "${1}" in
		# absolute
		/*) installdir="${1}";;
		# relative2absolute
		*) installdir="${CWD}/${1}";;
		esac
	else
		# current2absolute
		installdir="${CWD}"
	fi
}

# main function
main()
{
	steam_run
	steam_symlink
}

# call steam program
steam_run()
{
	_check_steambin_install
	_check_steam_installdir
	test ${opt_is_noionice} && IONICE=
	test ! ${operation_is_silent} && _command_feedback

	# retry N times if there is an update/failure
	i=0; iter=3
	while [ $i -lt $iter ]; do
	    [ $i -gt 0 ] && test ! ${operation_is_silent} && printf "${YELLOW}+ Retrying command ...${NORMAL}\n"

	    if test ${operation_is_silent}; then
		($IONICE "${STEAMBIN}" "${cmd[@]}" &>/dev/null)
	    elif test ${opt_is_verbose}; then
		($IONICE "${STEAMBIN}" "${cmd[@]}")
	    else
		($IONICE "${STEAMBIN}" "${cmd[@]}" 2>/dev/null)
	    fi

	    if [ $? -eq 0 ]; then break; fi
	    i=$(($i+1))
	done
	[ $i -eq 3 ] &&
	${error:?Executing: \`${BIN} ${cmd[@]}\' in ($iter) tries: exited with exit code ${RETVAL-$?}}
}

# call steam console
steam_console()
{
	_check_steam_console_install

	# retry N times if there is an update/failure
	i=0; iter=3
	while [ $i -lt $iter ]; do
	    [ $i -gt 0 ] && test ! ${operation_is_silent} && printf "${YELLOW}+ Retrying command ...${NORMAL}\n"

	    if test ${operation_is_silent}; then
		(STEAMEXE=steamcmd "${CONSOLEBIN}" &>/dev/null)
	    elif test ${opt_is_verbose}; then
		(STEAMEXE=steamcmd "${CONSOLEBIN}")
	    else
		(STEAMEXE=steamcmd "${CONSOLEBIN}" 2>/dev/null)
	    fi

	    if [ $? -eq 0 ]; then break; fi
	    i=$(($i+1))
	done
	[ $i -eq 3 ] &&
	${error:?Executing: \`${BIN} --interactive\' in ($iter) tries: exited with exit code ${RETVAL-$?}}
	exit
}

# steam program installation
_check_steambin_install()
{
	# sanity check, steambin executable?
	if ! test -x "${STEAMBIN}"; then
	    # sanity check, CONFDIR exists?
	    if ! test -d "${CONFDIR}"; then
		$INSTALL_DIR "${CONFDIR}" &&
		printf "${YELLOW}+ Creating directory ${CONFDIR} ...${NORMAL}\n" ||
		${error:?Creating directory ${CONFDIR}: exited with exit code ${RETVAL-$?}}
	    fi

	    # install users steambin
	    $INSTALL_PROGRAM "${HLDSUPDATETOOL}" "${STEAMBIN}" &&
	    printf "${YELLOW}+ Installing ${HLDSUPDATETOOL} to ${STEAMBIN} ...${NORMAL}\n" ||
	    ${error:?Installing ${HLDSUPDATETOOL} to ${STEAMBIN}: exited with exit code ${RETVAL-$?}}
	fi
}

# steam console installation
_check_steam_console_install()
{
	# sanity check, steamcmd executable?
	if ! test -x "${CONSOLEBIN}"; then
	    # sanity check, CONFDIR exists?
	    if ! test -d "${CONFDIR}"; then
		$INSTALL_DIR "${CONFDIR}" &&
		printf "${YELLOW}+ Creating directory ${CONFDIR} ...${NORMAL}\n" ||
		${error:?Creating directory ${CONFDIR}: exited with exit code ${RETVAL-$?}}
	    fi

	    # install users steamcmd
	    cd "${CONFDIR}"
	    $UNPACK "${STEAMCMD}" &&
	    printf "${YELLOW}+ Installing ${STEAMCMD} to ${CONFDIR} ...${NORMAL}\n" ||
	    ${error:?Installing ${STEAMCMD} to ${CONSOLEBIN}: exited with exit code ${RETVAL-$?}}
	fi
}

# check steam workon dir
_check_steam_installdir()
{
	# finds workon(installdir) dir from opt or last-run-path else CWD
	if ! test "${installdir}"; then
	    installdir=$(cat "${CONFDIR}/last-run-path" 2>/dev/null)
	    if ! test "${installdir}"; then
		installdir="${CWD}"
	    fi
	fi

	# sanity check, installdir exists && writeable?
	if ! test -d "${installdir}"; then
	    ${error:?Directory ${installdir} does not exist: exited with exit code ${RETVAL-$?}}
	else
	    if test -w "${installdir}"; then
		echo "${installdir}" >"${CONFDIR}"/last-run-path
		cmd+=("-dir" "${installdir}")
	    else
		${error:?Permission denied ${installdir}: exited with exit code ${RETVAL-$?}}
	    fi
	fi
}

# cmd feedback
_command_feedback()
{
	if test ${opt_is_noionice}; then
	    printf "${BOLD}+ steam ${cmd[@]}${NORMAL}\n"
	else
	    printf "${BOLD}+ ${IONICE} steam ${cmd[@]}${NORMAL}\n"
	fi
}

# symlink for -autoupdate option
steam_symlink()
{
	if test ${opt_has_update}; then
	    # find run-script dir
	    for rundir in $(find "${installdir}" -maxdepth 2 -name "*_run" -execdir pwd \;); do
		_check_steam_link
	    done
	fi
}

# check the integrity of the steam_link to make sure it points back at ${FILENAME}
_check_steam_link()
{
	steamlink="${rundir}/steam"; action=
	# sanity check steamlink
	if test -L "${steamlink}"; then
	    # is link, check if correct
	    link_target=$(readlink --canonicalize "${steamlink}")
	    if test "${link_target}" = "${FILENAME}"; then
		reply=$(printf "${GREEN}ok${NORMAL}")
	    else
		action=Repairing; reply=$(printf "${RED}bad -> \`${link_target}'${NORMAL}")

	    fi
	elif ! test -e "${steamlink}"; then
	    action=Creating; reply=$(printf "${RED}missing${NORMAL}")
	elif test -x "${steamlink}"; then
	    action=WARNING; reply=$(printf "${RED}program${NORMAL}")
	elif test -f "${steamlink}"; then
	    action=WARNING; reply=$(printf "${RED}file${NORMAL}")
	else
	    action=WARNING; reply=$(printf "${RED}unknown${NORMAL}")

	fi

	printf "\n\n${YELLOW}+ Checking steam symlink in ${rundir} ... \t${reply}${NORMAL}"

	# touch link, if required.
	if [ "${action}" = "Repairing" ] || [ "${action}" = "Creating" ]; then
	    echo
	    pushd "${rundir}" >/dev/null ||
	    ${error:?exited with exit code ${RETVAL-$?}}

	    # if ${BINDIR} has steam; check if linked to ${FILENAME}.
            # makes a nice "steam -> /path/to/bindir/steam" link.
	    if test ${opt_is_verbose}; then
		hash steam && binlink=$(hash -t steam) || binlink=${FILENAME}
	    else
		hash steam 2>/dev/null && binlink=$(hash -t steam) || binlink=${FILENAME}
	    fi

	    # sanity check binlink
	    if test -L "${binlink}"; then
		# is link, check if correct
		link_target=$(readlink --canonicalize "${binlink}")
		if ! test "${link_target}" = "${FILENAME}"; then
		    binlink=${FILENAME}
		fi
	    else
		binlink=${FILENAME}
	    fi

	    # do the symlink
	    $SYMLINK "${binlink}" "steam" &&
	    printf "${YELLOW}+ ${action} symlink ${steamlink} -> \`${binlink}'${NORMAL}\n" ||
	    ${error:?${action} symlink ${steamlink} -> ${binlink}: exited with exit code ${RETVAL-$?}}

	    popd >/dev/null

	elif [ "${action}" = "WARNING" ]; then
	    printf "\n${RED}${action}: Conflict file type ${steamlink}. Expected symlink. Ignore if intentional.${NORMAL}\n"
	else
	    echo #no action, symlink is ok
	fi
}

# remove blob files
steam_wipe()
{
	_check_steam_installdir
	_command_feedback

	printf "${GREEN}+ removing blobs ...${YELLOW}\n"
	$FIND "${installdir}" -maxdepth 2 -name "InstallRecord.blob" -print -delete
	$FIND ${CONFDIR} -name "ClientRegistry.blob" -print -delete
	$FIND ${CONFDIR} -name "test*.so" -print -delete
	# remove some strange dirs if exists
	$REMOVE -frv ${CONFDIR}/appcache
	$REMOVE -frv ${CONFDIR}/config
	$REMOVE -frv ${CONFDIR}/logs
	# clean & remove old conf dir if exists (fail silently)
	$FIND ${OLDCONFDIR} -name "ClientRegistry.blob" -print -delete 2>/dev/null
	$FIND ${OLDCONFDIR} -name "test*.so" -print -delete 2>/dev/null
	$FIND ${OLDCONFDIR} -name "steam" -print -delete 2>/dev/null
	$FIND ${OLDCONFDIR} -name "last-run-path" -print -delete 2>/dev/null
	$REMOVE_EMPTY_DIR ${OLDCONFDIR} 2>/dev/null
	printf "${NORMAL}"
	exit
}

# read steam.inf files for app version
steam_version()
{
	# NB: -command version does NOT associate with the -dir option.
	# We do a silent update first to redirect steam to the correct path.
	cmd=("-command" "update"); operation_is_silent=1; steam_run
	cmd=("-command" "version"); operation_is_silent=; steam_run
	$FIND "${installdir}" -maxdepth 4 -name steam.inf -execdir cat '{}' \;
	exit
}

# ===============================================
# store installdir value if script is interrupted
keyboard_interrupt()
{
	echo -en "\nInterrupted! Terminating ...\n"
	_check_steam_installdir
	exit
}

# run if user hits (control-c)
trap keyboard_interrupt SIGINT
# ===============================================

optparse "$@"
main
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.