From 10029c297ed8f6d97b582bc7382d9e9558808884 Mon Sep 17 00:00:00 2001 From: Kellen Carey Date: Fri, 9 Oct 2020 18:00:11 -0700 Subject: [PATCH 1/3] exit setup if no write permissions in directory --- docs/static/setup.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 49ed3eb2..96e87688 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -22,6 +22,13 @@ check_exists "command -v curl" "curl is not installed, and is required for this check_exists "git config user.name" "Git username not set!\nRun: git config --global user.name 'My Name'" check_exists "git config user.email" "Git email not set!\nRun: git config --global user.email 'example@myemail.com'" +# Check to see if the user has write permissions in this directory to prevent a cryptic error later on +if [ ! -w `pwd` ]; then + echo 'Sorry, you do not have write permissions in this directory.'; + echo 'Please try running this script again from a directory that you do have write permissions for.'; + exit 1 +fi + repo_path="https://github.com/zmkfirmware/zmk-config-split-template.git" title="ZMK Config Setup:" From b64517943deb3dfe72e2e37ca62319856bc35752 Mon Sep 17 00:00:00 2001 From: Kellen Carey Date: Fri, 9 Oct 2020 18:53:21 -0700 Subject: [PATCH 2/3] add powershell check --- docs/static/setup.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/static/setup.ps1 b/docs/static/setup.ps1 index abdb6981..1da57378 100644 --- a/docs/static/setup.ps1 +++ b/docs/static/setup.ps1 @@ -59,6 +59,19 @@ catch [System.Management.Automation.CommandNotFoundException] { Test-Git-Config -Option "user.name" -ErrMsg "Git username not set!`nRun: git config --global user.name 'My Name'" Test-Git-Config -Option "user.email" -ErrMsg "Git email not set!`nRun: git config --global user.name 'example@myemail.com'" +$permission = (Get-Acl $PSScriptRoot).Access | +?{$_.IdentityReference -match $env:UserName ` + -and $_.FileSystemRights -match "Read" ` + -or $_.FileSystemRights -match "Write" } | + + Select IdentityReference,FileSystemRights + +If (-Not $permission){ + Write-Host "Sorry, you do not have write permissions in this directory." + Write-Host "Please try running this script again from a directory that you do have write permissions for." + exit 1 +} + $repo_path = "https://github.com/zmkfirmware/zmk-config-split-template.git" $title = "ZMK Config Setup:" From 4aa45c6f40c3e640cebce58b4d10cd24dc61b8ed Mon Sep 17 00:00:00 2001 From: Kellen Carey Date: Sat, 10 Oct 2020 17:00:13 -0700 Subject: [PATCH 3/3] update setup.ps1 --- docs/static/setup.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/static/setup.ps1 b/docs/static/setup.ps1 index 1da57378..63bd5c0e 100644 --- a/docs/static/setup.ps1 +++ b/docs/static/setup.ps1 @@ -57,11 +57,11 @@ catch [System.Management.Automation.CommandNotFoundException] { } Test-Git-Config -Option "user.name" -ErrMsg "Git username not set!`nRun: git config --global user.name 'My Name'" -Test-Git-Config -Option "user.email" -ErrMsg "Git email not set!`nRun: git config --global user.name 'example@myemail.com'" +Test-Git-Config -Option "user.email" -ErrMsg "Git email not set!`nRun: git config --global user.email 'example@myemail.com'" -$permission = (Get-Acl $PSScriptRoot).Access | +$permission = (Get-Acl $pwd).Access | ?{$_.IdentityReference -match $env:UserName ` - -and $_.FileSystemRights -match "Read" ` + -and $_.FileSystemRights -match "FullControl" ` -or $_.FileSystemRights -match "Write" } | Select IdentityReference,FileSystemRights