Skip to content

Commit

Permalink
Steam
Browse files Browse the repository at this point in the history
  • Loading branch information
matteocorti committed Jan 30, 2024
1 parent 575f295 commit bdf528f
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 12 deletions.
2 changes: 1 addition & 1 deletion COPYRIGHT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

* Copyright © 2018-2023 Matteo Corti
* Copyright © 2018-2024 Matteo Corti

with the following individuals added to the list of contributing authors

Expand Down
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2024-01-30 Matteo Corti <matteo@corti.li>

* update.sh: added Steam support

2023-09-04 Matteo Corti <matteo@corti.li>

* update.sh: added --no-* options to skip updates
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* 2024-01-30, Version 2.4.0
* Steam support
* 2023-10-01, Version 2.3.0
* Options can be specified in the ```~/.update.sh.rc``` file (no documentation yet)
* 2023-09-04, Version 2.2.0
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

&copy; Matteo Corti, 2018-2023
&copy; Matteo Corti, 2018-2024

![](https://img.shields.io/github/v/release/matteocorti/update.sh)&nbsp;![](https://img.shields.io/github/downloads/matteocorti/update.sh/latest/total)&nbsp;![](https://img.shields.io/github/downloads/matteocorti/update.sh/total)&nbsp;![](https://img.shields.io/github/license/matteocorti/update.sh)&nbsp;![](https://img.shields.io/github/stars/matteocorti/update.sh)&nbsp;![](https://img.shields.io/github/forks/matteocorti/update.sh)

Expand All @@ -18,6 +18,7 @@ Updates a macOS system. Following software packages are analyzed and automatical
- Ruby dependencies
- Homebrew and installed packages
- MacPorts and installed ports
- Steam games

## Usage

Expand All @@ -44,9 +45,11 @@ Options:
--no-msupdate do not update Microsoft products
--no-perl do not update Perl and CPAN modules with Perlbrew
--no-ruby do not update ruby
--no-steam do not update steam
--perl update Perl and CPAN modules with Perlbrew
-q,--quiet minimal output
--ruby update ruby
--steam update Steam
-v,--verbose verbose output
Report bugs to https://github.com/matteocorti/update.sh/issues
Expand Down
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Options can be specified in the ```~/.update.sh.rc``` file (no documentation yet)
Steam support
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0
2.4.0
142 changes: 135 additions & 7 deletions update.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/sh

# Copyright (c) 2018-2023 Matteo Corti <matteo@corti.li>
# Copyright (c) 2018-2024 Matteo Corti <matteo@corti.li>

VERSION=2.3.0
VERSION=2.4.0

SIGNALS="HUP INT QUIT TERM ABRT"

VERBOSE=""
CLEAR=""
Expand All @@ -13,6 +15,55 @@ error() {
exit 1
}

create_temporary_file() {

# create a temporary file
# mktemp is not always available (e.g., on AIX)
# we could use https://stackoverflow.com/questions/10224921/how-to-create-a-temporary-file-with-portable-shell-in-a-secure-way
# but on some systems od -N4 -tu /dev/random takes seconds (?) to execute

if [ -n "${MKTEMP}" ]; then
TEMPFILE="$(mktemp "${TMPDIR}/XXXXXX" 2>/dev/null)"
else
TEMPFILE=${TMPDIR}/XXX-$(od -N4 -tu /dev/random | head -n 1 | sed 's/ *$//' | sed 's/.* //')
touch "${TEMPFILE}"
fi

if [ -z "${TEMPFILE}" ] || [ ! -w "${TEMPFILE}" ]; then
echo 'temporary file creation failure.' 1>&2
fi

# add the file to the list of temporary files
TEMPORARY_FILES="${TEMPORARY_FILES} ${TEMPFILE}"

}

remove_temporary_files() {
# shellcheck disable=SC2086
if [ -n "${TEMPORARY_FILES}" ]; then
rm -f ${TEMPORARY_FILES}
fi
}

cleanup() {
remove_temporary_files
# shellcheck disable=SC2086
trap - ${SIGNALS}
exit
}

################################################################################
# trap passing the signal name
# see https://stackoverflow.com/questions/2175647/is-it-possible-to-detect-which-trap-signal-in-bash/2175751#2175751
trap_with_arg() {
func="$1"
shift
for sig; do
# shellcheck disable=SC2064
trap "${func} ${sig}" "${sig}"
done
}

run_command() {

COMMAND="$1"
Expand Down Expand Up @@ -61,9 +112,11 @@ usage() {
echo " --no-msupdate do not update Microsoft products"
echo " --no-perl do not update Perl and CPAN modules with Perlbrew"
echo " --no-ruby do not update ruby"
echo " --no-steam do not update steam"
echo " --perl update Perl and CPAN modules with Perlbrew"
echo " -q,--quiet minimal output"
echo " --ruby update ruby"
echo " --steam update Steam"
echo " -v,--verbose verbose output"
echo
echo "Report bugs to https://github.com/matteocorti/update.sh/issues"
Expand All @@ -74,11 +127,16 @@ usage() {
ALL=1

# source the settings file
if [ -r "${HOME}/.update.sh.rc" ] ; then
if [ -r "${HOME}/.update.sh.rc" ]; then
# shellcheck disable=SC1091
. "${HOME}/.update.sh.rc"
fi

# Cleanup before program termination
# Using named signals to be POSIX compliant
# shellcheck disable=SC2086
trap_with_arg cleanup ${SIGNALS}

while true; do

case "$1" in
Expand Down Expand Up @@ -166,6 +224,10 @@ while true; do
NO_RUBY=1
shift
;;
--no-steam)
NO_STEAM=1
shift
;;
--perl)
PERL=1
ALL=
Expand All @@ -185,6 +247,11 @@ while true; do
ALL=
shift
;;
--steam)
STEAM=1
ALL=
shift
;;
-v | --verbose)
VERBOSE=1
echo "Enabling verbose output"
Expand Down Expand Up @@ -216,6 +283,7 @@ if [ -n "${ALL}" ]; then
PERL=1
PORT=1
RUBY=1
STEAM=1
fi

if [ -n "${NO_ADOBE}" ]; then
Expand Down Expand Up @@ -245,6 +313,9 @@ fi
if [ -n "${NO_RUBY}" ]; then
RUBY=
fi
if [ -n "${NO_STEAM}" ]; then
STEAM=
fi

if [ -n "${CLEAR}" ]; then
clear
Expand All @@ -269,6 +340,62 @@ if [ -n "${MAC_UPDATER}" ] && [ -x /Applications/MacUpdater.app/Contents/Resourc

fi

if [ -n "${STEAM}" ]; then

if command -v steamcmd >/dev/null 2>&1; then

if [ -z "${QUIET}" ]; then
echo
echo "##############################################################################"
echo "# Steam${NAME}"
echo "#"
echo
fi

# https://stackoverflow.com/questions/56573277/fabric-framework-can-t-be-opened-because-it-is-from-an-unidentified-developer
sudo spctl --master-disable

create_temporary_file
steamcmd_script=${TEMPFILE}

# get app IDs
app_ids=$(grep appid ~/Library/Application\ Support/Steam/steamapps/appmanifest*acf |
sed 's/.*"appid".*"\([0-9]*\)".*/\1/')

for app_id in ${app_ids}; do

if [ -z "${QUIET}" ]; then
echo "Updating Steam app '${app_id}'"
fi

cat <<____STEAM >"${steamcmd_script}"
login anonymous
app_update ${app_id}
quit
quit
____STEAM

if [ -z "${QUIET}" ]; then
run_command "steamcmd runscript < ${steamcmd_script}"
else
run_command "steamcmd runscript < ${steamcmd_script} > /dev/null"
fi

done

sudo spctl --master-disable

else

if [ -z "${QUIET}" ]; then
echo 'steamcmd non installed: skipping Steam updates'
fi

fi

fi

if [ -n "${MSUPDATE}" ] && [ -x /Library/Application\ Support/Microsoft/MAU2.0/Microsoft\ AutoUpdate.app/Contents/MacOS/msupdate ]; then

if [ -z "${QUIET}" ]; then
Expand Down Expand Up @@ -413,9 +540,9 @@ if [ -n "${BREW}" ]; then

fi

if [ -n "${EMACS}" ] ; then
if [ -n "${EMACS}" ]; then

if [ -x /Applications/Emacs.app/Contents/MacOS/emacs-nw ] ; then
if [ -x /Applications/Emacs.app/Contents/MacOS/emacs-nw ]; then

if [ -z "${QUIET}" ]; then
echo
Expand All @@ -431,8 +558,7 @@ if [ -n "${EMACS}" ] ; then

fi


if [ -n "${RUBY}" ] ; then
if [ -n "${RUBY}" ]; then

if command -v bundle >/dev/null 2>&1; then

Expand Down Expand Up @@ -510,3 +636,5 @@ fi
if [ -z "${QUIET}" ]; then
echo
fi

remove_temporary_files
2 changes: 1 addition & 1 deletion update.sh.completion
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _update.sh() {
# only the autocompletion with long options is implemented: long options are more readable and quick to enter since we are
# using autocompletion.
#
opts="--adobe --apple --brew --emacs --macupdater --mas --msupdate --perl --clear --help --name --no-adobe --no-apple --no-brew --no-emacs --no-macupdater --no-mas --no-msupdate --no-perl --no-ruby --quiet --verbose --ruby"
opts="--adobe --apple --brew --emacs --macupdater --mas --msupdate --perl --clear --help --name --no-adobe --no-apple --no-brew --no-emacs --no-macupdater --no-mas --no-msupdate --no-perl --no-ruby --no-steam --quiet --verbose --ruby --steam"

if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]]; then
# shellcheck disable=2207
Expand Down

0 comments on commit bdf528f

Please sign in to comment.