GoogleCloudPlatform / immersive-stream-for-xr-templates

Apache License 2.0
62 stars 19 forks source link

The XR_Actions script file did not support mac terminal #16

Open hinls1007 opened 1 year ago

hinls1007 commented 1 year ago

Hi all maintainers,

I found that the script SyncContent.ps1 in XR_Actions folder didn't support mac terminal. Although I installed Powershell in my device, due to the file system, the execution of the script file didn't work well.

According to this behaviour, I wrote a shell script file which can run in Mac Terminal. Could I know the git follow that I can raise PR for adding the support for Mac users?

mnefzger commented 1 year ago

I'm also interested in a shell script for Mac. Would you be willing to share a preview here before opening a PR, @hinls1007? Would be much appreciated.

hinls1007 commented 1 year ago

Hi @mnefzger

Here is the shell script for the mac user (that may compatible with linux, but I didn't perform any test). Please advice if this script have anythings can enhance or fix


#!/bin/bash

gcs_bucket=$1
if [ -z $gcs_bucket ]; then
    echo "Please input Bucket name"
    exit 1
fi

ProjectPath=$(dirname "$0")
cd $ProjectPath/..
ProjectPath=$(pwd)
ProjectFile=$(find *.uproject | head -1); echo $A;

SyncFiles=("$ProjectFile" "CHANGELOG.md")

FoldersList=("Content" "Config" "Cloud" "ToBuild" "Source" "Plugins" "ToCustomize")
SyncFolders=()
for folder in ${FoldersList[@]}
do
    if [ -d "$ProjectPath/$folder" ]; then
        SyncFolders+=($folder)
    fi
done

echo "Sync the following files and folders to gs://$gcs_bucket:"
printf -v SyncFileString '%s, ' "${SyncFiles[@]}"
echo "Files: ${SyncFileString:0:${#SyncFileString}-2}"
printf -v SyncFolderString '%s, ' "${SyncFolders[@]}"
echo "Folders: ${SyncFolderString:0:${#SyncFolderString}-2}"

read -r -p "Proceed? (Y/n) " response
case "$response" in
    [yY][eE][sS]|[yY]) 
        break
        ;;
    *)
        exit 1
        ;;
esac

echo "Deleting all *.uproject files..."
gsutil rm gs://${gcs_bucket}/*.uproject

for file in ${SyncFiles[@]}
do
    echo "Copying file ""$SyncFile""..."
    gsutil cp "$ProjectPath/$file" gs://$gcs_bucket/$file
done

for folder in ${SyncFolders[@]}
do
    echo "Synching folder ""$folder""..."
    gsutil -m rsync -r -d "$ProjectPath/$folder" gs://$gcs_bucket/$folder
done

echo "All files uploaded."