mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Add Windows support, but it could be unstable ⚠️
"tr -d '\r'" is used to avoid Windows errors, reference: https://github.com/stedolan/jq/issues/92
This commit is contained in:
parent
8261c27949
commit
34d1d9bfec
@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- macOS support
|
- [macOS](https://apple.com/macos) support
|
||||||
|
- [Windows](https://microsoft.com/windows) support, but it could be unstable ⚠️
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Remove parallel requests improvement, because it's buggy in some situations...
|
- Remove parallel requests improvement, because it's buggy in some situations...
|
||||||
|
56
README.md
56
README.md
@ -30,7 +30,9 @@ _Based on previous work by [@vladbabii](https://github.com/vladbabii) on [docker
|
|||||||
|
|
||||||
### Standalone
|
### Standalone
|
||||||
|
|
||||||
Just clone the repo and use the script:
|
> **Note**: The easiest way to install `psu` is to use [Docker method](#docker-image-and-variants), instead of this one
|
||||||
|
|
||||||
|
Check the [Requirements](#requirements) section then [git] clone the repo and use the [bash] script below:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://gitlab.com/psuapp/psu.git
|
git clone https://gitlab.com/psuapp/psu.git
|
||||||
@ -50,17 +52,37 @@ For detailed instructions, see [How to use](#how-to-use) section.
|
|||||||
|
|
||||||
You will need these dependencies installed:
|
You will need these dependencies installed:
|
||||||
|
|
||||||
- [bash](https://www.gnu.org/software/bash/)<sup title="required">*</sup> <small>(>= 5.0.3)</small>
|
##### For [Linux] based systems <small>([Alpine], [Debian], [Ubuntu]...)</small>
|
||||||
- [curl](https://curl.se/)<sup title="required">*</sup> <small>(>= 7.64.0, but >= 7.76.0 is recommended)</small>
|
- [bash]<sup title="required">\*</sup> <small>(>= 4.4.23)</small>
|
||||||
- [jq](https://stedolan.github.io/jq/)<sup title="required">*</sup> <small>(>= 1.5.1)</small>
|
- [curl]<sup title="required">\*</sup> <small>(>= 7.64.0, but >= 7.76.0 is recommended)</small>
|
||||||
- [timeout](https://man7.org/linux/man-pages/man1/timeout.1.html)<sup title="required">*</sup> <small>For macOS run: `brew install coreutils`</small>
|
- [jq]<sup title="required">\*</sup> <small>(>= 1.5.1)</small>
|
||||||
- [uuidgen](https://man7.org/linux/man-pages/man1/uuidgen.1.html) only for some <abbr title="Operating System">OS</abbr> <small>(Debian and Alpine work fine without it)</small>
|
- [uuidgen] recommended only for some <abbr title="Operating System">OS</abbr> <small>(Alpine and Debian work fine without it)</small>
|
||||||
- greadlink <small>Only for macOS run: `brew install coreutils`</small>
|
|
||||||
|
For [Debian] and similar apt-powered [Linux] systems, run: `apt install bash curl jq`
|
||||||
|
|
||||||
|
##### For [macOS]
|
||||||
|
- [bash]<sup title="required">\*</sup> <small>(>= 4.4.23)</small>
|
||||||
|
- [curl]<sup title="required">\*</sup> <small>(>= 7.64.0, but >= 7.76.0 is recommended)</small>
|
||||||
|
- [jq]<sup title="required">\*</sup> <small>(>= 1.5.1)</small>
|
||||||
|
- [timeout]<sup title="required">\*</sup> <small>(included in the [coreutils] package)</small>
|
||||||
|
- greadlink <small>(included in the [coreutils] package)</small>
|
||||||
|
|
||||||
|
You should install [Homebrew], then run: `brew install bash coreutils jq`
|
||||||
|
|
||||||
|
##### For [Windows]
|
||||||
|
- [bash]<sup title="required">\*</sup> <small>(>= 4.4.23)</small>
|
||||||
|
- [curl]<sup title="required">\*</sup> <small>(>= 7.64.0, but >= 7.76.0 is recommended)</small>
|
||||||
|
- [jq]<sup title="required">\*</sup> <small>(>= 1.5.1)</small>
|
||||||
|
|
||||||
|
> **Note**: `psu`should work with [Windows], but it could be unstable ⚠️
|
||||||
|
|
||||||
|
You should download and install [Git](https://git-scm.com/download/win) and [jq](https://stedolan.github.io/jq/download) for [Windows]
|
||||||
|
|
||||||
|
##### For all systems
|
||||||
|
- [docker-compose] is recommended but not required <small>(useful for linting docker compose/stack files)</small>
|
||||||
|
|
||||||
<sup>\*</sup> = required
|
<sup>\*</sup> = required
|
||||||
|
|
||||||
For Debian and similar apt-powered systems: `apt install bash curl jq`
|
|
||||||
|
|
||||||
### Docker image and variants
|
### Docker image and variants
|
||||||
|
|
||||||
If you don't want or can't install `psu` and its dependencies, you can run it with the default [published Docker image](https://hub.docker.com/r/psuapp/psu), like this:
|
If you don't want or can't install `psu` and its dependencies, you can run it with the default [published Docker image](https://hub.docker.com/r/psuapp/psu), like this:
|
||||||
@ -246,3 +268,19 @@ For detailed instructions, see the [CLI Commands](docs/README.md) documentation.
|
|||||||
Source code contained by this project is licensed under the [GNU General Public License version 3](https://www.gnu.org/licenses/gpl-3.0.en.html).
|
Source code contained by this project is licensed under the [GNU General Public License version 3](https://www.gnu.org/licenses/gpl-3.0.en.html).
|
||||||
|
|
||||||
See [LICENSE](LICENSE) file for reference.
|
See [LICENSE](LICENSE) file for reference.
|
||||||
|
|
||||||
|
[Linux]: https://kernel.org
|
||||||
|
[Alpine]: https://alpinelinux.org
|
||||||
|
[Debian]: https://debian.org
|
||||||
|
[Ubuntu]: https://ubuntu.com/
|
||||||
|
[macOS]: https://apple.com/macos
|
||||||
|
[Homebrew]: https://brew.sh
|
||||||
|
[coreutils]: https://formulae.brew.sh/formula/coreutils
|
||||||
|
[Windows]: https://microsoft.com/windows
|
||||||
|
[bash]: https://www.gnu.org/software/bash
|
||||||
|
[curl]: https://curl.se
|
||||||
|
[jq]: https://stedolan.github.io/jq
|
||||||
|
[timeout]: https://man7.org/linux/man-pages/man1/timeout.1.html
|
||||||
|
[uuidgen]: https://man7.org/linux/man-pages/man1/uuidgen.1.html
|
||||||
|
[docker-compose]: https://docs.docker.com/compose/install
|
||||||
|
[git]: https://git-scm.com/
|
18
psu
18
psu
@ -170,7 +170,7 @@ main() {
|
|||||||
echo "$services"
|
echo "$services"
|
||||||
else
|
else
|
||||||
# Only display service(s) name in quiet mode
|
# Only display service(s) name in quiet mode
|
||||||
echo "$services" | jq -r '.[] | [.Spec.Name] | add'
|
echo "$services" | jq -r '.[] | [.Spec.Name] | add' | tr -d '\r'
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -229,7 +229,7 @@ main() {
|
|||||||
echo "$tasks"
|
echo "$tasks"
|
||||||
else
|
else
|
||||||
# Only display task(s) id in quiet mode
|
# Only display task(s) id in quiet mode
|
||||||
echo "$tasks" | jq -r '.[] | [.ID] | add'
|
echo "$tasks" | jq -r '.[] | [.ID] | add' | tr -d '\r'
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -248,7 +248,7 @@ main() {
|
|||||||
echo "$containers"
|
echo "$containers"
|
||||||
else
|
else
|
||||||
# Only display container(s) id in quiet mode
|
# Only display container(s) id in quiet mode
|
||||||
echo "$containers" | jq -r '.[] | [.Id] | add'
|
echo "$containers" | jq -r '.[] | [.Id] | add' | tr -d '\r'
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -277,7 +277,7 @@ main() {
|
|||||||
echo "$STACKS"
|
echo "$STACKS"
|
||||||
else
|
else
|
||||||
# Only display stack names in quiet mode
|
# Only display stack names in quiet mode
|
||||||
echo "$STACKS" | jq -r '.[] | [.Name] | add'
|
echo "$STACKS" | jq -r '.[] | [.Name] | add' | tr -d '\r'
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -912,7 +912,7 @@ unique_temp_file_path() {
|
|||||||
if [ -w "$temp_path" ]; then
|
if [ -w "$temp_path" ]; then
|
||||||
local file_uuid
|
local file_uuid
|
||||||
# Generate universally unique identifier (UUID)
|
# Generate universally unique identifier (UUID)
|
||||||
file_uuid=$(if [ -x "$(command -v uuidgen)" ]; then uuidgen; else cat /proc/sys/kernel/random/uuid; fi)
|
file_uuid=$(if [ -x "$(command -v uuidgen)" ]; then uuidgen; else cat /proc/sys/kernel/random/uuid 2> /dev/null || od -vAn -N4 -t u4 < /dev/urandom | tr -d ' '; fi)
|
||||||
if [ -z "$file_uuid" ]; then
|
if [ -z "$file_uuid" ]; then
|
||||||
echo_error "You must install the 'uuidgen' program, to generate universally unique identifier"
|
echo_error "You must install the 'uuidgen' program, to generate universally unique identifier"
|
||||||
exit 1
|
exit 1
|
||||||
@ -1340,11 +1340,13 @@ lint() {
|
|||||||
###################################################
|
###################################################
|
||||||
env_file_to_json() {
|
env_file_to_json() {
|
||||||
local jq_command
|
local jq_command
|
||||||
|
local sh_command
|
||||||
|
|
||||||
# For macOS compatibility
|
# For macOS and Windows compatibility
|
||||||
jq_command="$(which jq)"
|
jq_command="$(command -v jq)"
|
||||||
|
sh_command="$(command -v sh)"
|
||||||
|
|
||||||
env -i sh -c "(unset \$(env | sed 's/=.*//'); set -a; . $(readlink_wrapper -f $ENVIRONMENT_VARIABLES_FILE); set +a; \"$jq_command\" -njc 'env | to_entries | map({name: .key, value: .value})')"
|
env -i "$sh_command" -c "(unset \$(env | sed 's/=.*//'); set -a; . $(readlink_wrapper -f $ENVIRONMENT_VARIABLES_FILE); set +a; \"$jq_command\" -njc 'env | to_entries | map({name: .key, value: .value})')"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set the ACTIONS variable who's a list of all psu actions
|
# Set the ACTIONS variable who's a list of all psu actions
|
||||||
|
@ -15,11 +15,11 @@ fi
|
|||||||
|
|
||||||
SWARM_NODE_NAME=${SWARM_NODE_NAME:-cluster}
|
SWARM_NODE_NAME=${SWARM_NODE_NAME:-cluster}
|
||||||
SWARM_NODE_IP=${SWARM_NODE_IP:-$(getent hosts "${SWARM_NODE_NAME}" | awk '{ print $1 }')}
|
SWARM_NODE_IP=${SWARM_NODE_IP:-$(getent hosts "${SWARM_NODE_NAME}" | awk '{ print $1 }')}
|
||||||
export BASE_DOMAIN="$SWARM_NODE_IP.nip.io"
|
export BASE_DOMAIN=${SWARM_NODE_IP}.nip.io
|
||||||
export PSU_STACK_NAME="web-app"
|
export PSU_STACK_NAME="web-app"
|
||||||
PSU_URL="https://portainer.$BASE_DOMAIN"
|
PSU_URL="${PSU_URL:-"https://portainer.${BASE_DOMAIN}"}"
|
||||||
PSU_USER="admin"
|
PSU_USER="${PSU_USER:-admin}"
|
||||||
PSU_PASSWORD=${PSU_PASSWORD:-"$(openssl rand -hex 50)"}
|
PSU_PASSWORD="${PSU_PASSWORD:-"$(openssl rand -hex 50)"}"
|
||||||
|
|
||||||
PSU_TAG=$(if [ -n "$PSU_TAG" ]; then
|
PSU_TAG=$(if [ -n "$PSU_TAG" ]; then
|
||||||
eval echo "$PSU_TAG";
|
eval echo "$PSU_TAG";
|
||||||
|
Loading…
Reference in New Issue
Block a user