2022-08-27 12:24:17 +00:00
#!/bin/bash
set -e
ARMA_MOD_VOLUME = "arma3_dev_mods"
# Check if argument is given
if [ -z " $1 " ] ; then
echo "No argument given. Use workshop id as argument. e.g. 1400118996"
exit 1
fi
PAYLOAD = $( cat <<EOF
set -e
WORKSHOP_DIR = "/home/steam/Steam/steamapps/workshop/content"
2022-08-30 14:05:41 +00:00
MOD_DIR = "\$WORKSHOP_DIR/107410"
2022-08-27 12:24:17 +00:00
mkdir -p \$ WORKSHOP_DIR
2022-08-30 14:05:41 +00:00
ln -s /home/steam/mount "\$MOD_DIR"
2022-08-27 12:24:17 +00:00
echo -n "Username: "
read username
2022-08-30 14:05:41 +00:00
echo "Perform initial login."
2022-08-27 12:24:17 +00:00
/home/steam/steamcmd/steamcmd.sh +login \$ username +quit
tmpFile = $( mktemp)
for mod_id in \$ ( curl -s " https://steamcommunity.com/sharedfiles/filedetails/?id= $1 " | grep -E 'id="sharedfile_[0-9]+"' | sed 's/.*id="sharedfile_\([0-9]\+\)".*/\1/' )
do
{
echo "// autogenerated DONT TOUCH" ;
echo -e "@ShutdownOnFailedCommand 1" ;
echo -e "@NoPromptForPassword 1"
echo "login \$username" ;
echo "workshop_download_item 107410 \$mod_id validate" ;
echo "quit" ;
} > "\$tmpFile"
2022-08-30 14:05:41 +00:00
echo "### DOWNLOADING MOD \$mod_id ###"
2022-08-27 12:24:17 +00:00
until /home/steam/steamcmd/steamcmd.sh +runscript "\$tmpFile" ; do echo -e "###\nLets try that again\n###" ; done
2022-08-30 14:05:41 +00:00
echo "### DOWNLOAD FINISHED ###"
done
echo "### FIX CASE ###"
IFS = \$ '\n'
for SRC in \$ ( find "\$MOD_DIR/" -depth)
do
DST = \$ ( dirname "\${SRC}" ) /\$ ( basename "\${SRC}" | tr '\[A-Z\]' '\[a-z\]' )
if [ "\${SRC}" != "\${DST}" ]
then
[ ! -e "\${DST}" ] && mv -vT "\${SRC}" "\${DST}"
fi
2022-08-27 12:24:17 +00:00
done
EOF
)
docker run \
-it \
--rm \
--name= arma3_mods \
-v " $ARMA_MOD_VOLUME " :/home/steam/mount \
cm2network/steamcmd \
bash -c " $PAYLOAD "