Skip to content

Commit

Permalink
chore: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hlhr202 committed Apr 14, 2024
1 parent 29174ac commit 93f499f
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 13 deletions.
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This is a cross-platform GUI client for OpenConnect, written in Rust and designe
<img src="./doc/screenshot/openconnect-2.png" width="360px" height="320px" alt="Edit">
<img src="./doc/screenshot/openconnect-3.png" width="360px" height="320px" alt="Connect">

## Installation
## Installation of Client

- GUI:

Expand All @@ -37,6 +37,59 @@ This is a cross-platform GUI client for OpenConnect, written in Rust and designe
curl -sL https://raw.githubusercontent.com/hlhr202/Openconnect-RS/main/install-cli.sh | sh
```

## Usage of CLI client

- Run the following command in your terminal:

```bash
openconnect --help
```

This will print the following help message:

```plaintext
A CLI client to connect to VPN using OpenConnect
Usage: openconnect <COMMAND>
Commands:
start Connect to a VPN server and run in daemon mode [aliases: connect, run]
status Get the current VPN connection status [aliases: info, stat]
stop Close the current connection and exit the daemon process [aliases: kill, disconnect]
add Add new VPN server configuration to local config file [aliases: new, create, insert]
delete Delete a VPN server configuration from local config file [aliases: rm, remove, del]
list List all VPN server configurations in local config file [aliases: ls, l]
logs Show logs of the daemon process [aliases: log]
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
```

- For each subcommand, you can run `openconnect <COMMAND> --help` to get more information

For example:

```bash
openconnect start --help
```

This will print the following help message:

```plaintext
Connect to a VPN server and run in daemon mode
Usage: openconnect start [OPTIONS] <NAME>
Arguments:
<NAME> The server name saved in local config file to connect to
Options:
-c, --config-file <CONFIG_FILE> The path to the local config file
-h, --help Print help
```

## Build

- Read the [System Requirements](./crates/openconnect-sys/README.md) for environment setup
Expand Down
59 changes: 47 additions & 12 deletions install-cli.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
# Installation script for Openconnect CLI
# This script will download the Openconnect CLI and vpnc-script and install them in $HOME/.oidcvpn/bin
#!/bin/sh
# Installation script for Openconnect-RS CLI
# This script will download the Openconnect-RS CLI and vpnc-script and install them in $HOME/.oidcvpn/bin
# It will also add $HOME/.oidcvpn/bin to PATH
# Usage:
# curl -s -L URL_TO_SCRIPT_HERE | sh

COLOR_PRIMARY="\033[0;34m"
COLOR_WARN="\033[1;33m"
COLOR_SUCCESS="\033[0;32m"
COLOR_RESET="\033[0m"

echo ""
echo "=================================="
echo ""
echo "${COLOR_PRIMARY}Installing Openconnect-RS CLI${COLOR_RESET}"
echo ""
echo ""
echo "This script will download the Openconnect CLI and vpnc-script and install them in $HOME/.oidcvpn/bin"
echo "${COLOR_WARN}WARNING: Openconnect-RS CLI has the same installed binary name as the original Openconnect CLI."
echo "Please remove the original Openconnect CLI if you wish to use Openconnect-RS CLI.${COLOR_RESET}"
echo ""
echo "=================================="
echo ""

# shut down if openconnect is running
if pgrep -x "openconnect" > /dev/null
then
echo "Openconnect is running. Please shut it down before installing Openconnect-RS CLI"
exit 1
fi

CLI_DOWNLOAD_URL=""
VPNC_SCRIPT_URL="https://gitlab.com/openconnect/vpnc-scripts/raw/master/vpnc-script"

Expand All @@ -12,11 +38,9 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
# detect arch
if [[ "$HOSTTYPE" == "x86_64" ]]; then
# install macos cli
echo "installing macos cli for x86_64"
CLI_DOWNLOAD_URL="https://github.com/hlhr202/Openconnect-RS/releases/download/v0.0.0-pre1/openconnect-cli_osx-x86_64"
elif [[ "$HOSTTYPE" == "arm64" ]]; then
# install macos cli
echo "installing macos cli for arm64"
CLI_DOWNLOAD_URL="https://github.com/hlhr202/Openconnect-RS/releases/download/v0.0.0-pre1/openconnect-cli_osx-aarch64"
else
echo "unsupported arch"
Expand All @@ -25,7 +49,6 @@ if [[ "$OSTYPE" == "darwin"* ]]; then

elif [[ "$OSTYPE" == "linux-gnu" ]]; then
if [[ "$HOSTTYPE" == "x86_64" ]]; then
echo "installing linux cli"
CLI_DOWNLOAD_URL="https://github.com/hlhr202/Openconnect-RS/releases/download/v0.0.0-pre1/openconnect-cli_linux-x86_64"
else
echo "unsupported arch"
Expand All @@ -43,18 +66,26 @@ if [ ! -d "$HOME/.oidcvpn/bin" ]; then
fi

# download cli
echo "Downloading cli"
echo "${COLOR_PRIMARY}Downloading cli${COLOR_RESET}"
echo ""
curl -L $CLI_DOWNLOAD_URL >$HOME/.oidcvpn/bin/openconnect
chmod +x $HOME/.oidcvpn/bin/openconnect
echo ""
echo "=================================="
echo ""

# download vpnc-script
echo "Downloading vpnc-script"
echo "${COLOR_PRIMARY}Downloading vpnc-script${COLOR_RESET}"
echo ""
curl -L $VPNC_SCRIPT_URL >$HOME/.oidcvpn/bin/vpnc-script
chmod +x $HOME/.oidcvpn/bin/vpnc-script
echo ""
echo "=================================="
echo ""

# add .oidcvpn/bin to PATH
echo "Checking if .oidcvpn/bin is in PATH"

echo "${COLOR_PRIMARY}Adding .oidcvpn/bin to PATH${COLOR_RESET}"
echo ""
if [[ ":$PATH:" != *":$HOME/.oidcvpn/bin:"* ]]; then

echo "Adding .oidcvpn/bin to PATH"
Expand All @@ -74,8 +105,12 @@ if [[ ":$PATH:" != *":$HOME/.oidcvpn/bin:"* ]]; then
echo "Run source $HOME/.zshrc to apply changes"
fi

echo "If you are using shell other than bash or zsh, please add the following line to your shell profile:"
echo "export PATH=\$PATH:$HOME/.oidcvpn/bin"
fi
echo "If you are using shell other than bash or zsh, please add the following line to your shell profile:"
echo "export PATH=\$PATH:$HOME/.oidcvpn/bin"

echo ""
echo "=================================="
echo ""

echo "Installation complete"
echo "${COLOR_SUCCESS}Installation complete!${COLOR_RESET}"

0 comments on commit 93f499f

Please sign in to comment.