Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Proposal : Going version-less on Plex #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions check_process

This file was deleted.

7 changes: 0 additions & 7 deletions conf/app-amd64.src

This file was deleted.

7 changes: 0 additions & 7 deletions conf/app-arm64.src

This file was deleted.

7 changes: 0 additions & 7 deletions conf/app-armhf.src

This file was deleted.

7 changes: 0 additions & 7 deletions conf/app-i386.src

This file was deleted.

58 changes: 0 additions & 58 deletions manifest.json

This file was deleted.

51 changes: 51 additions & 0 deletions manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json

packaging_format = 2

id = "plexmediaserver"
name = "PlexMediaServer"
description.en = "PlexMediaServer package for YunoHost"
description.fr = "PlexMediaServer pour YunoHost"

version = "2.0~ynh1"

maintainers = ["liberodark", "UnicodeApocalypse"]

[upstream]
license = "non-free"
website = "http://plex.tv/"
userdoc = "https://support.plex.tv/articles/"

[integration]
yunohost = ">= 11.1.15"
architectures = "all"
multi_instance = false
ldap = false
sso = false

[install]
[install.domain]
type = "domain"

[install.path]
type = "path"
default = "/web"

[install.admin]
type = "user"

[install.is_public]
help.en = "Should Plex be publicly accessible?"
help.fr = "Plex doit-il être publiquement accessible ?"
type = "boolean"
default = false

[resources]
[resources.apt]
packages = ["jq"]

[resources.permissions]
main.url = "/"

[resources.ports]
main.default = 32400
52 changes: 39 additions & 13 deletions scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ path_url=$(ynh_normalize_url_path "$path_url")

# Check web path availability
ynh_webpath_available "$domain" "$path_url"
# Register (book) web path
ynh_webpath_register "$app" "$domain" "$path_url"


#=================================================
# STORE SETTINGS FROM MANIFEST
Expand All @@ -69,7 +68,7 @@ ynh_app_setting_set "$app" is_public "$is_public"
#=================================================
# FIND AND OPEN A PORT
#=================================================

ynh_script_progression --message="Configuring ports..."
### Use these lines if you have to open a port for the application
### `ynh_find_port` will find the first available port starting from the given port.
### If you're not using these lines:
Expand All @@ -85,24 +84,51 @@ ynh_app_setting_set "$app" port "$port"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Fetching Plex releases..."

# Get the machine architecture
arch=$(uname -m)

# Check the architecture and set variable accordingly
if [ "$arch" = "x86_64" ]; then
BUILD="linux-x86_64"
elif [ "$arch" = "i386" ]; then
BUILD="linux-x86"
elif [ "$arch" = "aarch64" ]; then
BUILD="linux-aarch64"
elif [ "$arch" = "armv7l" ]; then
BUILD="linux-armv7neon"
else
ynh_die "Your arch doesn't have a debian-compatible Plex release"
fi

# Fetch releases from Plex
PLEX_INDEX=$(curl -s https://plex.tv/pms/downloads/5.json);
SOURCE_URL=$(echo $PLEX_INDEX | jq -r ".computer.Linux.releases[] | select(.distro == \"debian\" and .build == \"$BUILD\") | .url");
DEB_FILE="$final_path/plexmediaserver.deb";

ynh_script_progression --message="Downloading PlexMediaManager..."
ynh_app_setting_set "$app" final_path "$final_path"
mkdir -p "$final_path"
wget --tries 3 --no-dns-cache --timeout 900 --no-verbose --output-document=$DEB_FILE $SOURCE_URL 2>&1

# Verifying checksum
SOURCE_SUM=$(echo $PLEX_INDEX | jq -r ".computer.Linux.releases[] | select(.distro == \"debian\" and .build == \"$BUILD\") | .checksum");
ACTUAL_SUM=$(sha1sum $DEB_FILE | cut -c 1-40)

# Download, check integrity, uncompress and patch the source from app-[arch].src
case $(uname -m) in
i386) ynh_setup_source "$final_path" "app-i386" ;;
x86_64) ynh_setup_source "$final_path" "app-amd64" ;;
aarch64) ynh_setup_source "$final_path" "app-arm64" ;;
armv7l) ynh_setup_source "$final_path" "app-armhf" ;;
*) ynh_die "Unknown arch" ;;
esac
if [ "$SOURCE_SUM" != "$ACTUAL_SUM" ]
then
rm -f "$DEB_FILE"
ynh_die --message="Download file have incorrect checksum. Aborting."
fi

#==============================================
# INSTALL PLEX
#==============================================
ynh_script_progression --message="Installing PlexMediaManager..."

dpkg --install "$final_path"/plexmediaserver.deb
rm -f "$final_path"/plexmediaserver.deb
dpkg --install $DEB_FILE
rm -f $DEB_FILE

#=================================================
# NGINX CONFIGURATION
Expand Down
43 changes: 34 additions & 9 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,47 @@ systemctl stop plexmediaserver
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================

# Get the machine architecture
arch=$(uname -m)

# Check the architecture and set variable accordingly
if [ "$arch" = "x86_64" ]; then
BUILD="linux-x86_64"
elif [ "$arch" = "i386" ]; then
BUILD="linux-x86"
elif [ "$arch" = "aarch64" ]; then
BUILD="linux-aarch64"
elif [ "$arch" = "armv7l" ]; then
BUILD="linux-armv7neon"
else
ynh_die "Your arch doesn't have a debian-compatible Plex release"
fi

# Fetch releases from Plex
PLEX_INDEX=$(curl -s https://plex.tv/pms/downloads/5.json);
SOURCE_URL=$(echo $PLEX_INDEX | jq -r ".computer.Linux.releases[] | select(.distro == \"debian\" and .build == \"$BUILD\") | .url");
DEB_FILE="$final_path/plexmediaserver.deb";

ynh_script_progression --message="Downloading PlexMediaManager..."
ynh_app_setting_set "$app" final_path "$final_path"
mkdir -p "$final_path"
wget --tries 3 --no-dns-cache --timeout 900 --no-verbose --output-document=$DEB_FILE $SOURCE_URL 2>&1

# Download, check integrity, uncompress and patch the source from app-[arch].src
case $(uname -m) in
i386) ynh_setup_source "$final_path" "app-i386" ;;
x86_64) ynh_setup_source "$final_path" "app-amd64" ;;
aarch64) ynh_setup_source "$final_path" "app-arm64" ;;
armv7l) ynh_setup_source "$final_path" "app-armhf" ;;
*) ynh_die "Unknown arch" ;;
esac
# Verifying checksum
SOURCE_SUM=$(echo $PLEX_INDEX | jq -r ".computer.Linux.releases[] | select(.distro == \"debian\" and .build == \"$BUILD\") | .checksum");
ACTUAL_SUM=$(sha1sum $DEB_FILE | cut -c 1-40)

if [ "$SOURCE_SUM" != "$ACTUAL_SUM" ]
then
rm -f "$DEB_FILE"
ynh_die --message="Download file have incorrect checksum. Aborting."
fi

#==============================================
# INSTALL PLEX
#==============================================

dpkg --install "$final_path"/plexmediaserver*
dpkg --install $DEB_FILE

#=================================================
# NGINX CONFIGURATION
Expand Down