Skip to content

Commit

Permalink
Add support for unRAID 6.10; add some docs on how to develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zb140 committed May 18, 2022
1 parent d452656 commit 9e28b84
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 106 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/build-uinput.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
-e UNRAID_VERSION=${{ matrix.unraid_version }}
shell: bash
run: /opt/scripts/build.sh

- name: get built kernel version
id: kernel-version
run: echo "::set-output name=kernel::$(ls ${{ github.workspace }}/packages/uinput/root/lib/modules/)"
Expand All @@ -41,16 +41,26 @@ jobs:
name: uinput-${{ steps.kernel-version.outputs.kernel }}.txz
path: ${{ github.workspace }}/output/uinput-${{ steps.kernel-version.outputs.kernel }}.txz

- name: generate checksum
- name: generate checksum (md5)
id: checksum
run: md5sum ${{ github.workspace }}/output/uinput-${{ steps.kernel-version.outputs.kernel }}.txz > ${{ github.workspace }}/output/uinput-${{ steps.kernel-version.outputs.kernel }}.txz.md5

- name: Upload checksum for ${{ steps.kernel-version.outputs.kernel }}
- name: Upload checksum for ${{ steps.kernel-version.outputs.kernel }} (md5)
uses: actions/upload-artifact@v2
with:
name: uinput-${{ steps.kernel-version.outputs.kernel }}.txz.md5
path: ${{ github.workspace }}/output/uinput-${{ steps.kernel-version.outputs.kernel }}.txz.md5

- name: generate checksum (sha256)
id: checksum
run: sha256sum ${{ github.workspace }}/output/uinput-${{ steps.kernel-version.outputs.kernel }}.txz > ${{ github.workspace }}/output/uinput-${{ steps.kernel-version.outputs.kernel }}.txz.sha256

- name: Upload checksum for ${{ steps.kernel-version.outputs.kernel }} (sha256)
uses: actions/upload-artifact@v2
with:
name: uinput-${{ steps.kernel-version.outputs.kernel }}.txz.sha256
path: ${{ github.workspace }}/output/uinput-${{ steps.kernel-version.outputs.kernel }}.txz.sha256

release:
needs: docker-build
runs-on: ubuntu-latest
Expand All @@ -62,7 +72,7 @@ jobs:

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%d.%m.%Y')"
run: echo "::set-output name=date::$(date +'%Y.%m.%d')"

- uses: ncipollo/release-action@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-dist/
42 changes: 42 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Developer How-To

## Prerequisites

unRAID installs plugins from an HTTP server, so in order to install your locally-modified version you'll need some way to serve the files over HTTP. There is no HTTP server included with this distribution, but several popular development environments include an easy way to launch one.

1. NodeJS. This is the one I use. Just run `npx http-server` in the top level of the plugin repo (the directory that contains this file). This will serve the files at `http://[your ip address]:8080/`.
2. Python (3+). This is untested, but it should work. Run `python -m http.server 8080` and the files will (should) be available at `http://[your ip address]:8080/`.

## Getting Started

Open up [`gow.plg`](gow.plg) and change the `gitPkgURL` entity to point to `http://[your ip address]:8080`. Be sure to use the IP address of the system you're doing the dev work on; this may not necessarily be your unRAID server. It should _not_ end with a trailing slash. Also change the `gitReleaseURL` entity to `http://[your ip address]:8080/package-dist`. It should likewise have no trailing slash.

The majority of the functionality of this plugin is implemented in various "packages" (see the `packages/` directory); this provides a convenient mechanism to break the work down into manageable chunks with a standardized way of installing, uninstalling, reloading after reboot, etc.

Installing and uninstalling packages is managed by the [`preinstall.sh`](scripts/preinstall.sh), [`install.sh`](scripts/install.sh), and [`uninstall.sh`](scripts/uninstall.sh) scripts. Any time you modify one of these, you'll need to update the MD5 and SHA256 hashes in [`gow.plg`](gow.plg). The SHA256 hash takes precedence if both exist, but the MD5 hash is left in for older versions of unRAID. (TODO: it's possible we don't need these anymore)

Now it's time to try installing your development version of the plugin. Open a terminal on your unRAID server and uninstall the old version of GoW (if you have one installed), then install the new version:
```sh
$ plugin remove gow.plg
$ plugin install http://[your ip address]:8080/gow.plg
```

## How to add a new package

1. Create a new directory under `packages/`, let's say `packages/new-pkg`.
2. In `packages/new-pkg`, add a file called `root/install/slack-desc`. It's easiest to copy an existing one and modify it.
3. Build any directory structure you like under `root/`. Any files you add will be automatically installed in their corresponding places under `/` when the plugin is installed or reloaded after reboot.
4. If your new package needs to perform any actions on start or stop, add a shell script in `root/boot/config/plugins/gow/scripts/start/new-pkg.sh` or `root/boot/config/plugins/gow/scripts/stop/new-pkg.sh`. `start` corresponds to when the plugin is installed or reloaded after reboot, while `stop` is when the plugin is uninstalled.

## How to build a package

Packages are built using the [`utils/fmakepkg.sh`](utils/fmakepkg.sh) script. For the purposes of these steps, we'll assume the name of the package you're building is `your-pkg`.

1. Make a directory at the top level called `package-dist` to hold packages while you're working on them.
2. `cd` to `packages/your-pkg/root`.
3. Run `../../../utils/fmakepkg.sh ../../../package-dist/your-pkg.txz`.
4. `cd` to `../../../package-dist`.
5. Generate `your-pkg.txz.md5` and `your-pkg.txz.sha256`.
6. Uninstall and reinstall the plugin as above to pick up the new package.


6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A plugin for running Games on Whales on Unraid
## Important Note

This plugin is still a work in progress. While several people have found it
useful, it is still at least theoretically possible it could be issues with it;
useful, it is still at least theoretically possible there could be issues with it;
possibly even issues that we don't know how to help you fix. Having said that,
it doesn't do anything permanent to your system, so uninstalling the plugin
should be a good last-resort solution.
Expand All @@ -29,3 +29,7 @@ and press `INSTALL`
success!
plugin: gow.plg installed
```

## Developer Notes

See [DEVELOPING.md](DEVELOPING.md)
47 changes: 40 additions & 7 deletions gow.plg
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
<!ENTITY name "gow">
<!ENTITY author "zb140">
<!ENTITY org "games-on-whales">
<!ENTITY version "2021.12.29">
<!ENTITY version "2022.05.18">
<!ENTITY launch "Settings/gow">
<!ENTITY gitURL "https://github.com/&org;/unraid-plugin/raw/main">
<!ENTITY gitPkgURL "https://github.com/&org;/unraid-plugin/raw/&version;">
<!ENTITY gitReleaseBaseURL "https://github.com/&org;/unraid-plugin/releases/download">
<!ENTITY gitModReleaseURL "&gitReleaseBaseURL;/modules-&version;">
<!ENTITY gitReleaseURL "&gitReleaseBaseURL;/&version;">
<!ENTITY gowGitUrl "https://github.com/&org;/gow/raw/master">
<!ENTITY pluginURL "&gitURL;/&name;.plg">
<!ENTITY plugin "/boot/config/plugins/&name;">
<!ENTITY emhttp "/usr/local/emhttp/plugins/&name;">
Expand All @@ -20,11 +24,14 @@
launch="&launch;"
pluginURL="&pluginURL;"
min="6.9.2"
max="6.10.0-rc2"
max="6.10.0"
support="https://discord.gg/kRGUDHNHt2"
>

<CHANGES>
### 2022.05.18
- Add support for unRAID 6.10.0

### 2021.12.29
- Add support for pre-release versions of unRAID
- Automatically download 32-bit drivers if an NVIDIA card is detected (used for Steam)
Expand Down Expand Up @@ -61,6 +68,10 @@ export GOW_VERSION="&version;"
export GOW_LAUNCH="&launch;"
export GOW_GITURL="&gitURL;"
export GOW_GITPKGURL="&gitPkgURL;"
export GOW_GITMODRELEASEURL="&gitModReleaseURL;"
export GOW_GITRELEASEURL="&gitReleaseURL;"
export GOW_GITRELEASEBASEURL="&gitReleaseBaseURL;"
export GOW_GOWGITURL="&gowGitUrl;"
export GOW_PLUGINURL="&pluginURL;"
export GOW_PLUGIN="&plugin;"
export GOW_EMHTTP="&emhttp;"
Expand All @@ -70,22 +81,44 @@ export GOW_PACKAGES="kernel/uinput common/settings-ui nvidia/32-bit-drivers"
<!-- Bash script to download and install the drivers and utilities -->
<FILE Name="&script_dir;/install.sh">
<URL>&gitPkgURL;/scripts/install.sh</URL>
<MD5>485cce35f36abe521b056457276967f4</MD5>
<SHA256>0fdebb7e626327fb026c819d18057d8af44e26b80ae56e20f68bf93dfee5affb</SHA256>
<MD5>2e399109aa6086706502cdbea5648250</MD5>
</FILE>

<!-- Bash script to check preconditions before installing -->
<FILE Name="&script_dir;/preinstall.sh">
<URL>&gitPkgURL;/scripts/preinstall.sh</URL>
<SHA256>e7a129f30184a97ab52dfe6552a0758a7552ae3088f75c34f7eee8df1aee96b9</SHA256>
<MD5>6d35001f8dc6284b39dfee6c753875dd</MD5>
</FILE>

<!-- Bash script to uninstall -->
<FILE Name="&script_dir;/uninstall.sh">
<URL>&gitPkgURL;/scripts/uninstall.sh</URL>
<MD5>fbcf2cf99bd6907b41f155639b96b649</MD5>
<SHA256>693c3f9dfa8d71aae4053883566b5ecc061d40afa592e16dcdc6af637ad4cb47</SHA256>
<MD5>c59b2a488fbe5946b88415216c12e6d1</MD5>
</FILE>

<!-- Utilities used by the other scripts -->
<FILE Name="&script_dir;/utils.sh">
<URL>&gitPkgURL;/scripts/utils.sh</URL>
<SHA256>02eb913cb5e26e3de172a5b0e7ea05325d7c2b603b801cde899dd9a3d72910fe</SHA256>
<MD5>d385111e4d1ef7b1930942811178b29f</MD5>
</FILE>

<FILE Run="/bin/bash">
<INLINE>
echo "╔════════════════════════════╗"
echo "║ Installing Games on Whales ║"
echo "╚════════════════════════════╝"
cd &script_dir;
if ! bash ./preinstall.sh; then
echo "preconditions not met; not installing"
rm -rf &plugin;
exit 1
fi

if ! bash ./install.sh; then
echo "╔════════════════════════════╗"
echo "║ Installing Games on Whales ║"
echo "╚════════════════════════════╝"
echo "error while installing, cleaning up"
rm -rf &plugin;
exit 1
Expand Down
80 changes: 17 additions & 63 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/bin/bash

source vars.sh

KV="$(uname -r)"
KERNEL_VER=${KV%%-*}

PACKAGE_DIR="$GOW_PLUGIN/packages"
source utils.sh

KERNEL_PKG_DIR="$PACKAGE_DIR/$KERNEL_VER"
COMMON_PKG_DIR="$PACKAGE_DIR/$GOW_VERSION"
Expand All @@ -17,88 +13,46 @@ for dir in $KERNEL_PKG_DIR $COMMON_PKG_DIR; do
done

function wait_for_network() {
HOST=8.8.8.8
local host=8.8.8.8
for i in {1..30}; do
ping -c1 $HOST &>/dev/null && return 0
ping -c1 $host &>/dev/null && return 0
done

return 1
}

function pkg_name() {
PACKAGE_NAME=${1/kernel\//$KERNEL_VER\/}
PACKAGE_NAME=${PACKAGE_NAME/common\//$GOW_VERSION\/}
PACKAGE_NAME=${PACKAGE_NAME/nvidia\//$GOW_VERSION\/}

echo "$PACKAGE_NAME"
}

function pkg_file() {
PACKAGE_NAME=$(pkg_name "$1")

echo "$PACKAGE_DIR/$PACKAGE_NAME.txz"
}

function pkg_url() {
name=$1
PACKAGE_NAME=$(pkg_name "$name")

if [[ $name == kernel/* ]]; then
echo "$GOW_GITPKGURL/kernel-bin/$PACKAGE_NAME.txz"
else
echo "https://github.com/games-on-whales/unraid-plugin/releases/download/$PACKAGE_NAME.txz"
fi
}

function download_pkg() {
PACKAGE_FILE=$(pkg_file "$1")
PACKAGE_URL=$(pkg_url "$1")

echo "Downloading $PACKAGE_URL"

if wget -q -nc --show-progress --progress=bar:force:noscroll -O "$PACKAGE_FILE" "$PACKAGE_URL"; then
if [ "$(md5sum "$PACKAGE_FILE" | cut -d ' ' -f1)" != "$(wget -qO- "$PACKAGE_URL.md5" | cut -d ' ' -f1)" ]; then
echo "ERROR: Checksum mismatch for $PACKAGE_URL"
return 1
fi
else
echo "ERROR: Unable to download $PACKAGE_URL"
return 1
fi
}

function ensure_pkg() {
PACKAGE_NAME=$1
PACKAGE_FILE=$(pkg_file "$PACKAGE_NAME")
local package_name=$1
local package_file=$(pkg_file "$package_name")

# if it doesn't exist, download it
if [ ! -f "$PACKAGE_FILE" ] || [ ! -s "$PACKAGE_FILE" ]; then
rm -f "$PACKAGE_FILE"
if ! download_pkg "$PACKAGE_NAME"; then
if [ ! -f "$package_file" ] || [ ! -s "$package_file" ]; then
rm -f "$package_file"
if ! download_pkg "$package_name"; then
return 1
fi
fi
}

function install_pkg() {
PACKAGE_FILE=$(pkg_file "$1")
local package_file=$(pkg_file "$1")

echo "Installing: $PACKAGE_FILE"
/sbin/installpkg "$PACKAGE_FILE"
echo "Installing: $package_file"
/sbin/installpkg "$package_file"
}

function start_pkg() {
# strip everything before the first slash. start/stop scripts are versioned
# with the plugin, so they don't need the version in their filename.
NAME=${1#*/}
local name=${1#*/}

echo "attempting to start $NAME"
echo "attempting to start $name"

START_SCRIPT="$GOW_PLUGIN/scripts/start/$NAME.sh"
local start_script="$GOW_PLUGIN/scripts/start/$name.sh"

if [ -f "$START_SCRIPT" ]; then
echo "executing $START_SCRIPT"
bash "$START_SCRIPT"
if [ -f "$start_script" ]; then
echo "executing $start_script"
bash "$start_script"
fi
}

Expand Down
35 changes: 35 additions & 0 deletions scripts/preinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

source vars.sh

# What kind of GPUs do we have?
has_nvidia=false
has_non_nvidia=false

if command -v lshw >/dev/null 2>&1; then
while read line; do
if [[ ${line,,} =~ nvidia ]]; then
has_nvidia=true
else
has_non_nvidia=true
fi
done < <(lshw -C display 2>/dev/null | grep vendor)
fi

if [[ "$has_nvidia" = "true" && ! -f /boot/config/plugins/nvidia-driver.plg ]]; then
if [ "$has_non_nvidia" = "true" ]; then
# This user has both NVIDIA and non-NVIDIA cards, so don't prevent
# installation, but provide a warning.
echo "╔══════════╗"
echo "║ WARNING! ║"
echo "╚══════════╝"
echo "Using Games on Whales with an NVIDIA GPU requires the Nvidia-Driver plugin, but you don't have it installed. If you want to use your NVIDIA GPU, please install Nvidia-Driver from Community Applications."
else
# This user only has NVIDIA GPUs, so it's an error to install GoW without the Nvidia-Driver plugin.
echo "╔════════╗"
echo "║ ERROR! ║"
echo "╚════════╝"
echo "Games on Whales requires the Nvidia-Driver plugin. Please install it from Community Applications and try again."
exit 1
fi
fi
Loading

0 comments on commit 9e28b84

Please sign in to comment.