-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update readme, add first commit files
- Loading branch information
Showing
12 changed files
with
609 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
###################################################################### | ||
# List of available definitions (it's not necessary to uncomment them) | ||
###################################################################### | ||
###### Command definitions ##### | ||
#CMD_AWK="/bin/awk" | ||
#CMD_CAT="/bin/cat" | ||
#CMD_CHMOD="/bin/chmod" | ||
#CMD_CHOWN="/bin/chown" | ||
#CMD_CP="/bin/cp" | ||
#CMD_CUT="/bin/cut" | ||
#CMD_DATE="/bin/date" | ||
#CMD_ECHO="/bin/echo" | ||
#CMD_EXPR="/usr/bin/expr" | ||
#CMD_FIND="/usr/bin/find" | ||
#CMD_GETCFG="/sbin/getcfg" | ||
#CMD_GREP="/bin/grep" | ||
#CMD_GZIP="/bin/gzip" | ||
#CMD_HOSTNAME="/bin/hostname" | ||
#CMD_LN="/bin/ln" | ||
#CMD_LOG_TOOL="/sbin/log_tool" | ||
#CMD_MD5SUM="/bin/md5sum" | ||
#CMD_MKDIR="/bin/mkdir" | ||
#CMD_MV="/bin/mv" | ||
#CMD_RM="/bin/rm" | ||
#CMD_RMDIR="/bin/rmdir" | ||
#CMD_SED="/bin/sed" | ||
#CMD_SETCFG="/sbin/setcfg" | ||
#CMD_SLEEP="/bin/sleep" | ||
#CMD_SORT="/usr/bin/sort" | ||
#CMD_SYNC="/bin/sync" | ||
#CMD_TAR="/bin/tar" | ||
#CMD_TOUCH="/bin/touch" | ||
#CMD_WGET="/usr/bin/wget" | ||
#CMD_WLOG="/sbin/write_log" | ||
#CMD_XARGS="/usr/bin/xargs" | ||
#CMD_7Z="/usr/local/sbin/7z" | ||
# | ||
###### System definitions ##### | ||
#SYS_EXTRACT_DIR="$(pwd)" | ||
#SYS_CONFIG_DIR="/etc/config" | ||
#SYS_INIT_DIR="/etc/init.d" | ||
#SYS_STARTUP_DIR="/etc/rcS.d" | ||
#SYS_SHUTDOWN_DIR="/etc/rcK.d" | ||
#SYS_RSS_IMG_DIR="/home/httpd/RSS/images" | ||
#SYS_QPKG_DATA_FILE_GZIP="./data.tar.gz" | ||
#SYS_QPKG_DATA_FILE_BZIP2="./data.tar.bz2" | ||
#SYS_QPKG_DATA_FILE_7ZIP="./data.tar.7z" | ||
#SYS_QPKG_DATA_CONFIG_FILE="./conf.tar.gz" | ||
#SYS_QPKG_DATA_MD5SUM_FILE="./md5sum" | ||
#SYS_QPKG_DATA_PACKAGES_FILE="./Packages.gz" | ||
#SYS_QPKG_CONFIG_FILE="$SYS_CONFIG_DIR/qpkg.conf" | ||
#SYS_QPKG_CONF_FIELD_QPKGFILE="QPKG_File" | ||
#SYS_QPKG_CONF_FIELD_NAME="Name" | ||
#SYS_QPKG_CONF_FIELD_VERSION="Version" | ||
#SYS_QPKG_CONF_FIELD_ENABLE="Enable" | ||
#SYS_QPKG_CONF_FIELD_DATE="Date" | ||
#SYS_QPKG_CONF_FIELD_SHELL="Shell" | ||
#SYS_QPKG_CONF_FIELD_INSTALL_PATH="Install_Path" | ||
#SYS_QPKG_CONF_FIELD_CONFIG_PATH="Config_Path" | ||
#SYS_QPKG_CONF_FIELD_WEBUI="WebUI" | ||
#SYS_QPKG_CONF_FIELD_WEBPORT="Web_Port" | ||
#SYS_QPKG_CONF_FIELD_SERVICEPORT="Service_Port" | ||
#SYS_QPKG_CONF_FIELD_SERVICE_PIDFILE="Pid_File" | ||
#SYS_QPKG_CONF_FIELD_AUTHOR="Author" | ||
#SYS_QPKG_CONF_FIELD_RC_NUMBER="RC_Number" | ||
## The following variables are assigned values at run-time. | ||
#SYS_HOSTNAME=$($CMD_HOSTNAME) | ||
## Data file name (one of SYS_QPKG_DATA_FILE_GZIP, SYS_QPKG_DATA_FILE_BZIP2, | ||
## or SYS_QPKG_DATA_FILE_7ZIP) | ||
#SYS_QPKG_DATA_FILE= | ||
## Base location. | ||
#SYS_QPKG_BASE="" | ||
## Base location of QPKG installed packages. | ||
#SYS_QPKG_INSTALL_PATH="" | ||
## Location of installed software. | ||
#SYS_QPKG_DIR="" | ||
## If the QPKG should be enabled or disabled after the installation/upgrade. | ||
#SYS_QPKG_SERVICE_ENABLED="" | ||
## Architecture of the device the QPKG is installed on. | ||
#SYS_CPU_ARCH="" | ||
## Name and location of system shares | ||
#SYS_PUBLIC_SHARE="" | ||
#SYS_PUBLIC_PATH="" | ||
#SYS_DOWNLOAD_SHARE="" | ||
#SYS_DOWNLOAD_PATH="" | ||
#SYS_MULTIMEDIA_SHARE="" | ||
#SYS_MULTIMEDIA_PATH="" | ||
#SYS_RECORDINGS_SHARE="" | ||
#SYS_RECORDINGS_PATH="" | ||
#SYS_USB_SHARE="" | ||
#SYS_USB_PATH="" | ||
#SYS_WEB_SHARE="" | ||
#SYS_WEB_PATH="" | ||
## Path to ipkg or opkg package tool if installed. | ||
#CMD_PKG_TOOL= | ||
# | ||
###################################################################### | ||
# All package specific functions shall call 'err_log MSG' if an error | ||
# is detected that shall terminate the installation. | ||
###################################################################### | ||
# | ||
###################################################################### | ||
# Define any package specific operations that shall be performed when | ||
# the package is removed. | ||
###################################################################### | ||
PKG_PRE_REMOVE="{ | ||
# Remove web UI | ||
if [ -L ${SYS_WEB_PATH}/${QPKG_NAME} ]; then | ||
${CMD_RM} -f ${SYS_WEB_PATH}/${QPKG_NAME} | ||
fi | ||
}" | ||
# | ||
#PKG_MAIN_REMOVE="{ | ||
#}" | ||
# | ||
#PKG_POST_REMOVE="{ | ||
#}" | ||
# | ||
###################################################################### | ||
# Define any package specific initialization that shall be performed | ||
# before the package is installed. | ||
###################################################################### | ||
#pkg_init(){ | ||
#} | ||
# | ||
###################################################################### | ||
# Define any package specific requirement checks that shall be | ||
# performed before the package is installed. | ||
###################################################################### | ||
#pkg_check_requirement(){ | ||
#} | ||
# | ||
###################################################################### | ||
# Define any package specific operations that shall be performed when | ||
# the package is installed. | ||
###################################################################### | ||
#pkg_pre_install(){ | ||
#} | ||
# | ||
#pkg_install(){ | ||
#} | ||
# | ||
pkg_post_install(){ | ||
# Create web UI | ||
if [ ! -e ${SYS_WEB_PATH}/${QPKG_NAME} ]; then | ||
${CMD_LN} -fs ${SYS_QPKG_DIR}/web ${SYS_WEB_PATH}/${QPKG_NAME} | ||
fi | ||
SYS_QPKG_SERVICE_ENABLED=TRUE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Name of the packaged application. | ||
QPKG_NAME="PlexConnect" | ||
# Version of the packaged application. | ||
QPKG_VER="0.1" | ||
# Author or maintainer of the package | ||
QPKG_AUTHOR="rycochet@rycochet.com" | ||
# License for the packaged application | ||
QPKG_LICENSE="MIT" | ||
# One-line description of the packaged application | ||
QPKG_SUMMARY="Plex @ aTV - think different..." | ||
|
||
# Preferred number in start/stop sequence. | ||
#QPKG_RC_NUM="201" | ||
# Init-script used to control the start and stop of the installed application. | ||
QPKG_SERVICE_PROGRAM="plexconnect.sh" | ||
|
||
# Specifies any packages required for the current package to operate. | ||
QPKG_REQUIRE="Optware | opkg, OPT/python27 | Python >= 2.7, Git | OPT/git, OPT/openssl, PlexMediaServer" | ||
# Specifies what packages cannot be installed if the current package | ||
# is to operate properly. | ||
#QPKG_CONFLICT="Python, OPT/sed" | ||
# Name of configuration file (multiple definitions are allowed). | ||
QPKG_CONFIG="web/settings.cfg" | ||
# Port number used by service program. | ||
#QPKG_SERVICE_PORT="" | ||
# Location of file with running service's PID | ||
#QPKG_SERVICE_PIDFILE="" | ||
# Relative path to web interface | ||
QPKG_WEBUI="/PlexConnect" | ||
# Port number for the web interface. | ||
#QPKG_WEB_PORT="" | ||
# Port number for the ssl web interface. | ||
#QPKG_WEB_SSL_PORT="" | ||
|
||
#Desktop Application (since 4.1) | ||
# Optional. 1 means to open the QPKG's Web UI on QTS desktop. | ||
QPKG_DESKTOP_APP="1" | ||
# Desktop Application Window default inner width (since 4.1) (not over 1178) | ||
QPKG_DESKTOP_APP_WIN_WIDTH="640" | ||
# Desktop Application Window default inner width (since 4.1) (not over 600) | ||
QPKG_DESKTOP_APP_WIN_HEIGHT="256" | ||
|
||
# Minimum QTS version | ||
QTS_MINI_VERSION="4.1.0" | ||
|
||
# Select volume | ||
# 1: support installation | ||
# 2: support migration | ||
# 3 (1+2): support both installation and migration | ||
#QPKG_VOLUME_SELECT="0" | ||
|
||
# Location of the chroot environment (only TS-x09) | ||
#QPKG_ROOTFS="" | ||
# Init-script used to controls the start and stop of the | ||
# installed application (only TS-x09) | ||
#QPKG_SERVICE_PROGRAM_CHROOT="" | ||
|
||
# Location of icons for the packaged application. | ||
#QDK_DATA_DIR_ICONS="icons" | ||
# Location of files specific to arm-x09 packages. | ||
#QDK_DATA_DIR_X09="arm-x09" | ||
# Location of files specific to arm-x19 packages. | ||
#QDK_DATA_DIR_X19="arm-x19" | ||
# Location of files specific to x86 packages. | ||
#QDK_DATA_DIR_X86="x86" | ||
# Location of files specific to x86 (64-bit) packages. | ||
#QDK_DATA_DIR_X86_64="x86_64" | ||
# Location of files common to all architectures. | ||
#QDK_DATA_DIR_SHARED="shared" | ||
# Location of configuration files. | ||
#QDK_DATA_DIR_CONFIG="config" | ||
# Name of local data package. | ||
#QDK_DATA_FILE="" | ||
# Name of extra package (multiple definitions are allowed). | ||
#QDK_EXTRA_FILE="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Ryc O'Chet | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#!/bin/sh | ||
CONF=/etc/config/qpkg.conf | ||
QPKG_NAME="PlexConnect" | ||
QPKG_ROOT=`/sbin/getcfg ${QPKG_NAME} Install_Path -f ${CONF}` | ||
|
||
function update_conf() | ||
{ | ||
OLD_VALUE=`/sbin/getcfg ${QPKG_NAME} $1 -f ${PLEXCONNECT_CONF}` | ||
NEW_VALUE=`/sbin/getcfg ${QPKG_NAME} $1 -f ${QPKG_CONF}` | ||
if [ "${OLD_VALUE}" != "${NEW_VALUE}" ]; then | ||
/sbin/setcfg ${QPKG_NAME} $1 "${NEW_VALUE}" -f ${PLEXCONNECT_CONF} | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
#echo "$1" >> activity.log | ||
|
||
case "$1" in | ||
start) | ||
ENABLED=$(/sbin/getcfg ${QPKG_NAME} Enable -u -d TRUE -f $CONF) | ||
if [ "$ENABLED" != "TRUE" ]; then | ||
echo "${QPKG_NAME} is disabled." | ||
exit 1 | ||
fi | ||
|
||
# Set our variables | ||
RESTART_APACHE=FALSE | ||
PLEXCONNECT_GIT="https://github.com/iBaa/PlexConnect.git" | ||
APACHE_CONF="/usr/local/apache/conf/apache.conf" | ||
QPKG_CONF="${QPKG_ROOT}/web/settings.cfg" | ||
PROXY_CONF="${QPKG_ROOT}/apache/proxy.conf" | ||
PLEXCONNECT_CONF="${QPKG_ROOT}/PlexConnect/Settings.cfg" | ||
|
||
# Create any folders we require | ||
mkdir -p apache | ||
mkdir -p certificates | ||
|
||
# Install or update PlexConnect | ||
if [ ! -d "PlexConnect" ]; then | ||
git clone -- $PLEXCONNECT_GIT | ||
else | ||
cd PlexConnect | ||
git fetch --all | ||
git reset --hard origin/master | ||
cd .. | ||
fi | ||
|
||
# Workaround for a python / PlexConnect issue that prevents it working on QNAP | ||
sed -i "s/proxy\.start(initProxy)/proxy.start()/" PlexConnect/PlexConnect.py | ||
|
||
# Check if we have a settings file | ||
if [ ! -f "${PLEXCONNECT_CONF}" ]; then | ||
echo "Creating PlexConnect settings file" | ||
cp -f ${QPKG_CONF} ${PLEXCONNECT_CONF} | ||
NEW_PLEXCONNECT_CONF=TRUE | ||
fi | ||
|
||
# Make sure that our local IP is up to date | ||
LOCAL_IP=`hostname -i | xargs` | ||
/sbin/setcfg ${QPKG_NAME} ip_pms ${LOCAL_IP} -f ${PLEXCONNECT_CONF} | ||
/sbin/setcfg ${QPKG_NAME} ip_plexconnect ${LOCAL_IP} -f ${PLEXCONNECT_CONF} | ||
|
||
# Get the host we're intercepting, this can be changed in the config | ||
NEW_HOSTTOINTERCEPT=`/sbin/getcfg ${QPKG_NAME} hosttointercept -f ${QPKG_CONF}` | ||
|
||
# update the values we want to copy | ||
#update_conf enable_plexgdm | ||
update_conf enable_dnsserver | ||
update_conf prevent_atv_update | ||
update_conf loglevel | ||
update_conf hosttointercept | ||
if [ "$?" == "1" ] || [ "${NEW_PLEXCONNECT_CONF}" == "TRUE" ]; then | ||
echo "Updating intercepted host" | ||
/sbin/setcfg ${QPKG_NAME} certfile "../certificates/${NEW_HOSTTOINTERCEPT}.pem" -f "${PLEXCONNECT_CONF}" | ||
# Make sure our Apache proxy config is hitting the right url and certificate | ||
sed -e "s/trailers\.key/${NEW_HOSTTOINTERCEPT}.key/" -e "s/trailers\.pem/${NEW_HOSTTOINTERCEPT}.pem/" -e "s/trailers\.apple\.com/${NEW_HOSTTOINTERCEPT}/" -e "s/0\.0\.0\.0/${LOCAL_IP}/" proxy.conf > $PROXY_CONF | ||
RESTART_APACHE=TRUE | ||
fi | ||
|
||
# Make sure Apache knows to proxy our connection | ||
if ! grep -F -q "${QPKG_ROOT}" "${APACHE_CONF}" ; then | ||
echo "Adding proxy to Apache configuration" | ||
# Would prefer IncludeOptional, but QNAP doesn't have it | ||
echo "Include ${QPKG_ROOT}/apache/proxy[.]conf" >> "${APACHE_CONF}" | ||
RESTART_APACHE=TRUE | ||
fi | ||
|
||
# Create the certificates if needed | ||
if [ ! -e "certificates/${NEW_HOSTTOINTERCEPT}.key" ]; then | ||
echo "Creating certificates" | ||
openssl req -new -nodes -newkey rsa:2048 -out certificates/${NEW_HOSTTOINTERCEPT}.pem -keyout certificates/${NEW_HOSTTOINTERCEPT}.key -x509 -days 7300 -subj "/C=US/CN=${NEW_HOSTTOINTERCEPT}" | ||
openssl x509 -in certificates/${NEW_HOSTTOINTERCEPT}.pem -outform der -out certificates/${NEW_HOSTTOINTERCEPT}.cer && cat certificates/${NEW_HOSTTOINTERCEPT}.key >> certificates/${NEW_HOSTTOINTERCEPT}.pem | ||
RESTART_APACHE=TRUE | ||
fi | ||
|
||
# Restart Apache if we need to - install or changed host | ||
if [ "${RESTART_APACHE}" == "TRUE" ]; then | ||
# Restart Apache | ||
/etc/init.d/Qthttpd.sh restart | ||
fi | ||
|
||
# Start PlexConnect | ||
cd PlexConnect && ./PlexConnect_daemon.bash start | ||
;; | ||
|
||
stop) | ||
# Stop PlexConnect | ||
cd PlexConnect && ./PlexConnect_daemon.bash stop | ||
;; | ||
|
||
restart) | ||
$0 stop | ||
$0 start | ||
;; | ||
|
||
*) | ||
echo "Usage: $0 {start|stop|restart}" | ||
exit 1 | ||
esac | ||
|
||
exit 0 |
Oops, something went wrong.