1
0
Fork 0
mirror of https://github.com/aclist/dztui.git synced 2025-04-05 03:53:01 +02:00

Sanitize mod links

This commit is contained in:
aclist 2021-12-30 13:23:17 +09:00 committed by GitHub
parent 00ecb9747c
commit 38c42f6358
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -eo pipefail set -eo pipefail
version=0.1.0 version=0.2.0
aid=221100 aid=221100
game="dayz" game="dayz"
workshop="https://steamcommunity.com/sharedfiles/filedetails/?id=%s" workshop="https://steamcommunity.com/sharedfiles/filedetails/?id=%s"
@ -71,10 +71,12 @@ parse_json(){
} }
symlinks(){ symlinks(){
for d in "$workshop_dir"/*; do for d in "$workshop_dir"/*; do
mod=$(awk -F\" '/name/ {print $2}' "$d"/meta.cpp) id=$(awk -F"= " '/publishedid/ {print $2}' "$d"/meta.cpp | awk -F\; '{print $1}')
[[ -h "$game_dir/@$mod" ]] && : || mod=$(awk -F\" '/name/ {print $2}' "$d"/meta.cpp | sed -E 's/[^[:alpha:]0-9]+/_/g; s/^_|_$//g')
link="@$id-$mod"
[[ -h "$game_dir/$link" ]] && : ||
printf "[INFO] Creating symlink for $mod\n" printf "[INFO] Creating symlink for $mod\n"
ln -fs "$d" "$game_dir/@$mod" ln -fs "$d" "$game_dir/$link"
done done
} }
installed_mods(){ installed_mods(){
@ -116,18 +118,19 @@ table(){
concat_mods(){ concat_mods(){
readarray -t serv <<< "$remote_mods" readarray -t serv <<< "$remote_mods"
for i in "${serv[@]}"; do for i in "${serv[@]}"; do
awk -F\" '/name/ {print "@"$2";"}' "$workshop_dir"/$i/meta.cpp id=$(awk -F"= " '/publishedid/ {print $2}' "$workshop_dir"/$i/meta.cpp | awk -F\; '{print $1}')
done | tr -d '\n' mod=$(awk -F\" '/name/ {print $2}' "$workshop_dir"/$i/meta.cpp | sed -E 's/[^[:alpha:]0-9]+/_/g; s/^_|_$//g')
link="@$id-$mod;"
echo -e "$link"
done | tr -d '\n' | perl -ple 'chop'
} }
launch(){ launch(){
#args="-nolauncher -nosplash -skipintro -world=empty -name=$name"
mods=$(concat_mods) mods=$(concat_mods)
ip=$(echo -e "${tabled[$sel]}" | awk -F'\t' '{print $2}') ip=$(echo -e "${tabled[$sel]}" | awk -F'\t' '{print $2}')
printf "[INFO] Connecting to: $connecting_to\n" printf "[INFO] Connecting to: $connecting_to\n"
if [[ $debug -eq 1 ]]; then if [[ $debug -eq 1 ]]; then
printf "[DEBUG] steam -applaunch $aid $args -connect=$ip \"-mod=$mods\"\n" printf "[DEBUG] steam -applaunch $aid -nolauncher -nosplash -skipintro -world=empty $args -connect=$ip \"-mod=$mods\"\n"
else else
#steam -applaunch $aid "$args" -connect=$ip \"-mod=$mods\"
steam -applaunch $aid -nolauncher -nosplash -skipintro -world=empty -name=$name -connect=$ip \"-mod=$mods\" steam -applaunch $aid -nolauncher -nosplash -skipintro -world=empty -name=$name -connect=$ip \"-mod=$mods\"
printf "Good luck out there. DZTUI $version\n" printf "Good luck out there. DZTUI $version\n"
exit exit