|
19 | 19 | #gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution |
20 | 20 |
|
21 | 21 |
|
22 | | -VERSION="1.1.2" |
| 22 | +VERSION="1.2.0" |
23 | 23 | gitreposubpath="PowerShell/PowerShell/master" |
24 | 24 | gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools" |
25 | 25 | thisinstallerdistro=redhat |
|
90 | 90 |
|
91 | 91 | ## Check requirements and prerequisites |
92 | 92 |
|
93 | | -#Only do SUDO if we are not root |
94 | | -SUDO='' |
95 | | -if (( $EUID != 0 )); then |
96 | | - SUDO='sudo' |
| 93 | +#Check for sudo if not root |
| 94 | +if [[ "${CI}" == "true" ]]; then |
| 95 | + echo "Running on CI (as determined by env var CI set to true), skipping SUDO check." |
| 96 | + set -- "$@" '-skip-sudo-check' |
97 | 97 | fi |
98 | 98 |
|
99 | | -#Check that sudo is available |
100 | | -if [[ "$SUDO" == "sudo" && ! ("'$*'" =~ skip-sudo-check) ]]; then |
101 | | - |
102 | | - $SUDO -v |
103 | | - if [ $? -ne 0 ]; then |
104 | | - echo "ERROR: You must either be root or be able to use sudo" >&2 |
105 | | - exit 5 |
| 99 | +SUDO='' |
| 100 | +if (( $EUID != 0 )); then |
| 101 | + #Check that sudo is available |
| 102 | + if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then |
| 103 | + SUDO='sudo' |
| 104 | + else |
| 105 | + echo "ERROR: You must either be root or be able to use sudo" >&2 |
| 106 | + #exit 5 |
106 | 107 | fi |
107 | 108 | fi |
108 | 109 |
|
109 | | -#Collect any variation details if required for this distro |
110 | | - |
111 | | -#END Collect any variation details if required for this distro |
112 | | - |
113 | | -#If there are known incompatible versions of this distro, put the test, message and script exit here: |
114 | | - |
115 | | -#END Verify The Installer Choice |
116 | | - |
117 | | -##END Check requirements and prerequisites |
| 110 | +if [[ "'$*'" =~ allowprerelease ]] ; then |
| 111 | + echo |
| 112 | + echo "-allowprerelease was used, but since $DistroBasedOn uses repositories - selection of releases will depend on the repository contents." |
| 113 | +fi |
118 | 114 |
|
119 | | -echo |
| 115 | +release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`echo |
120 | 116 | echo "*** Installing PowerShell Core for $DistroBasedOn..." |
121 | 117 | if ! hash curl 2>/dev/null; then |
122 | 118 | echo "curl not found, installing..." |
@@ -152,12 +148,11 @@ if [[ "'$*'" =~ includeide ]] ; then |
152 | 148 | echo |
153 | 149 | echo "*** Installing VS Code PowerShell Extension" |
154 | 150 | code --install-extension ms-vscode.PowerShell |
155 | | -fi |
156 | | - |
157 | | -if [[ "'$*'" =~ -interactivetesting ]] ; then |
158 | | - echo "*** Loading test code in VS Code" |
159 | | - curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1 |
160 | | - code ./testpowershell.ps1 |
| 151 | + if [[ "'$*'" =~ -interactivetesting ]] ; then |
| 152 | + echo "*** Loading test code in VS Code" |
| 153 | + curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1 |
| 154 | + code ./testpowershell.ps1 |
| 155 | + fi |
161 | 156 | fi |
162 | 157 |
|
163 | 158 | if [[ "$repobased" == true ]] ; then |
|
0 commit comments