Skip to content

Commit

Permalink
Update script to use the new application.properties.dist file (#2049)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwithi committed Sep 10, 2024
1 parent 8144884 commit 10dcc51
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions oh.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,11 @@ function write_api_config_file {
# generate OH API token and save to settings file
$JWT_TOKEN_SECRET=( -join ($(for($i=0; $i -lt 64; $i++) { ((65..90)+(97..122)+(".")+("!")+("?")+("&") | Get-Random | % {[char]$_}) })) )
Write-Host "Writing OH API configuration file -> $API_SETTINGS..."
(Get-Content "$OH_PATH/$OH_DIR/rsc/$API_SETTINGS.dist").replace("JWT_TOKEN_SECRET","$JWT_TOKEN_SECRET") | Set-Content "$OH_PATH/$OH_DIR/rsc/$API_SETTINGS"
(Get-Content "$OH_PATH/$OH_DIR/rsc/$API_SETTINGS").replace("OH_API_PID","$OH_API_PID") | Set-Content "$OH_PATH/$OH_DIR/rsc/$API_SETTINGS"
(Get-Content "$OH_PATH/$OH_DIR/rsc/$API_SETTINGS.dist") `
-replace "JWT_TOKEN_SECRET", "$JWT_TOKEN_SECRET" `
-replace "OH_API_PID", "$OH_API_PID" `
-replace "API_HOST:API_PORT", "localhost:8080" `
| Set-Content "$OH_PATH/$OH_DIR/rsc/$API_SETTINGS"
}
}

Expand Down
5 changes: 4 additions & 1 deletion oh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,10 @@ function write_api_config_file {
# JWT_TOKEN_SECRET=`openssl rand -base64 64 | xargs`
JWT_TOKEN_SECRET=`LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 66`
echo "Writing OH API configuration file -> $API_SETTINGS..."
sed -e "s/JWT_TOKEN_SECRET/"$JWT_TOKEN_SECRET"/g" -e "s&OH_API_PID&"$OH_API_PID"&g" ./$OH_DIR/rsc/$API_SETTINGS.dist > ./$OH_DIR/rsc/$API_SETTINGS
sed -e "s/JWT_TOKEN_SECRET/"$JWT_TOKEN_SECRET"/g" \
-e "s&OH_API_PID&"$OH_API_PID"&g" \
-e "s/API_HOST:API_PORT/localhost:8080/g" \
./$OH_DIR/rsc/$API_SETTINGS.dist > ./$OH_DIR/rsc/$API_SETTINGS
fi
}

Expand Down
6 changes: 5 additions & 1 deletion ohmac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,11 @@ function write_api_config_file {
JWT_TOKEN_SECRET=`LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 66`

echo "Writing OH API configuration file -> $API_SETTINGS..."
sed -i '' -e "s/JWT_TOKEN_SECRET/"$JWT_TOKEN_SECRET"/g" -e "s&OH_API_PID&"$OH_API_PID"&g" $SET_FILE.dist
sed -i '' \
-e "s/JWT_TOKEN_SECRET/$JWT_TOKEN_SECRET/g" \
-e "s/API_HOST:API_PORT/localhost:8080/g" \
-e "s&OH_API_PID&$OH_API_PID&g" \
$SET_FILE.dist
cp -f $SET_FILE.dist $SET_FILE
fi
}
Expand Down

0 comments on commit 10dcc51

Please sign in to comment.