Jump to content

how can I run a second instance of CouchPotato on an Unraid server?


lumpumun

Recommended Posts

Hi dear forum members,

 

Is anyone running a second instance of CP on their unraid server? By searching the web it looks like it can be done, I just don't know how to implement it in Unraid-OS.

I need detailed instructions, or some good hints. My Unraid is in production so I do not want to screw things up.

 

CP is installed with Influencers plugin. Other plugins running from Influencer are SB, Transmission, Sab, PMS, LMS.

I am running Unraid 5 rc16 with UnMenu.

The hardware running all this: AMD quadcore 2100MHz, 4GB ram.

 

Could it be an option to adapt Influencers CP plugin to run the second instance?

 

Thank you for helping out.

Herman :)

Link to comment
  • 2 weeks later...

Hi,

I tried to adapt influencers plugin for running a second instance of Couchpotato.

After I did an installplg it installed without errors. Problem is the original instance of Couchpotato disappeared from the unraid web interface and is now replaced by the second instance.

Below is part 1 of the code of Couchpotato_v2_instance2_unplugged.plg which is based on Couchpotato_v2_unplugged.plg. Part 2 is in another message because of acceding the allowed quantity of characters for a message. I really hope someone is able to guide me in the right direction.

 <?xml version='1.0' standalone='yes'?>
<PLUGIN>

<!--
This Plugin installs and controls CouchPotato v2 for unRaid.
All dependencies are installed as needed and everything is controlable from the webgui

Credits:
Benni-Chan: Code for original(couchpotato v1) plug-in. Much of that code is still in place.

WW: Modification to enable use of Couchpotato V2, config page formatting, ability to select alternate branches.

I have...
* done little for this plug-in other than maintaining it and some bug fixes.
* probably missed some credits here, not intentional but I do not have a perfect memory!
* removed the changelog from the plug-in itself.
* done this because since I am hosting the plug-ins on github, there is an accurate changelog with the commits.
-->

<FILE Name="/boot/packages/python-2.6.6-i486-1.txz" Run="upgradepkg --install-new">
<URL>http://slackware.cs.utah.edu/pub/slackware/slackware-13.37/slackware/d/python-2.6.6-i486-1.txz</URL>
<MD5>b8de0c9f8b89aa7b3c89823d20076867</MD5>
</FILE>
<FILE Name="/boot/packages/zlib-1.2.5-i486-4.txz" Run="upgradepkg --install-new">
<URL>http://slackware.cs.utah.edu/pub/slackware/slackware-13.37/slackware/l/zlib-1.2.5-i486-4.txz</URL>
<MD5>eabaa7087a32dfd9f6d2662163779d07</MD5>
</FILE>
<FILE Name="/boot/packages/sqlite-3.7.5-i486-1.txz" Run="upgradepkg --install-new">
<URL>http://slackware.cs.utah.edu/pub/slackware/slackware-13.37/slackware/ap/sqlite-3.7.5-i486-1.txz</URL>
<MD5>6786d3764cb294ecb71cdd24e6d171d1</MD5>
</FILE>
<FILE Name="/boot/packages/curl-7.21.4-i486-1.txz" Run="upgradepkg --install-new">
<URL>http://slackware.osuosl.org/slackware-13.37/slackware/n/curl-7.21.4-i486-1.txz</URL>
<MD5>e32449e0588ef54df8524827028972e8</MD5>
</FILE>
<FILE Name="/boot/packages/git-1.7.4.4-i486-1.txz" Run="upgradepkg --install-new">
<URL>http://slackware.osuosl.org/slackware-13.37/slackware/d/git-1.7.4.4-i486-1.txz</URL>
<MD5>5d92bd44e67618dfdacc2e2fa9a41821</MD5>
</FILE>
<FILE Name="/boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.png">
<URL>--no-check-certificate https://github.com/downloads/W-W/unRAID/couchpotato_v2.png</URL>
</FILE>
<FILE Name="/boot/config/plugins/images/device_status.png">
<URL>--no-check-certificate https://github.com/downloads/Influencer/UNplugged/device_status.png</URL>
</FILE>
<FILE Name="/boot/config/plugins/images/new_config.png">
<URL>--no-check-certificate https://github.com/downloads/Influencer/UNplugged/new_config.png</URL>
</FILE>
<FILE Name="/boot/config/plugins/images/information.png">
<URL>--no-check-certificate https://github.com/downloads/Influencer/UNplugged/information.png</URL>
</FILE>

<!-- clean up previous install -->
<FILE Name="/tmp/couchpotato_v2_instance2-cleanup" Run="/bin/bash">
<INLINE>
<![CDATA[
[ -d /usr/local/emhttp/plugins/couchpotato_v2_instance2 ] && rm -f -R /usr/local/emhttp/plugins/couchpotato_v2_instance2
[ -f /etc/rc.d/rc.couchpotato_v2_instance2 ] && rm -f /etc/rc.d/rc.couchpotato_v2_instance2
[ -f /boot/config/plugins/couchpotato_v2_instance2/plgver.txt ] && rm -f /boot/config/plugins/couchpotato_v2_instance2/plgver.txt
git config --global http.sslVerify false
rm /tmp/couchpotato_v2_instance2-cleanup
]]>
</INLINE>
</FILE>

<FILE Name="/boot/config/plugins/couchpotato_v2_instance2/plgver.txt">
<INLINE>
<![CDATA[
2.3.6
]]>
</INLINE>
</FILE>

<FILE Name="/boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg">
<INLINE>
<![CDATA[
# CouchPotato v2 configuration:
SERVICE="disable"
INSTALLDIR="/usr/local/couchpotato_v2_instance2"
CONFIGFILE="/boot/config/plugins/couchpotato_v2_instance2/settings.conf"
RUNAS="nobody"
PLG_STORAGESIZE="yes"
PLG_DATACHECK="yes"
INSTALLURL="https://github.com/RuudBurger/CouchPotatoServer"
BRANCH="master"
]]>
</INLINE>
</FILE>

<FILE Name="/tmp/checkconfig_instance2" Run="/bin/bash">
<INLINE>
<![CDATA[
#!/bin/sh
test=`cat /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg | grep BRANCH`
if [[ $test = "" ]]; then
echo "" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
echo "INSTALLURL=\"https://github.com/RuudBurger/CouchPotatoServer\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
echo "BRANCH=\"master\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
fi

plgstorage=`cat /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg | grep PLG_STORAGESIZE`
if [[ $plgstorage = "" ]]; then
   echo "PLG_STORAGESIZE=\"yes\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
fi
plgdata=`cat /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg | grep PLG_DATACHECK`
if [[ $plgdata = "" ]]; then
echo "PLG_DATACHECK=\"yes\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
fi
rm /tmp/checkconfig_instance2
]]>
</INLINE>
</FILE>

<FILE Name="/boot/config/plugins/couchpotato_v2_instance2/settings.conf">
<INLINE>
<![CDATA[
[growl]
port = 

[core]
data_dir = /usr/local/couchpotato_v2_instance2
port = 8087
]]>
</INLINE>
</FILE>

<FILE Name="/usr/local/emhttp/plugins/webGui/unplugged.page">
<INLINE>
<![CDATA[
Author="Influencer"
Version="1.0.0"
Title="Unplugged PLG"
Menu="Settings"
Type="menu"
]]>
</INLINE>
</FILE>

<FILE Name="/etc/rc.d/rc.couchpotato_v2_instance2" Mode="0770">
<INLINE>
<![CDATA[
#!/bin/sh
# start|stop|restart|enable|disable|install|update|storagesize|datacheck CouchPotato v2_instance2

couchpotato_instance2_start()
{ 
# no-op if not enabled
if [ $SERVICE != "enable" ]; then
	sed -i "s/"disable"/"enable/"" $CONFIG	
fi
  
# no-op if already running
if [ -r /var/run/couchpotato_v2_instance2/couchpotato_v2.pid ]; then
	return
fi
  
# if directory doesn't exist or CouchPotato v2 is not found, install it
if [[ "$INSTALLDIR" != "" && ! -e "$INSTALLDIR/CouchPotato.py" ]]; then
	couchpotato_instance2_install
fi
  
CMDLINE="sudo -u $RUNAS python $INSTALLDIR/CouchPotato.py --daemon --config_file $CONFIGFILE --pid_file /var/run/couchpotato_v2_instance2/couchpotato_v2.pid"
echo "Starting CouchPotato v2 instance2: $CMDLINE"
sleep 1
$CMDLINE

while [ ! -e /var/run/couchpotato_v2_instance2/couchpotato_v2.pid ]; do
	sleep 1
done
echo "... OK"
sleep 1
}

couchpotato_instance2_stop()
{
# no-op if not running
if [ ! -r /var/run/couchpotato_v2_instance2/couchpotato_v2.pid ]; then
	return
fi

echo "Stopping CouchPotato v2 instance2..."
sleep 1
kill $(cat /var/run/couchpotato_v2_instance2/couchpotato_v2.pid)
sleep 3

if [ -e /var/run/couchpotato_v2_instance2/couchpotato_v2.pid ]; then
	kill -9 $(cat /var/run/couchpotato_v2_instance2/couchpotato_v2.pid )
	rm /var/run/couchpotato_v2_instance2/couchpotato_v2.pid
fi
echo "... OK"
sleep 1
}

couchpotato_instance2_restart()
{
couchpotato_instance2_stop
sleep 1
couchpotato_instance2_start
}
couchpotato_instance2_buttonstart()
{
echo "Enabling couchpotato instance2"
CONFIG="/boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg"
if [ -f $CONFIG ]; then
	sed -i "s/"disable"/"enable/"" $CONFIG	
	sleep 3
	echo "Starting couchpotato instance2"
couchpotato_start
fi
}

#couchpotato_instance2_update()
#{
#	couchpotato_instance2_stop
#	sleep 1
#	cd /tmp
#	git clone -b $BRANCH $INSTALLURL
#	cp -Rfu /tmp/couchpotato_v2_instance2/* $INSTALLDIR
#	rm -Rf /tmp/couchpotato_v2_instance2
#	chown -R $RUNAS:users "$INSTALLDIR" "$DATADIR"
#	sleep 1
#	couchpotato_instance2_start
#}

write_config()
{
echo "#CouchPotato v2 instance2 configuration:" > /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
echo "SERVICE=\"$SERVICE\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
echo "INSTALLDIR=\"$INSTALLDIR\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
    	echo "CONFIGFILE=\"$CONFIGFILE\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
echo "RUNAS=\"$RUNAS\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
echo "PLG_STORAGESIZE=\"$PLG_STORAGESIZE\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
echo "PLG_DATACHECK=\"$PLG_DATACHECK\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
echo "INSTALLURL=\"$INSTALLURL\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
echo "BRANCH=\"$BRANCH\"" >> /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
if [ -e "$CONFIGFILE" ]; then
	sed -i 's!data_dir = '"`cat "$CONFIGFILE" | grep 'data_dir' | cut -d' ' -f3`"'!data_dir = '"$DATADIR"'!' "$CONFIGFILE"
	sed -i 's!port = '"`cat "$CONFIGFILE" | grep 'port = ' | cut -d' ' -f3 | awk 'NR==2'`"'!port = '"$PORT"'!' "$CONFIGFILE"
fi
}

couchpotato_instance2_change_settings()
{
PORT="$2"
INSTALLDIR="$3"
DATADIR="$4"

if [ $DATADIR == "" ]; then
	$DATADIR="$INSTALLDIR"
fi

if [ $RUNAS != $1 ]; then
	chown -R $1:users "$INSTALLDIR" "$DATADIR"
fi

RUNAS="$1"

PLG_STORAGESIZE="$5"
PLG_DATACHECK="$6"
INSTALLURL="$7"
BRANCH="$8"

# create CouchPotato v2_instance2 user if necessary
if [[ $RUNAS != "nobody" && $RUNAS != "root" ]]; then
	if ( ! grep -q ^$RUNAS /etc/passwd ); then
  		useradd -r -g users -d / -s /bin/false $RUNAS &> /dev/null
  		cp /etc/passwd /etc/shadow /boot/config
	fi
fi
}

couchpotato_instance2_enable()
{
# if not already enabled, enable it
	SERVICE=enable
	if [ $PORT != $2 ];then
	couchpotato_instance2_change_settings $1 $2 $3 $4 $5 $6 $7 $8
	write_config
        couchpotato_instance2_restart
	else
	couchpotato_instance2_change_settings $1 $2 $3 $4 $5 $6 $7 $8
	write_config
	fi
# enabling also starts it
if [ ! -f /var/run/couchpotato_v2_instance2/couchpotato_v2.pid ]; then
couchpotato_instance2_start
fi
}

couchpotato_instance2_disable()
{
couchpotato_instance2_stop
SERVICE=disable
couchpotato_instance2_change_settings $1 $2 $3 $4 $5 $6 $7 $8
write_config
}

couchpotato_instance2_install()
{ 
source /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg

echo "Installing latest version of CouchPotato v2..."

if [ ! -e "$INSTALLDIR" ]; then 
	mkdir -p $INSTALLDIR
fi

DATADIR="`cat "$CONFIGFILE" | grep 'data_dir' | cut -d' ' -f3`"
if [ ! -e "$DATADIR" ]; then 
	mkdir -p $DATADIR
fi

if [ -e ""$DATADIR"/cache/version" ]; then 
	rm ""$DATADIR"/cache/version"
fi	

cd /tmp
git clone -b $BRANCH $INSTALLURL Couchpotato
cp -Rfu /tmp/Couchpotato_instance2/* $INSTALLDIR
rm -Rf /tmp/Couchpotato_instance2

chown -R $RUNAS:users "$INSTALLDIR" "$DATADIR"
sleep 1
echo "... OK"
sleep 1
}

couchpotato_instance2_storagesize() 
{
if [ $1 ] && [ $2 ]; then
	if [ -d $1 ]; then
		INST=`du -sh $1 | cut -f1`
	elif [ -f $1 ]; then
		INST=`ls -lah $1 | awk '{ print $5}'`
	fi

	if [ -d $2 ]; then
		DAT=`du -sh $2 | cut -f1`
	elif [ -f $2 ]; then
		DAT=`ls -lah $2 | awk '{ print $5}'`
	fi

	if [ $1 == $2 ]; then
		echo "<p style="margin-left:10px\;">Storage memory usage: install + data directory: <b>$INST</b></p>"
	else
		echo "<p style="margin-left:10px\;">Storage memory usage: install directory: <b>$INST</b>, data directory: <b>$DAT</b></p>"
	fi
elif [ $1 ]; then
	if [ -d $1 ]; then
		INST=`du -sh $1 | cut -f1`
	elif [ -f $1 ]; then
		INST=`ls -lah $1 | awk '{ print $5}'`
	fi
	echo "<p style="margin-left:10px\;">Storage memory usage: <b>$INST</b></p>"
fi
}

couchpotato_instance2_datacheck() 
{
array=( ramfs proc tempfs sysfs )
fs=$( stat -f -c '%T' $DATADIR )
for i in "${array[@]}"
do
	if [ $i = $fs ]; then
	    echo "<p style="color:red\;margin-left:10px\;margin-right:10px\;"><b>WARNING:</b> Your data directory is not persistent and WILL NOT survive a reboot. Please locate Data Directory on disk for persistency</p>"
		break
	elif [ $i = msdos ]; then
		echo "<p style="color:red\;margin-left:10px\;margin-right:10px\;"><b>WARNING:</b> Your data directory is located on your flash drive. This will decrease your flash drives life span!</p>"
		break
	else
		echo "<p style="color:green\;margin-left:10px\;margin-right:10px\;">Your data will persist after a reboot</p>"
		break
	fi
done
}

couchpotato_instance2_updateplg()
{
cd /boot/config/plugins
[ -f couchpotato_v2_instance2_unplugged.plg.old ] && rm -f couchpotato_v2_instance2_unplugged.plg.old
if [ -f couchpotato_v2_instance2_unplugged.plg ]; then
mv couchpotato_v2_instance2_unplugged.plg couchpotato_v2_instance2_unplugged.plg.old
echo "Updating plugin"
wget -q --no-check-certificate https://github.com/Influencer/UNplugged/raw/master/couchpotato_v2_unplugged.plg
/usr/local/sbin/installplg /boot/config/plugins/couchpotato_v2_instance2_unplugged.plg
else
echo "Updating plugin"
wget -q --no-check-certificate https://github.com/Influencer/UNplugged/raw/master/couchpotato_v2_unplugged.plg
/usr/local/sbin/installplg /boot/config/plugins/couchpotato_v2_instance2_unplugged.plg
fi
}
couchpotato_instance2_downgradeplg()
{
cd /boot/config/plugins
if [ -f couchpotato_v2_instance2_unplugged.plg.old ]; then
rm -f couchpotato_v2_instance2_unplugged.plg
mv couchpotato_v2_instance2_unplugged.plg.old couchpotato_v2_instance2_unplugged.plg
echo "downgrading plugin"
/usr/local/sbin/installplg /boot/config/plugins/couchpotato_v2_instance2_unplugged.plg
fi
}
couchpotato_instance2_vercheck()
{ set -x
if [ -e $DATADIR/cache/version ]; then
curversion=$( cat $DATADIR/cache/version )
echo "$curversion"
fi
}

# read our configuration
source /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
if [ -e "$CONFIGFILE" ]; then
DATADIR=`cat "$CONFIGFILE" | grep 'data_dir' | cut -d' ' -f3`
PORT=`cat "$CONFIGFILE" | grep 'port = ' | cut -d' ' -f3 | awk 'NR==2'`
fi

case "$1" in
'start')
	couchpotato_instance2_start
;;
'stop')
	couchpotato_instance2_stop
;;
'restart')
	couchpotato_instance2_restart
;;
'enable')
	couchpotato_instance2_enable $2 $3 $4 $5 $6 $7 $8 $9
;;
'disable')
	couchpotato_instance2_disable $2 $3 $4 $5 $6 $7 $8 $9
;;
'install')
	couchpotato_instance2_install
;;
#	'update')
#		couchpotato_instance2_update
#	;;
'storagesize')
	couchpotato_instance2_storagesize $2 $3
;;
'datacheck')
	couchpotato_instance2_datacheck
;;
'updateplg')
	couchpotato_instance2_updateplg
;;
'downgradeplg')
	couchpotato_instance2_downgradeplg
;;
'buttonstart')
	couchpotato_instance2_buttonstart
;;
#	'vercheck')
#		couchpotato_instance2_vercheck
#	;;
*)
	echo "usage $0 start|stop|restart|enable|disable|install|update|storagesize|datacheck|updateplg|downgradeplg"
esac
]]>
</INLINE>
</FILE>

Link to comment

Part 2 of the code for the second instance:

 <FILE Name="/usr/local/emhttp/plugins/couchpotato_v2_instance2/couchpotato_v2.page">
<INLINE>
<![CDATA[
Menu="unplugged"
Icon="couchpotato_v2.png"
Version="2.3.1"
Author="Wojciech Walaszek; Influencer; Benjamin Waller"
Type="php"
Title="CouchPotato v2 instance2"
]]>
</INLINE>
</FILE>

<FILE Name="/usr/local/emhttp/plugins/couchpotato_v2_instance2/couchpotato_v2.png">
<LOCAL>/boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.png</LOCAL>
</FILE>

<FILE Name="/usr/local/emhttp/plugins/couchpotato_v2_instance2/device_status.png">
<LOCAL>/boot/config/plugins/images/device_status.png</LOCAL>
</FILE>

<FILE Name="/usr/local/emhttp/plugins/couchpotato_v2_instance2/new_config.png">
<LOCAL>/boot/config/plugins/images/new_config.png</LOCAL>
</FILE>

<FILE Name="/usr/local/emhttp/plugins/couchpotato_v2_instance2/information.png">
<LOCAL>/boot/config/plugins/images/information.png</LOCAL>
</FILE>

<FILE Name="/usr/local/emhttp/plugins/couchpotato_v2_instance2/couchpotato_v2.php">
<INLINE>
<![CDATA[
<?PHP
$couchpotato_instance2_cfg = parse_ini_file( "/boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg");
$couchpotato_instance2_installed = file_exists( $couchpotato_instance2_cfg["INSTALLDIR"] . "/CouchPotato.py" ) ? "yes" : "no";
$couchpotato_instance2_rollback = file_exists( "/boot/config/plugins/couchpotato_v2_instance2_unplugged.plg.old" ) ? "yes" : "no";
$couchpotato_instance2_configfile = $couchpotato_instance2_cfg["CONFIGFILE"];
$couchpotato_instance2_datadir = trim(shell_exec( "cat \"$couchpotato_instance2_configfile\" | grep 'data_dir' | cut -d' ' -f3" ));
if ($couchpotato_instance2_installed=="yes")
{	
$couchpotato_instance2_running = file_exists( "/var/run/couchpotato_v2_instance2/couchpotato_v2.pid") ? "yes" : "no";
if ($couchpotato_instance2_cfg[PLG_STORAGESIZE]=="yes")
	$couchpotato_instance2_datasize = shell_exec ( "/etc/rc.d/rc.couchpotato_v2_instance2 storagesize $couchpotato_instance2_cfg[iNSTALLDIR] $couchpotato_instance2_datadir" );
if ($couchpotato_instance2_cfg[PLG_DATACHECK]=="yes")
	$couchpotato_instance2_datacheck = shell_exec ( "/etc/rc.d/rc.couchpotato_v2_instance2 datacheck" );
$couchpotato_instance2_plgver = shell_exec ( "cat /boot/config/plugins/couchpotato_v2_instance2/plgver.txt" );

}
// get CouchPotato v2 instance2 port
if (file_exists($couchpotato_instance2_configfile))
$couch_port = trim(shell_exec( "cat \"$couchpotato_instance2_configfile\" | grep 'port = ' | cut -d' ' -f3 | awk 'NR==2'" ));
?>

<div style="width: 49%; float:left">
<div id="title">
	<span class="left">Status:&#32;<img src='/plugins/couchpotato_v2_instance2/device_status.png'> 
		<?if ($couchpotato_instance2_installed=="yes"):?>	
			<?if ($couchpotato_instance2_running=="yes"):?>
				<a href="http://<?=$var['NAME'];?>:<?=$couch_port;?>" target="_blank"><span class="green"><b>RUNNING</b></span></a>
			<?else:?>
				<span class="red"><b>STOPPED</b></span>
			<?endif;?>
		<?else:?>
			<span class="red"><b>NOT INSTALLED</b></span>
		<?endif;?>	
	</span>
</div>	
	<?if ($couchpotato_instance2_installed=="yes"):?>
		<?if ($couchpotato_instance2_running=="yes"):?>	
			<div style="position:relative;float:left;width:50%;text-align:right; margin-bottom:24px">
				<form name="couchpotato_instance2_stop" method="POST" action="/update.htm" target="progressFrame">
					<input type="hidden" name="cmd" value="/etc/rc.d/rc.couchpotato_v2_instance2 stop">
					<input type="submit" name="runCmd" value="Stop">
				</form>
			</div>
			<div style="position:relative;float:left;width:50%;text-align:left;margin-bottom:24px">
				<form name="couchpotato_instance2_restart" method="POST" action="/update.htm" target="progressFrame">
					<input type="hidden" name="cmd" value="/etc/rc.d/rc.couchpotato_v2_instance2 restart">
					<input type="submit" name="runCmd" value="Restart">
				</form>
			</div>
		<?else:?>
			<div style="position:relative;float:left;width:100%;text-align:center;margin-bottom:24px">
				<form name="couchpotato_instance2_buttonstart" method="POST" action="/update.htm" target="progressFrame">
					<input type="hidden" name="cmd" value="/etc/rc.d/rc.couchpotato_v2_instance2 buttonstart">
					<input type="submit" name="runCmd" value="Start">
				</form>
			</div>
		<?endif;?>
	<?else:?>
	<div style="position:relative;float:left;width:100%;text-align:center;margin-bottom:24px">
		<form name="couchpotato_instance2_install" method="POST" action="/update.htm" target="progressFrame">
			<input type="hidden" name="cmd" value="/etc/rc.d/rc.couchpotato_v2_instance2 install">			
			<input type="submit" name="runCmd" value="Install">
		</form>
	</div>
	<?endif;?>
<? if ($couchpotato_instance2_rollback=="yes"): ?>
<div style="position:relative;float:left;width:50%;text-align:right;margin-bottom:24px">
		<form name="couchpotato_v2_instance2_update1" method="POST" action="/update.htm" target="progressFrame">
				<input type="hidden" name="cmd" value="/etc/rc.d/rc.couchpotato_v2_instance2 updateplg">
				<input type="submit" name="runCmd" value="Update PLG">
		</form>
</div>
<div style="position:relative;float:left;width:50%;text-align:left;margin-bottom:24px">
	<form name="couchpotato_v2_instance2_downgrade" method="POST" action="/update.htm" target="progressFrame">
				<input type="hidden" name="cmd" value="/etc/rc.d/rc.couchpotato_v2_instance2 downgradeplg">
				<input type="submit" name="runCmd" value="Downgrade PLG">
		</form>
</div>
<?else:?>
<div style="position:relative;float:left;width:100%;text-align:center;margin-bottom:24px">
		<form name="couchpotato_v2_instance2_update" method="POST" action="/update.htm" target="progressFrame">
			<input type="hidden" name="cmd" value="/etc/rc.d/rc.couchpotato_v2_instance2 updateplg">			
			<input type="submit" name="runCmd" value="Update PLG">
		</form>
	</div>
<?endif;?><br/>
<? if ($couchpotato_instance2_installed=="yes"): ?>	
	<center><hr size="3" width="50%" color="grey"></center>
	<p style="margin-left:10px;">Installed from <?=$couchpotato_instance2_cfg[bRANCH]?> branch of <?=$couchpotato_instance2_cfg[iNSTALLURL]?> site</p>
	<? if ($couchpotato_instance2_cfg[PLG_STORAGESIZE]=="yes"): ?>
		<?=$couchpotato_instance2_datasize?>
	<? endif; ?>
	<? if ($couchpotato_instance2_cfg[PLG_DATACHECK]=="yes"): ?>
		<?=$couchpotato_instance2_datacheck?>
	<? endif; ?>
	<p style="margin-left:10px;"><b>Plug-in Version: <?=$couchpotato_instance2_plgver;?></b></p>
<? endif; ?>
</div>
<div style="width: 49%; float:right">
<div id="title">
	<span class="left">Configuration:&#32;<img src='/plugins/couchpotato_v2_instance2/new_config.png'></span>
</div>
<form name="couchpotato_instance2_settings" method="POST" action="/update.htm" target="progressFrame">
	<input type="hidden" name="cmd" value="/etc/rc.d/rc.couchpotato_v2_instance2">
	<table class="settings">
		<tr>
			<td>Enable CouchPotato v2 instance2:</td>
			<td>
				<select name="arg1" size="1">
					<?=mk_option($couchpotato_instance2_cfg['SERVICE'], "disable", "No");?>
					<?=mk_option($couchpotato_instance2_cfg['SERVICE'], "enable", "Yes");?>
				</select>
			</td>
		</tr>
		<tr>
			<td>Install directory:</td>
			<td><input type="text" name="arg4" maxlength="60" value="<?=$couchpotato_instance2_cfg['INSTALLDIR'];?>"></td>
		</tr>
		<tr>
			<td>Data directory:</td>
			<td><input type="checkbox" name="use_data" <?=($couchpotato_instance2_datadir!=$couchpotato_instance2_cfg['INSTALLDIR'])?"checked=\"checked\"":"";?> onChange="checkDATADIR(this.form);"> <input type="text" 				name="arg5" style="width:86%" maxlength="60" value="<?=$couchpotato_datadir;?>"></td>
		</tr>
		<tr>
			<td>Port:</td>
			<td><input type="text" name="arg3" maxlength="40" value="<?=$couch_port;?>"></td>
		</tr>
		<tr>
			<td>Run as user:</td>
			<td>
				<select name="runas" size="1" onChange="checkUSER(this.form);">
					<?=mk_option($couchpotato_instance2_cfg['RUNAS'], "nobody", "nobody");?>
					<?=mk_option($couchpotato_instance2_cfg['RUNAS'], "root", "root");?>
					<option value='other'<?=($couchpotato_instance2_cfg['RUNAS'] != "root" && $couchpotato_instance2_cfg['RUNAS'] != "nobody")?" selected=yes":"" ;?>>other</option>
				</select>
				<input type="hidden" name="arg2" style="width:66%" maxlength="40" value="<?=$couchpotato_instance2_cfg['RUNAS'];?>">
			</td>
		</tr>
		<tr><td>---</td></tr>
		<tr>
			<td>Show storage memory usage:</td>
			<td>
				<select name="storagesize" size="1" onChange="checkSTORAGE(this.form);">
					<?=mk_option($couchpotato_instance2_cfg['PLG_STORAGESIZE'], "yes", "Yes");?>
					<?=mk_option($couchpotato_instance2_cfg['PLG_STORAGESIZE'], "no", "No");?>
				</select>
				<input type="hidden" name="arg6" value="<?=$couchpotato_instance2_cfg['PLG_STORAGESIZE'];?>">
			</td>
		</tr>
		<tr>
			<td>Show data persistency information:</td>
			<td>
				<select name="datacheck" size="1" onChange="checkDATA(this.form);">
					<?=mk_option($couchpotato_instance2_cfg['PLG_DATACHECK'], "yes", "Yes");?>
					<?=mk_option($couchpotato_instance2_cfg['PLG_DATACHECK'], "no", "No");?>
				</select>
				<input type="hidden" name="arg7" value="<?=$couchpotato_instance2_cfg['PLG_DATACHECK'];?>">
			</td>
		</tr>
	</table>
	<div align="center">
		<hr size="3" align="center" width="75%" color="grey" style="margin-top:20px;margin-bottom:18px" >
		<input type="submit" name="runCmd" value="Apply" style="margin-bottom:8px">
		<? if ($couchpotato_instance2_installed=="no"): ?>
			<input type="button" value="Show advanced configuration" style="margin-bottom:35px" onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = 'Hide advanced configuration'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show advanced configuration'; }">
		<? endif; ?>
		<button type="button" style="margin-bottom:35px" onClick="done();">Done</button>
	</div>
	<div>
		<div style="display: none;">
			<br />
			<table class="settings">
				<tr>
					<td style="width:auto">Install from:</td>
					<td>
						<select name="url" size="1" onChange="checkURL(this.form);">
							<?=mk_option($couchpotato_instance2_cfg['INSTALLURL'], "https://github.com/RuudBurger/CouchPotatoServer", "official github");?>
							<option value='other'<?=($couchpotato_instance2_cfg['INSTALLURL'] != "https://github.com/RuudBurger/CouchPotatoServer")?" selected=yes":"" ;?>>other github</option>
						</select>
						<input type="hidden" name="arg8" maxlength="100" style="text-align:left;width:63%" value="<?=$couchpotato_instance2_cfg['INSTALLURL'];?>">
						<img src="/plugins/couchpotato_v2_instance2/information.png" title="Installing from other than official github site is not recommended. Use this option at your own risk!"/>
					</td>
				</tr>
				<tr>
					<td style="width:auto">Specify branch:</td>
					<td>
						<select name="branch" size="1" onChange="checkBRANCH(this.form);">
							<?=mk_option($couchpotato_instance2_cfg['BRANCH'], "master", "master");?>
							<option value='other'<?=($couchpotato_instance2_cfg['BRANCH'] != "master")?" selected=yes":"" ;?>>other</option>
						</select>
						<input type="hidden" name="arg9" maxlength="40" style="text-align:left;width:71%" value="<?=$couchpotato_instance2_cfg['BRANCH'];?>">
						<img src="/plugins/couchpotato_v2_instance2/information.png" title="Installing other branch than master is not recommended. Use this option at your own risk!"/>
					</td>
				</tr>
			</table>
		</div>
	</div>
</form>
<br />
</div>

<script type="text/javascript">
function checkRUNNING(form)
{
if ("<?=$couchpotato_instance2_running;?>" == "yes")
{
	form.arg2.readOnly = true;
	form.arg3.readOnly = true;
	form.arg4.readOnly = true;
	form.arg5.readOnly = true;
	form.arg6.readOnly = true;
	form.arg7.readOnly = true;
	form.arg8.readOnly = true;
	form.arg9.readOnly = true;
	form.runas.disabled = true;
	form.use_data.disabled = true;
	form.storagesize.disabled = true;
	form.datacheck.disabled = true;
	form.url.disabled = true;
	form.branch.disabled = true;
   } 
   else
   {
	form.arg2.readOnly = (form.arg1.value == "enable");
	form.arg3.readOnly = (form.arg1.value == "enable");
	form.arg4.readOnly = (form.arg1.value == "enable");
	form.arg5.readOnly = (form.arg1.value == "enable");
	form.arg6.readOnly = (form.arg1.value == "enable");
	form.arg7.readOnly = (form.arg1.value == "enable");
	form.arg8.readOnly = (form.arg1.value == "enable");
	form.arg9.readOnly = (form.arg1.value == "enable");
	form.runas.disabled = (form.arg1.value == "enable");
	form.use_data.disabled = (form.arg1.value == "enable");
	form.storagesize.disabled = (form.arg1.value == "enable");
	form.datacheck.disabled = (form.arg1.value == "enable");
	form.url.disabled = (form.arg1.value == "enable");
	form.branch.disabled = (form.arg1.value == "enable");
   }
}

function checkUSER(form)
{
if (form.runas.selectedIndex < 2 ) {
	form.arg2.value = form.runas.options[form.runas.selectedIndex].value;
	form.arg2.type = "hidden";
} else {
	form.arg2.value = "<?=$couchpotato_instance2_cfg['RUNAS'];?>";
	form.arg2.type = "text";
}
}

function checkDATADIR(form)
{
if (form.use_data.checked == false )
{
	form.arg5.value = form.arg4.value;
	form.arg5.type = "hidden";
}
else
{
	form.arg5.value = "<?=$couchpotato_instance2_datadir;?>";
	form.arg5.type = "text";
}
}

function checkSTORAGE(form)
{
form.arg6.value = form.storagesize.options[form.storagesize.selectedIndex].value;
}

function checkDATA(form)
{
form.arg7.value = form.datacheck.options[form.datacheck.selectedIndex].value;
}

function checkURL(form)
{
if (form.url.selectedIndex < 1 )
{
	form.arg8.value = form.url.options[form.url.selectedIndex].value;
	form.arg8.type = "hidden";
}
else
{
	form.arg8.value = "<?=$couchpotato_instance2_cfg['INSTALLURL'];?>";
	form.arg8.type = "text";
}
}

function checkBRANCH(form)
{
if (form.branch.selectedIndex < 1 )
{
	form.arg9.value = form.branch.options[form.branch.selectedIndex].value;
	form.arg9.type = "hidden";
}
else
{
	form.arg9.value = "<?=$couchpotato_instance2_cfg['BRANCH'];?>";
	form.arg9.type = "text";
}
}

checkUSER(document.couchpotato_instance2_settings);
checkDATADIR(document.couchpotato_instance2_settings);
checkSTORAGE(document.couchpotato_instance2_settings);
checkDATA(document.couchpotato_instance2_settings);
checkURL(document.couchpotato_instance2_settings);
checkBRANCH(document.couchpotato_instance2_settings);
</script>
]]>
</INLINE>
</FILE>

<!-- event handler -->
<FILE Name="/usr/local/emhttp/plugins/couchpotato_v2_instance2/event/disks_mounted" Mode="0770">
<INLINE>
<![CDATA[
#!/bin/bash
source /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg
if [ $SERVICE = enable ]; then
/etc/rc.d/rc.couchpotato_v2_instance2 start
fi
]]>
</INLINE>
</FILE>

<!-- event handler -->
<FILE Name="/usr/local/emhttp/plugins/couchpotato_v2_instance2/event/unmounting_disks" Mode="0770">
<INLINE>
<![CDATA[
#!/bin/bash
/etc/rc.d/rc.couchpotato_v2_instance2 stop
]]>
</INLINE>
</FILE>

<FILE Name="/tmp/couchpotato_v2_instance2-install" Run="/bin/bash">
<INLINE>
<![CDATA[
# include our config vars
source /boot/config/plugins/couchpotato_v2_instance2/couchpotato_v2.cfg

# create couchpotato_v2_instance2-writable directory for pid file
if [ ! -e /var/run/couchpotato_v2_instance2 ]; then
  mkdir /var/run/couchpotato_v2_instance2
  chown $RUNAS:users /var/run/couchpotato_v2_instance2
  chmod 0777 /var/run/couchpotato_v2_instance2
fi

if [ -e $INSTALLDIR ]; then
chmod -R 0777 $INSTALLDIR
fi
rm /tmp/couchpotato_v2_instance2-install
]]>
</INLINE>
</FILE>

<FILE Name="/var/log/plugins/couchpotato_v2_instance2">
<INLINE>
<![CDATA[

]]>
</INLINE>
</FILE>

Link to comment

Hi Switchman,

It's about control.

Every thursday there is a movie projected in house for a group of friends.

We share a imdb account where each one can add the movie he/she likes to watch to a watch list.

This watch list is the only source for second instance of couch potato.

In this way, by putting a priority on these downloads they don't end up in the middle of an endless que in sab.

Also they shall be moved by couch potato to a diff directory which is shared with the members of the movie club.

 

Maybe I do not completely understand the workings of couch and saB. Please enlighten me, because kis is always better.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...