Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
7973 lines (6808 sloc) 231 KB
#!/bin/sh
#[ -n "$DEBUG" ] && set -x -o pipefail -e
# AIO Script Version: 1.0.32 (May 19, 2017)
# By Ashley Townsend (Nozza) Copyright: Beerware License
################################################################################
# While using "nano" to edit this script (nano /aioscript.sh),
# Use the up, down, left and right arrow keys to navigate. Once done editing,
# Press "X" while holding "Ctrl", Press "Y" then press "Enter" to save changes
################################################################################
##### START OF CONFIGURATION SECTION #####
#
# In some instances of this script, the following variables must be defined
# by the user:
#
# cloud_server_port: Used to specify the port OwnCloud will be listening to.
# Needed due to some installs of N4F having trouble with
# the admin webgui showing up, even when browsing to the jail's IP.
#
#
# cloud_server_ip: This value is used to specify the ip address Owncloud
# will listen to. This is needed to keep the jail from
# listening on all ip's
#
###! OWNCLOUD / NEXTCLOUD INSTALLER CONFIG ! IMPORTANT ! DO NOT IGNORE ! #######
cloud_server_port="81"
cloud_server_ip="192.168.1.200"
cloud_database_name="nextcloud" # Only needed for nextcloud, owncloud can ignore
owncloud_version="9.0.0" # The version of ownCloud you wish to install.
# You can set this to "latest" but it isn't recommended
# as owncloud updates may require an updated script.
nextcloud_version="11.0.2" # Same as owncloud_version but for nextcloud.
##! END OF OWNCLOUD / NEXTCLOUD INSTALLER CONFIG ! IMPORTANT ! DO NOT IGNORE ! ##
###! No need to edit below here unless the script asks you to !###
##### OWNCLOUD / NEXTCLOUD UPDATER CONFIG #####
owncloud_update="latest" # This can be safely ignored unless you are planning
# on using the updater in this script (not recommended)
# It's best to leave it alone and let owncloud update itself
################################################################################
##### OTHER APPS CONFIGURATION #####
jail_ip="192.168.1.200" # ! No need to change this for OwnCloud installs !
# Only change this for OTHER jails/apps
# MUST be different to cloud_server_ip if you have
# installed OwnCloud previously.
################################################################################
###! EMBY CONFIG !###
emby_def_update_ver="3.2.13.0" # You can find release numbers here:
# https://github.com/MediaBrowser/Emby/releases
# Example, To use the beta: "3.0.5947-beta"
# Example, To use the dev: "3.0.5966.988-dev"
################################################################################
###! SABNZBD CONFIG !###
sab_ver="2.0.0" # You can find release numbers here:
# https://github.com/sabnzbd/sabnzbd/releases
################################################################################
###! SUBSONIC / MADSONIC CONFIG !###
subsonic_ver="6.0" # You can find release numbers here:
# sourceforge.net/projects/subsonic/files/subsonic
madsonic_ver="6.2.9040" # http://beta.madsonic.org/pages/download.jsp
################################################################################
###! THEBRIG CONFIG !###
# Define where to install TheBrig
thebriginstalldir="/mnt/Storage/System/Jails"
thebrigbranch="alcatraz" # Define which version of TheBrig to install
# master - For 9.0 and 9.1 FreeBSD versions
# working - For 9.1 and 9.2 FreeBSD versions
# alcatraz - For 9.3 and 10.x FreeBSD versions
# thebrigversion="3" # Not needed anymore
###! END OF THEBRIG CONFIG !###
################################################################################
### OTHER ###
# Modify this to reflect your storage location
mystorage="/mnt/Storage"
myappsdir="/mnt/Storage/Apps"
##################################################
###! CALIBRE CONFIG !#############################
# Modify to where you store all of your books.
CALIBRELIBRARYPATH="/mnt/Storage/Media/Books"
##################################################
###! MUNIN CONFIG !###############################
# Enter the jail name you wish to run Munin in
#muninjail="Munin" # Unused currently
# (For a future idea)
##################################################
###! NZBGET CONFIG !##############################
#nzbgetjail="NZBGet" # Unused currently
# (For a future idea)
##################################################
###! DELUGE CONFIG !##############################
#delugejail="Deluge" # Unused currently
user_ID="UID"
deluge_user="JonDoe"
deluge_user_password="MyC0mpL3xPass"
##################################################
##### END OF CONFIGURATION SECTION #####
################################################################################
# Get IP
jailip=$(ifconfig | grep -e "inet" -e "addr:" | grep -v "inet6" | grep -v "127.0.0.1" | head -n 1 | awk '{print $2}')
#Grab the date & time to be used later
date=$(date +"%Y.%m.%d-%I.%M%p")
# Add some colour!
nc='\033[0m' # Default Text (No Formatting / No Color)
alt='\033[0;31m' # Alert Text
emp='\033[1;31m' # Emphasis Text
msg='\033[1;37m' # Message Text
url='\033[1;32m' # URL
qry='\033[0;36m' # Query Text
ssep='\033[1;30m#----------------------#\033[0m' # Small Line Separator
msep='\033[1;30m#--------------------------------------#\033[0m' # Medium Line Separator
sep='\033[1;30m----------------------------------------------------------------------\033[0m' # Line Separator
cmd='\033[1;35m' # Command to be entered
fin='\033[0;32m' # Green Text
inf='\033[0;33m' # Information Text
ul='\033[4m' # Underline Text
lbt='\033[1;34m' # Light Blue Text
yt='\033[1;33m' # Yellow Text
lct='\033[1;36m' # Light Cyan Text
ca='\033[1;30m' # Currently Unavailable (Dark Grey Text)
################################################################################
##### CONTACT
################################################################################
gethelp ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} Ways of contacting me / Getting help from others:${nc}"
echo -e "${sep}"
echo " "
echo -e "${fin} ${ul}My Discord Support${fin} (Usually faster responses):${nc}"
echo -e "${msg} https://discord.gg/0bXnhqvo189oM8Cr${nc}"
echo -e "${fin} ${ul}My Email${fin} (Discord is easier):${nc}"
echo -e "${msg} support@vengefulsyndicate.com${nc}"
echo -e "${fin} ${ul}Forums:${nc}"
echo -e "${msg} NAS4Free Forums - NextCloud/OwnCloud:${nc}"
echo -e "${url} http://forums.nas4free.org/viewtopic.php?f=79&t=9383${nc}"
echo -e "${msg} [VS] Forums:${nc}"
echo -e "${url} forums.vengefulsyndicate.com${nc}"
echo " "
echo -e "${fin} Find an issue with the script or have a suggestion?${nc}"
echo -e "${msg} Drop a message using the above or head here:${nc}"
echo -e "${url} https://github.com/Nozza-VS/misc-code/issues"
echo " "
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
################################################################################
##### Debug
################################################################################
OPTIND=1 # Reset in case getopts has been used previously in the shell.
while getopts "dnvh" opt; do
case $opt in
h) echo " "
echo -e "${inf} -v ${msg}Run the script run in verbose mode${nc}"
echo -e "${inf} -d ${msg}Print command traces before executing command${nc}"
echo -e "${inf} -n ${msg}Read commands but do not execute them${nc}"
echo " "
exit 1;;
d) set -x;;
n) set -n;;
v) set -v;;
*) echo " "
echo -e "${alt} Invalid choice, please try again${nc}"
echo " "
exit 1;;
esac
done
################################################################################
##### OTHER OPTIONS
################################################################################
#------------------------------------------------------------------------------#
### CLOUD - ENABLE MEMORY CACHING
#TODO: Add option for automatic or manual (Will also need to ask if user is
# using default installation folder otherwise the auto version won't work)
#------------------------------------------------------------------------------#
owncloud.enablememcache ()
{
while [ "$choice" ]
do
echo " 'memcache.local' => '\OC\Memcache\APCu'," >> /usr/local/www/owncloud/config/memcache.txt
cp /usr/local/www/owncloud/config/config.php /usr/local/www/owncloud/config/old_config.bak
cat "/usr/local/www/owncloud/config/old_config.bak" | \
sed '21r /usr/local/www/owncloud/config/memcache.txt' > \
"/usr/local/www/owncloud/config/config.php"
rm /usr/local/www/owncloud/config/memcache.txt
/usr/local/etc/rc.d/lighttpd restart
echo " "
echo "${sep}"
echo " "
echo -e " Head to your owncloud admin page/refresh it"
echo -e " There should no longer be a message at the top about memory caching"
echo -e " If it didn't work follow these steps:"
echo -e " "
echo -e "${msg} This is entirely optional. Edit config.php:${nc}"
echo -e "${msg} Default location is:${nc}"
echo -e "\033[1;36m /usr/local/www/owncloud/config/config.php${nc}"
echo -e "${msg} Add the following right above the last line:${nc}"
echo -e "\033[1;33m 'memcache.local' => '\OC\Memcache\APCu',${nc}"
echo " "
echo -e "${msg} Once you've saved the file, restart the server with:${nc}"
echo -e "${cmd} /usr/local/etc/rc.d/lighttpd restart"
echo " "
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
nextcloud.enablememcache ()
{
while [ "$choice" ]
do
echo " 'memcache.local' => '\OC\Memcache\APCu'," >> /usr/local/www/nextcloud/config/memcache.txt
cp /usr/local/www/nextcloud/config/config.php /usr/local/www/nextcloud/config/old_config.bak
cat "/usr/local/www/nextcloud/config/old_config.bak" | \
sed '21r /usr/local/www/nextcloud/config/memcache.txt' > \
"/usr/local/www/nextcloud/config/config.php"
rm /usr/local/www/nextcloud/config/memcache.txt
/usr/local/etc/rc.d/lighttpd restart
echo " "
echo "${sep}"
echo " "
echo -e " Head to your nextcloud admin page/refresh it"
echo -e " There should no longer be a message at the top about memory caching"
echo -e " If it didn't work follow these steps:"
echo -e " "
echo -e "${msg} This is entirely optional. Edit config.php:${nc}"
echo -e "${msg} Default location is:${nc}"
echo -e "\033[1;36m /usr/local/www/nextcloud/config/config.php${nc}"
echo -e "${msg} Add the following right above the last line:${nc}"
echo -e "\033[1;33m 'memcache.local' => '\OC\Memcache\APCu',${nc}"
echo " "
echo -e "${msg} Once you've saved the file, restart the server with:${nc}"
echo -e "${cmd} /usr/local/etc/rc.d/lighttpd restart"
echo " "
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
################################################################################
##### INFORMATION / ABOUT
################################################################################
#------------------------------------------------------------------------------#
### ABOUT: THIS SCRIPT
about.thisscript ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: This Script${nc}"
echo " "
echo -e "${msg} I've been maintaining the 'OwnCloud in a Jail' NAS4Free script${nc}"
echo -e "${msg} for some time now and I tend to do a lot of messing around in jails on NAS4Free${nc}"
echo -e "${msg} As well as helping others set up jails for different things.${nc}"
echo " "
echo -e "${msg} So I figured, 'why am i always manually doing all this when i can script it?'${nc}"
echo -e "${msg} And now here we are! Aiming to have a mostly automated script for some of the${nc}"
echo -e "${msg} most common jail setups and hopefully some useful info about these setups${nc}"
echo -e "${msg} to help aid with any possible issues without google search frenzies!${nc}"
echo " "
echo -e "${msg} Wish to contribute? Feel free to drop me a message anyhere listed in the${nc}"
echo -e "${msg} 'Contact / Get Help' menu.${nc}"
echo " "
echo -e "${msg} Like my work enough to buy me a pizza? Please do!${nc}"
echo -e "${url} https://www.paypal.me/AshleyTownsend${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: MYSQL
about.mysql ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: MySQL${nc}"
echo " "
echo -e "${msg} MySQL is an open-source relational database management system (RDBMS). The SQL${nc}"
echo -e "${msg} abbreviation stands for Structured Query Language. The MySQL development${nc}"
echo -e "${msg} project has made its source code available under the terms of the GNU General${nc}"
echo -e "${msg} Public License, as well as under a variety of proprietary agreements.${nc}"
echo " "
echo -e "${msg} MySQL is a popular choice of database for use in web applications, and is a${nc}"
echo -e "${msg} central component of the widely used LAMP open-source web application software${nc}"
echo -e "${msg} stack (and other 'AMP' stacks).${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: CLOUD STORAGE
about.cloudstorage ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: Cloud Storage${nc}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: OWNCLOUD
about.owncloud ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: ownCloud${nc}"
echo " "
echo -e "${msg} ownCloud is a self-hosted file sync & share server. It provides access to your${nc}"
echo -e "${msg} data through a web interface, sync clients or WebDAV while providing a platform${nc}"
echo -e "${msg} to view, sync and share across devices easily — all under your control.${nc}"
echo " "
echo -e "${msg} ownCloud’s open architecture is extensible via a simple but powerful API for${nc}"
echo -e "${msg} applications and plugins and it works with any storage.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: NEXTCLOUD
about.nextcloud ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: NextCloud${nc}"
echo " "
echo -e "${emp} 'About: NextCloud' hasn't been added to this script yet :(${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: NEXTCLOUD / OWNCLOUD DIFFERENCES
about.cloud.differences ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: Difference between NextCloud & ownCloud${nc}"
echo " "
echo -e "${emp} This info hasn't been added to this script yet :(${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: PYDIO
about.pydio ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: Pydio${nc}"
echo " "
echo -e "${msg} Pydio (formely AjaXplorer) is a mature open source software solution for${nc}"
echo -e "${msg} file sharing and synchronization. With intuitive user interfaces${nc}"
echo -e "${msg} (web/mobile/desktop), Pydio provides enterprise-grade features to gain back${nc}"
echo -e "${msg} control and privacy of your data. Pydio is hosted exclusively on your private${nc}"
echo -e "${msg} server or cloud so you can rest assured that files are securely managed under your control.${nc}"
echo -e "${msg} your control.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: EMBY SERVER
about.emby ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: Emby Media Server${nc}"
echo " "
echo -e "${msg} Emby Server is a home media server built on top of other popular open source${nc}"
echo -e "${msg} technologies such as Service Stack, jQuery, jQuery mobile, and Mono.${nc}"
echo " "
echo -e "${msg} It features a REST-based API with built-in documention to facilitate client${nc}"
echo -e "${msg} development. It also has client libraries for API to enable rapid development.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: PLEX MEDIA SERVER
about.plex ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: Plex Media Server${nc}"
echo " "
echo -e "${msg} Plex organizes all of your personal media so you can enjoy it,${nc}"
echo -e "${msg} no matter where you are.${nc}"
echo " "
echo -e "${msg} Plex's front-end media player, Plex Media Player (formerly Plex Home Theater),${nc}"
echo -e "${msg} allows the user to manage and play audiobooks, music, photos, podcasts, and${nc}"
echo -e "${msg} videos from a local or remote computer running Plex Media Server. Additionally,${nc}"
echo -e "${msg} the integrated Plex Online service provides the user with a growing list of${nc}"
echo -e "${msg} community-driven plugins for online content such as Netflix, Hulu, etc.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: SUBSONIC
about.subsonic ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: Subsonic${nc}"
echo " "
echo -e "${msg} Subsonic is a free, web-based media streamer, providing ubiqutious access${nc}"
echo -e "${msg} to your music. Use it to share your music with friends, or to listen to your${nc}"
echo -e "${msg} own music while at work. You can stream to multiple players simultaneously,${nc}"
echo -e "${msg} for instance to one player in your kitchen and another in your living room.${nc}"
echo " "
echo -e "${msg} Subsonic is designed to handle very large music collections${nc}"
echo -e "${msg} (hundreds of gigabytes). Although optimized for MP3 streaming, it works for any${nc}"
echo -e "${msg} audio or video format that can stream over HTTP, for instance AAC and OGG.${nc}"
echo -e "${msg} By using transcoder plug-ins, Subsonic supports on-the-fly conversion and${nc}"
echo -e "${msg} streaming of virtually any audio format, including WMA, FLAC, APE, Musepack,${nc}"
echo -e "${msg} WavPack and Shorten.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: SONARR
about.sonarr ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: Sonarr (Formerly NZBDrone)${nc}"
echo " "
echo -e "${msg} Sonarr is a PVR for Usenet and BitTorrent users. It can monitor multiple RSS${nc}"
echo -e "${msg} feeds for new episodes of your favorite shows and will grab, sort and rename${nc}"
echo -e "${msg} them. It can also be configured to automatically upgrade the quality of files${nc}"
echo -e "${msg} already downloaded when a better quality format becomes available.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: COUCHPOTATO
about.couchpotato ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: CouchPotato${nc}"
echo " "
echo -e "${msg} CouchPotato (CP) is an automatic NZB and torrent downloader.${nc}"
echo -e "${msg} You can keep a 'movies I want'-list and it will search for NZBs/torrents${nc}"
echo -e "${msg} of these movies every X hours. Once a movie is found, it will send it to${nc}"
echo -e "${msg} SABnzbd/NZBGet or download the torrent to a specified directory.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: HEADPHONES
about.headphones ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: Headphones${nc}"
echo " "
echo -e "${msg} Headphones is an automated music downloader for NZB and Torrent, written in${nc}"
echo -e "${msg} Python. It supports SABnzbd, NZBget, Transmission, µTorrent, Deluge and${nc}"
echo -e "${msg} Blackhole.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: THEBRIG
about.thebrig ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: TheBrig${nc}"
echo " "
echo -e "${msg} thebrig is a set of PHP pages used to create & manage FreeBSD jails on NAS4Free${nc}"
echo " "
echo -e "${msg} The main advantage of thebrig is that it leverages the existing webgui control${nc}"
echo -e "${msg} and accounting mechanisms found within Nas4Free, and can be used on an embedded${nc}"
echo -e "${msg} installation.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: DELUGE
about.deluge ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: Deluge${nc}"
echo " "
echo -e "${msg} Deluge is a lightweight, Free Software, cross-platform BitTorrent client.${nc}"
echo " "
echo -e "${msg} It provides: Full Encryption, WebUI, Plugin System & Much more${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: NZBGET
about.nzbget ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: NZBGet${nc}"
echo " "
echo -e "${msg} NZBGet is a binary downloader, which downloads files from Usenet based on${nc}"
echo -e "${msg} information given in nzb-files.${nc}"
echo " "
echo -e "${msg} NZBGet is written in C++ and is known for its extraordinary performance and${nc}"
echo -e "${msg} efficiency.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: SABNZBD
about.sabnzbd ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: SABnzbd${nc}"
echo " "
echo -e "${msg} SABnzbd makes Usenet as simple and streamlined as possible by automating${nc}"
echo -e "${msg} everything we can. All you have to do is add an .nzb. SABnzbd takes over from${nc}"
echo -e "${msg} there, where it will be automatically downloaded, verified, repaired, extracted${nc}"
echo -e "${msg} and filed away with zero human interaction.${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### ABOUT: TEAMSPEAK 3
about.teamspeak3 ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} About: Teamspeak 3${nc}"
echo " "
echo -e "${msg} ${nc}"
echo -e "${sep}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### Clean ports tree
clean.portstree ()
{
echo " rm -rf /usr/ports/*/*/work"
}
################################################################################
##### HOW-TO'S
################################################################################
#------------------------------------------------------------------------------#
### OWNCLOUD - HOW-TO: FINISH SETUP
#------------------------------------------------------------------------------#
owncloud.howto.finishsetup ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} OwnCloud - How to finalize setup${nc}"
echo -e "${sep}"
echo " "
echo -e "${emp} Follow these instructions carefully${nc}"
echo " "
echo -e "${msg} In a web browser, head to: ${url}https://$cloud_server_ip:$cloud_server_port${nc}"
echo " "
echo -e "${msg} Admin Username: ${inf}Enter your choice of username${nc}"
echo -e "${msg} Admin Password: ${inf}Enter your choice of password${nc}"
echo " "
echo -e "${alt} Click Database options and choose MySQL${nc}"
echo -e "${msg} Database username: ${inf}root${nc}"
echo -e "${msg} Database password: ${inf}THE PASSWORD YOU ENTERED EARLIER FOR MYSQL${nc}"
echo -e "${msg} Database host: ${inf}Leave as is (Should be localhost)${nc}"
echo -e "${msg} Database name: ${inf}Your choice (owncloud is fine)${nc}"
echo " "
echo -e "${emp} Click Finish Setup, the page will take a moment to refresh${nc}"
echo -e "${msg} After it refreshes, if you are seeing a 'Trusted Domain' error,${nc}"
echo -e "${msg} head back to the owncloud menu and select option 4.${nc}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
################################################################################
##### HOW-TO'S: EMBY
################################################################################
#------------------------------------------------------------------------------#
### EMBY - HOW-TO: RESTART THE SERVER
emby.howto.restartserver ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} Emby - How to restart your server${nc}"
echo -e "${sep}"
echo " "
echo -e "${msg} If you need to restart the server, you can with:${nc}"
echo -e "${cmd} service emby-server restart${nc}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
################################################################################
##### HOW-TO'S: THEBRIG
################################################################################
#------------------------------------------------------------------------------#
### THEBRIG - HOW-TO: INSTALL THEBRIG
#------------------------------------------------------------------------------#
thebrig.howto.installthebrig ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} TheBrig - How to install TheBrig manually${nc}"
echo -e "${sep}"
echo " "
# Create directory
# mkdir -p ${thebriginstalldir}
# change to directory
# cd ${thebriginstalldir}
# Fetch TheBrig installer
# fetch https://raw.githubusercontent.com/fsbruva/thebrig/alcatraz/thebrig_install.sh
# Execute the script
# /bin/sh thebrig_install.sh ${thebriginstalldir} &
# echo " 1: Go to Extensions page in WebGUI > TheBrig > Maintenance > Rudimentary Config (Should take you to this config by default)"
# echo " 2: Click 'Save' (Make sure 'Installation folder' is correct first,"
# echo " we want it outside of the NAS4Free operating system drive"
# echo " 3: Head to Tarball Management (Underneath 'Maintenance') > Clicked Query!"
# echo " 4: Chose 'Release: 10.2-RELEASE' from dropdown menu (Should be selected by default after clicking query)"
# echo " 5: Tick all boxes below (Only 'base.txz' and 'lib32.txz' are really needed but grab all anyway)"
# echo " 6: Click Fetch, wait a while for the downloads to finish"
# echo " Once all the download bars are gone you can proceed to making your jail"
# echo " Instructions on creating a jail can be found in the 'more info' menu"
echo -e "${emp} This part of the script is unfinished currently :(${nc}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### THEBRIG - HOW-TO: CREATE A JAIL
#------------------------------------------------------------------------------#
thebrig.howto.createajail ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} TheBrig - How to create a jail${nc}"
echo -e "${sep}"
echo " "
echo -e "${emp} This assumes you have installed TheBrig already and${nc}"
echo -e "${emp} have done the initial configuration.${nc}"
echo " "
echo -e "${msg} Head to your NAS webgui, you should see a menu${nc}"
echo -e "${msg} named '${inf}Extensions${msg}'. Hover over it and click '${inf}TheBrig${msg}'${nc}"
echo -e "${msg} From here, click the '${inf}+${msg}' icon${nc}"
echo -e "${msg} On the new page, there are some things to change${nc}"
echo " "
echo -e "${fin} OPTIONAL ${msg}things are: '${inf}Jail name${msg}', '${inf}Path to jail${msg}'${nc}"
echo -e "${msg} & '${inf}Description${msg}'${nc}"
echo " "
echo -e "${emp} MUST ${msg}change items are: '${inf}Jail Network settings${msg}'"
echo -e "${msg} & '${inf}Official FreeBSD Flavor${msg}'${nc}"
echo " "
echo -e "${msg} For Jail IP enter an address that is NOT your NAS IP${nc}"
echo -e "${msg} or conflicts with any other IP on your network${nc}"
echo -e "${msg} It must be filled out like so: ${inf}192.168.1.200/24${nc}"
echo -e "${msg} Once you have entered your desired IP, click '${inf}<<${msg}'.${nc}"
echo " "
echo -e "${msg} For FreeBSD Flavor, select at least 1 of each type:${nc}"
echo -e "${msg} '${inf}base${msg}' & '${inf}lib32${msg}'${nc}"
echo " "
echo -e "${msg} Now press '${inf}Add${msg}' at the bottom and that should be it!${nc}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### THEBRIG - HOW-TO: MOUNT YOUR STORAGE IN JAIL WITH FSTAB
#------------------------------------------------------------------------------#
thebrig.howto.mountviafstab ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} TheBrig - How to mount any storage folder in a jail using fstab${nc}"
echo -e "${sep}"
echo " "
echo -e "${msg} First, you need to create a folder in the jail matching the name of the folder to mount${nc}"
echo -e "${msg} Example: mkdir /mnt/Storage/Jails/JailName/mnt/MEDIA${nc}"
echo -e "${msg} Now, head to your NAS webgui and go to '${inf}Extensions${msg}' -> '${inf}TheBrig.${nc}"
echo -e "${msg} Click the settings icon for the jail you wish to have your folder mounted in.${nc}"
echo -e "${msg} Now click the '${inf}More${msg}' button near the bottom.${nc}"
echo -e "${msg} You should be presented with a lot more options.${nc}"
echo -e "${msg} Look for '${inf}Fstab for current jail${msg}'${nc}"
echo -e "${msg} An example of what to set in here is:${nc}"
echo -e "${msg} /mnt/Storage/Media /mnt/Jails/JailName/mnt/MEDIA nullfs rw 0 0${nc}"
echo -e "${msg} /mnt/Storage/Media = The folder you want mounted${nc}"
echo -e "${msg} /mnt/Jails/JailName/mnt/MEDIA = The jail folder to mount in${nc}"
echo -e "${msg} 'rw 0 0' at the end = the jail may write to the folder${nc}"
echo -e "${msg} 'ro 0 0' at the end = the jail may NOT write to the folder${nc}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### THEBRIG - HOW-TO: ENABLE PORTS TREE
#------------------------------------------------------------------------------#
thebrig.howto.enableportstree ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} TheBrig - How to enable the ports tree in jails:"
echo -e "${sep}"
echo " "
echo -e "${msg} Head to your NAS webgui and go to '${inf}Extensions${msg}' -> '${inf}TheBrig.${nc}"
echo -e "${msg} From here, you want to click '${inf}Updates${msg}' and then '${inf}Central Ports.${nc}"
echo -e "${msg} First thing to do here is click '${inf}Fetch & Update${msg}'${nc}"
echo -e "${msg} After it has done, tick the box next to the name of the jail you wish${nc}"
echo -e "${msg} to enable the ports tree in. Finally, click '${inf}Save${msg}'.${nc}"
echo -e "${msg} Optionally you may also tick the '${inf}Cronjob${msg}' box and click '${inf}Save${msg}'.${nc}"
echo -e "${msg} This won't automatically apply the updates but it will make it so in future,${nc}"
echo -e "${msg} You may come back to this page and simply click '${inf}Update${msg}'${nc}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### THEBRIG - ABOUT: RUDIMENTARY CONFIGURATION
#------------------------------------------------------------------------------#
info.thebrig.rudimentaryconfig ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} TheBrig - Rudimentary Configuration"
echo -e "${sep}"
echo " "
echo -e "${msg} Head to that new ${fin}Extensions->TheBrig${msg} page in your WebGUI${nc}"
echo -e "${msg} After making sure the '${fin}Installation folder${msg}' =${fin} ${mystorage}/Jails${msg}, Click '${inf}Save${msg}'${nc}"
echo " "
echo -e "${msg} Now head to '${fin}Tarball Management${msg}' (Underneath 'Maintenance') > Click ${inf}Query!${nc}"
echo -e "${msg} It should now have '${fin}10.2-RELEASE${msg}' in the new dropdown menu${nc}"
echo -e "${msg} (Select it if it isn't already)${nc}"
echo -e "${msg} Tick all boxes below that ${nc}"
echo -e "${msg} (Only '${fin}base.txz${msg}' and '${fin}lib32.txz${msg}' are really needed${nc}"
echo -e "${msg} but let's grab them all just in case)${nc}"
echo -e "${msg} Click '${inf}Fetch${msg}', wait some time for the downloads to finish${nc}"
echo -e "${msg} Once all the download bars are gone you can proceed to making your jail${nc}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### EMBY SERVER - HOW-TO: UPDATE FFMPEG FROM PORTS TREE (FOR TRANSCODING)
#------------------------------------------------------------------------------#
emby.howto.updateffmpeg ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} Emby - How to update FFMpeg from ports tree:"
echo -e "${sep}"
echo " "
echo -e "${msg} Remove default FFMpeg package:${nc}"
echo -e "${cmd} pkg delete -f ffmpeg${nc}"
echo -e "${msg} Reinstall FFMpeg from ports with 'lame' & 'ass' options${nc}"
echo -e "${msg} enabled. To enable an option, highlight it using the arrow${nc}"
echo -e "${msg} keys and press space (I also enable 'OPUS' option)${nc}"
echo -e "${cmd} cd /usr/ports/multimedia/ffmpeg${nc}"
echo -e "${cmd} make config${nc}"
echo -e "${msg} This final step will take some time and you will also${nc}"
echo -e "${msg} get a few prompts, just press enter each time.${nc}"
echo -e "${cmd} make install clean${nc}"
echo -e "${msg} Once it is done, restart the emby server${nc}"
echo -e "${cmd} service emby-server restart${nc}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
#------------------------------------------------------------------------------#
### TEAMSPEAK 3 SERVER - HOW-TO: Set up the server bot
#------------------------------------------------------------------------------#
teamspeak3.howto.setupbot ()
{
while [ "$choice" ]
do
echo -e "${sep}"
echo -e "${inf} Emby - How to set up the server bot:"
echo -e "${sep}"
echo " "
echo -e "${msg} ${nc}"
echo " "
echo -e "${msep}"
echo -e "${emp} Press Enter To Go Back To The Menu${nc}"
echo -e "${msep}"
read choice
case $choice in
*)
return
;;
esac
done
}
################################################################################
##### FIXES
################################################################################
#------------------------------------------------------------------------------#
### OWNCLOUD - TRUSTED DOMAIN WARNING FIX
#------------------------------------------------------------------------------#
owncloud.trusteddomain.fix ()
{
# Confirm with the user
echo " "
echo -e "${emp} Please finish the owncloud setup before continuing${nc}"
echo -e "${emp} Can ignore the next few steps if you've already done it.${nc}"
echo -e "${msg} Head to ${url}https://$cloud_server_ip:$cloud_server_port ${msg}to do this.${nc}"
echo -e "${msg} Fill out the page you are presented with and hit finish${nc}"
echo " "
echo -e "${msg} Admin username & password = whatever you choose${nc}"
echo " "
echo -e "${emp} Make sure you click 'Storage & database'${nc}"
echo " "
echo -e "${msg} Database user = ${qry}root${nc} | Database password = ${nc}"
echo -e "${msg} the ${qry}mysql password${msg} you chose earlier during the script.${nc}"
echo -e "${msg} Database name = your choice (just ${qry}owncloud${msg} is fine)${nc}"
echo " "
echo " When trying to access owncloud"
read -r -p " do you have a 'untrusted domain' error? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
# If yes, let's fix that.
echo " "
echo -e "${url} Doing some last second changes to fix that..${nc}"
echo " "
# Prevent "Trusted Domain" error
echo " '${server_ip}'," >> /usr/local/www/owncloud/config/trusted.txt
cp /usr/local/www/owncloud/config/config.php /usr/local/www/owncloud/config/old_config.bak
cat "/usr/local/www/owncloud/config/old_config.bak" | \
sed '8r /usr/local/www/owncloud/config/trusted.txt' > \
"/usr/local/www/owncloud/config/config.php"
rm /usr/local/www/owncloud/config/trusted.txt
echo -e " Done, continuing with the rest of the script"
;;
*)
# If no, just continue like normal.
echo " "
echo -e "${qry} Great!, no need to do anything, continuing with script..${nc}"
echo " "
;;
esac
}
#------------------------------------------------------------------------------#
### OWNCLOUD - Populating Raw Post Data Fix
#------------------------------------------------------------------------------#
cloud.phpini ()
{
echo " "
echo -e "${sep}"
echo -e "${msg} Modifying php.ini${nc}"
echo -e "${msg} (/usr/local/etc/php.ini)${nc}"
echo -e "${sep}"
echo " "
echo always_populate_raw_post_data = -1 > /usr/local/etc/php.ini
}
################################################################################
##### OTHER
################################################################################
#------------------------------------------------------------------------------#
### EMBY - RECOMPILE FROM PORTS
#------------------------------------------------------------------------------#
recompile.imagemagick ()
{
recompile.imagemagick.continue ()
{
echo -e "${msep}"
echo -e "${emp} Press Enter To Continue${nc}"
echo -e "${msep}"
read -r -p " " response
case "$response" in
*)
# Otherwise continue with backup...
;;
esac
}
# Confirm with the user
echo -e "${msg} These steps could take some time${nc}"
read -r -p " Would you like to recompile these now? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
echo " "
echo -e "${sep}"
echo -e "${fin} First, lets do ImageMagick${nc}"
echo -e "${msg} When the options pop up, disable (By pressing space when its highlighted):${nc}"
echo -e "${inf} 16BIT_PIXEL ${msg}(to increase thumbnail generation performance)${nc}"
echo -e "${msg} and then press 'Enter'${nc}"
echo " "
recompile.imagemagick.continue
cd /usr/ports/graphics/ImageMagick && make deinstall
make clean && make clean-depends
make config
echo " "
echo -e "${sep}"
echo -e "${msg} Press 'OK'/'Enter' if any box that follows.${nc}"
echo -e "${msg} (There shouldn't be any that pop up)${nc}"
echo -e "${sep}"
echo " "
recompile.imagemagick.continue
make install clean
#make -DBATCH install clean
echo " "
echo -e "${sep}"
echo -e "${msg} Finished with the recompiling!${nc}"
echo -e "${sep}"
echo " "
;;
esac
}
recompile.ffmpeg ()
{
recompile.ffmpeg.continue ()
{
echo -e "${msep}"
echo -e "${emp} Press Enter To Continue${nc}"
echo -e "${msep}"
read -r -p " " response
case "$response" in
*)
# Otherwise continue with backup...
;;
esac
}
# Confirm with the user
echo -e "${msg} These steps could take some time${nc}"
read -r -p " Would you like to recompile these now? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
echo " "
echo -e "${sep}"
echo -e "${fin} Great, now ffmpeg${nc}"
echo -e "${sep}"
echo " "
cd /usr/ports/multimedia/ffmpeg && make deinstall
echo " "
echo -e "${sep}"
echo -e "${msg} When the options pop up, enable (By pressing space when its highlighted):${nc}"
echo -e "${inf} ASS ${msg}(required for subtitle rendering)${nc}"
echo -e "${inf} LAME ${msg}(required for mp3 audio transcoding -${nc}"
echo -e "${inf} ${msg}disabled by default due to mp3 licensing restrictions)${nc}"
echo -e "${inf} OPUS ${msg}(required for opus audio codec support)${nc}"
echo -e "${inf} X265 ${msg}(required for H.265 video codec support${nc}"
echo -e "${msg} Then press 'OK' for every box that follows.${nc}"
echo -e "${msg} This one may take a while, please be patient${nc}"
echo -e "${sep}"
echo " "
recompile.ffmpeg.continue
make clean
make clean-depends
make config
echo " "
echo -e "${sep}"
echo -e "${msg} Press 'OK'/'Enter' for any box that follows.${nc}"
echo -e "${sep}"
echo " "
recompile.ffmpeg.continue
#make install clean
make -DBATCH install clean
echo " "
echo -e "${sep}"
echo -e "${msg} Finished with the recompiling!${nc}"
echo -e "${sep}"
echo " "
;;
esac
}
emby.server.improvements ()
{
echo " "
}
################################################################################
##### INSTALLERS
# TODO: Finish the rest of the installers
################################################################################
#------------------------------------------------------------------------------#
### MYSQL INSTALL
install.mysql ()
{
webmin ()
{
# Confirm with the user
read -r -p " Install Webmin? [y/N]" response
case "$response" in
[yY][eE][sS]|[yY])
# If yes, then continue
echo -e "${fin} Setting up Webmin..${nc}"
pkg install -y webmin
echo 'webmin_enable="YES"' >> /etc/rc.conf
/usr/local/lib/webmin/setup.sh
/usr/local/etc/rc.d/webmin restart
echo -e "${msg} You should now be able to visit${nc}"
echo -e "${url} http://jailip:10000 ${msg}and log in to webmin.${nc}"
echo " "
;;
*)
# Otherwise exit...
echo " "
echo -e "${inf} Skipping Webmin..${nc}"
echo " "
;;
esac
}
phpmyadmin ()
{
echo " "
mkdir /usr/local/www/phpMyAdmin/config && chmod o+w /usr/local/www/phpMyAdmin/config
chmod o+r /usr/local/www/phpMyAdmin/config.inc.php
echo -e "${emp} Follow these instructions carefully before continuing:${nc}"
echo " "
echo -e "${msg} 1: In your web browser, go to ${url}http://jailip/phpMyAdmin/setup${nc}"
echo -e "${msg} 2: Click ${cmd}'New server'${msg} and select the ${cmd}'Authentication'${msg} tab.${nc}"
echo -e "${msg} 3: Under the ${cmd}'Authentication type'${msg} choose ${cmd}'http'${nc}"
echo -e "${msg} from the drop-down list (prevents storing login${nc}"
echo -e "${msg} credentials directly in config.inc.php)${nc}"
echo -e "${msg} 4: Also remove ${cmd}'root'${msg} from the ${cmd}'User for config auth'${nc}"
echo -e "${msg} 5: Now click ${cmd}'Apply'${msg} and you'll return to the Overview page.${nc}"
echo -e "${msg} 6: Finally, Click ${cmd}'Save'${msg} to save your configuration in${nc}"
echo -e "${msg} /usr/local/www/phpMyAdmin/config/config.inc.php.${nc}"
echo " "
echo " Only continue once you have done the above steps"
read -r -p " Continue? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
# If yes, then continue
echo -e "${url} Great! Moving on..${nc}"
#Now let’s move that file up one directory to /usr/local/www/phpMyAdmin where phpMyAdmin can make use of it.
mv /usr/local/www/phpMyAdmin/config/config.inc.php /usr/local/www/phpMyAdmin
rm -r /usr/local/www/phpMyAdmin/config
chmod o-r /usr/local/www/phpMyAdmin/config.inc.php
echo " "
;;
*)
# Otherwise exit...
echo " "
echo -e "${alt} phpMyAdmin wont work without setting it up.${nc}"
echo -e "${msg} It's not required though so skipping..${nc}"
echo " "
;;
esac
}
dbtype ()
{
echo " "
echo -e "${emp} Choose between MariaDB or MySQL:${nc}"
echo " "
echo -e "${msg} 1: MariaDB${nc}"
echo -e "${msg} 2: MySQL${nc}"
echo " "
echo " Choose carefully, in some cases this cannot be changed!"
read -r -p " Make your selection? [1 or 2] " response
case "$response" in
[1])
echo " Installing MariaDB"
echo " "
pkg install -y mariadb10-server
;;
[2])
echo " Installing MySQL"
echo " "
pkg install -y mysql56-server
;;
*)
# Otherwise exit...
echo " "
echo -e "${alt} No DB Selected${nc}"
echo " "
;;
esac
}
echo " "
echo -e "${sep}"
echo -e "${msg} Welcome to the MySQL guided setup script!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's start with downloading some packages.${nc}"
echo -e "${msg} If you get an error about '${qry}package management tool${nc}"
echo -e "${qry} is not yet installed${msg}', just press y then enter.${nc}"
echo -e " "
echo -e "${msg} You may also get 2 errors later from Apache:${nc}"
echo -e "${msg} AH00557 & AH00558, these can be safely ignored.${nc}"
echo -e "${sep}"
echo " "
pkg install -y nano mysql56-server mod_php56 php56-mysql php56-mysqli phpmyadmin apache24
#dbtype
# -------------------------------------------------------
# MySQL
echo " "
echo -e "${sep}"
echo -e "${msg} Great, now let's get MySQL set up.${nc}"
echo -e "${sep}"
echo " "
echo 'mysql_enable="YES"' >> /etc/rc.conf
echo '[mysqld]' >> /var/db/mysql/my.cnf
/usr/local/etc/rc.d/mysql-server start
mysql_secure_installation
/usr/local/etc/rc.d/mysql-server restart
# -------------------------------------------------------
# Webmin
echo " "
echo -e "${sep}"
echo -e "${msg} Would you like Webmin also? (Not required)${nc}"
echo -e "${sep}"
echo " "
webmin
# -------------------------------------------------------
# Apache
echo " "
echo -e "${sep}"
echo -e "${msg} Getting there! Time for Apache setup.${nc}"
echo -e "${sep}"
echo " "
echo 'apache24_enable="YES"' >> /etc/rc.conf
service apache24 start
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
# Configure Apache to Use PHP Module
echo '<IfModule dir_module>' >> /usr/local/etc/apache24/Includes/php.conf
echo ' DirectoryIndex index.php index.html' >> /usr/local/etc/apache24/Includes/php.conf
echo ' <FilesMatch "\.php$">' >> /usr/local/etc/apache24/Includes/php.conf
echo ' SetHandler application/x-httpd-php' >> /usr/local/etc/apache24/Includes/php.conf
echo ' </FilesMatch>' >> /usr/local/etc/apache24/Includes/php.conf
echo ' <FilesMatch "\.phps$">' >> /usr/local/etc/apache24/Includes/php.conf
echo ' SetHandler application/x-httpd-php-source' >> /usr/local/etc/apache24/Includes/php.conf
echo ' </FilesMatch>' >> /usr/local/etc/apache24/Includes/php.conf
echo '</IfModule>' >> /usr/local/etc/apache24/Includes/php.conf
# Is this next step even needed anymore? If so, use sed command for this.
#echo -e "${msg} Find: ${qry}DirectoryIndex index.html${nc}"
#echo -e "${msg} and add ${qry}index.php${msg} to the end of that line${nc}"
#echo -e "${msg} It should then look like this:${nc}"
#echo -e "${qry} DirectoryIndex index.html index.php${nc}"
#echo -e "${msg} Once you're done, press Ctrl+X then Y then Enter${nc}"
# nano /usr/local/etc/apache24/httpd.conf
# Adding stuff to above file to get phpmyadmin working.
echo '<FilesMatch "\.php$">' >> /usr/local/etc/apache24/httpd.conf
echo ' SetHandler application/x-httpd-php' >> /usr/local/etc/apache24/httpd.conf
echo '</FilesMatch>' >> /usr/local/etc/apache24/httpd.conf
echo '<FilesMatch "\.phps$">' >> /usr/local/etc/apache24/httpd.conf
echo ' SetHandler application/x-httpd-php-source' >> /usr/local/etc/apache24/httpd.conf
echo '</FilesMatch>' >> /usr/local/etc/apache24/httpd.conf
echo ' ' >> /usr/local/etc/apache24/httpd.conf
echo 'Alias /phpMyAdmin "/usr/local/www/phpMyAdmin"' >> /usr/local/etc/apache24/httpd.conf
echo ' ' >> /usr/local/etc/apache24/httpd.conf
echo '<Directory "/usr/local/www/phpMyAdmin">' >> /usr/local/etc/apache24/httpd.conf
echo 'Options None' >> /usr/local/etc/apache24/httpd.conf
echo 'AllowOverride None' >> /usr/local/etc/apache24/httpd.conf
echo 'Require all granted' >> /usr/local/etc/apache24/httpd.conf
echo '</Directory>' >> /usr/local/etc/apache24/httpd.conf
service apache24 restart
# -------------------------------------------------------
# phpMyAdmin
echo " "
echo -e "${sep}"
echo -e "${msg} Now for phpMyAdmin${nc}"
echo -e "${msg} This may seem confusing but follow the steps closely${nc}"
echo -e "${msg} and you shouldn't run in to any issues!${nc}"
echo -e "${sep}"
echo " "
phpmyadmin
# -------------------------------------------------------
# Now restart Apache, MySQL too for good measure.
echo " "
echo -e "${sep}"
echo -e "${msg} Last step! Restart apache and mysql.${nc}"
echo -e "${msg} Reminder: You can safely ignore the AH00557 & AH00558 errors.${nc}"
echo -e "${sep}"
echo " "
service apache24 restart
service mysql-server restart
echo " "
echo -e "${sep}"
echo -e "${msg} It looks like we finished here!!! NICE${nc}"
echo -e "${msg} Now when you have an app that requires a mysql${nc}"
echo -e "${msg} you can use this jails ip in the host setting${nc}"
echo " "
echo -e "${msg} You can also head to ${url}http://yourjailip/phpMyAdmin${nc}"
echo -e "${msg} enter root for the username and use the password you set earlier${nc}"
echo -e "${msg} to easily create/modify/etc. your new mysql database!${nc}"
echo " "
echo -e " More information will be added to this script later"
echo -e " And will also be added to a forum post somewhere."
echo " "
echo -e "${msg} You can get in touch with me any of the ways listed here:${nc}"
echo -e "${url} http://vengefulsyndicate.com/about-us${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### OWNCLOUD INSTALL
install.owncloud ()
{
confirm ()
{
# Confirm with the user
read -r -p " Continue? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
# If yes, then continue
echo -e "${url} Great! Moving on..${nc}"
;;
*)
# Otherwise exit...
echo " "
echo -e "${alt}Stopping script..${nc}"
echo " "
exit
;;
esac
}
setconfig ()
{
read -r -p " Did you modify the script before running? [y/N] " response
case $response in
[yY][eE][sS]|[yY])
echo " No need to do anything here then${nc}"
;;
*)
echo " "
echo -e "${msg} Set your IP. MUST MATCH YOUR JAIL IP!${nc}"
echo -e "${qry} Example:"
echo -e "${url} 192.168.1.200${nc}"
echo " "
echo "Server IP:"
read oc_server_ip
echo " "
echo -e "${msg} Set your Port (Default [81] is fine)${nc}"
echo -e "${qry} Example:"
echo -e "${url} 81${nc}"
echo " "
echo "Server Port:"
read oc_server_port
echo " "
echo -e "${msg} ownCloud version to install${nc}"
echo -e "${qry} Example:"
echo -e "${url} 9.0.0${nc}"
echo " "
echo "ownCloud Version:"
read oc_server_ver
;;
esac
}
trusteddomain.error ()
{
# Confirm with the user
echo " "
echo -e "${emp} Please finish the owncloud setup before continuing${nc}"
echo -e "${msg} Head to ${url}https://$cloud_server_ip:$cloud_server_port ${msg}to do this.${nc}"
echo -e "${msg} Fill out the page you are presented with and hit finish${nc}"
echo " "
echo -e "${msg} Admin username & password = whatever you choose${nc}"
echo " "
echo -e "${emp} Make sure you click 'Storage & database'${nc}"
echo " "
echo -e "${msg} Database user = ${qry}root${nc} | Database password = ${nc}"
echo -e "${msg} the ${qry}mysql password${msg} you chose earlier during the script.${nc}"
echo -e "${msg} Database name = your choice (just ${qry}owncloud${msg} is fine)${nc}"
echo " "
echo -e "${inf} You can always perform this next step later from the menu but it's best to do${nc}"
echo -e "${inf} it now if your installing version 9.0.0 or above (8.x.x shouln't need this)${nc}"
echo " "
read -r -p " Once the page reloads, do you have a 'untrusted domain' warning? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
# If yes, let's fix that.
echo " "
echo -e "${url} Doing some last second changes to fix that..${nc}"
echo " "
# Prevent "Trusted Domain" error
echo " '${server_ip}'," >> /usr/local/www/owncloud/config/trusted.txt
cat "/usr/local/www/owncloud/config/old_config.bak" | \
sed '8r /usr/local/www/owncloud/config/trusted.txt' > \
"/usr/local/www/owncloud/config/config.php"
rm /usr/local/www/owncloud/config/trusted.txt
echo -e " Done, continuing with the rest of the script"
;;
*)
# If no, just continue like normal.
echo " "
echo -e "${qry} Great!, no need to do anything, continuing with script..${nc}"
echo " "
;;
esac
}
echo " "
echo -e "${sep}"
echo -e "${msg} Welcome to the ownCloud installer!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's start with the config!!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's install all the requirements${nc}"
echo -e "${sep}"
echo " "
echo "If you get a question regarding package management tool, answer yes"
# Install packages
pkg install -y lighttpd php56-openssl php56-ctype php56-curl php56-dom php56-fileinfo php56-filter php56-gd php56-hash php56-iconv php56-json php56-mbstring php56-mysql php56-pdo php56-pdo_mysql php56-pdo_sqlite php56-session php56-simplexml php56-sqlite3 php56-xml php56-xmlrpc php56-xmlwriter php56-xmlreader php56-gettext php56-mcrypt php56-zip php56-zlib php56-posix mp3info mysql56-server pecl-apcu
echo " "
echo -e "${sep}"
echo -e "${msg} Packages installed - now configuring MySQL${nc}"
echo -e "${sep}"
echo " "
echo 'mysql_enable="YES"' >> /etc/rc.conf
echo '[mysqld]' >> /var/db/mysql/my.cnf
echo 'skip-networking' >> /var/db/mysql/my.cnf
# Start MySQL Server
/usr/local/etc/rc.d/mysql-server start
echo " "
echo -e "${sep}"
echo -e "${msg} Securing the install. Default root password is blank,${nc}"
echo -e "${msg} you want to provide a strong root password, remove the${nc}"
echo -e "${msg} anonymous accounts, disallow remote root access,${nc}"
echo -e "${msg} remove the test database, and reload privilege tables${nc}"
echo -e "${sep}"
echo " "
mysql_secure_installation
echo " "
echo -e "${sep}"
echo -e "${msg} Done hardening MySQL - Performing key operations now${nc}"
echo -e "${sep}"
echo " "
cd ~
openssl genrsa -des3 -out server.key 1024
echo " "
echo -e "${sep}"
echo -e "${msg} Removing password from key${nc}"
echo -e "${sep}"
echo " "
openssl rsa -in server.key -out no.pwd.server.key
echo " "
echo -e "${sep}"
echo -e "${msg} Creating cert request. The Common Name should match${nc}"
echo -e "${msg} the URL you want to use${nc}"
echo -e "${sep}"
echo " "
openssl req -new -key no.pwd.server.key -out server.csr
echo " "
echo -e "${sep}"
echo -e "${msg} Creating cert & pem file & moving to proper location${nc}"
echo -e "${sep}"
echo " "
openssl x509 -req -days 365 -in /root/server.csr -signkey /root/no.pwd.server.key -out /root/server.crt
cat no.pwd.server.key server.crt > server.pem
mkdir /usr/local/etc/lighttpd/ssl
cp server.crt /usr/local/etc/lighttpd/ssl
chown -R www:www /usr/local/etc/lighttpd/ssl/
chmod 0600 server.pem
echo " "
echo -e "${sep}"
echo -e "${msg} Creating backup of lighttpd config${nc}"
echo -e "${sep}"
echo " "
cp /usr/local/etc/lighttpd/lighttpd.conf /usr/local/etc/lighttpd/old_config.bak
echo " "
echo -e "${sep}"
echo -e "${msg} Modifying lighttpd.conf file${nc}"
echo -e "${sep}"
echo " "
cat "/usr/local/etc/lighttpd/old_config.bak" | \
sed -r '/^var.server_root/s|"(.*)"|"/usr/local/www/owncloud"|' | \
sed -r '/^server.use-ipv6/s|"(.*)"|"disable"|' | \
sed -r '/^server.document-root/s|"(.*)"|"/usr/local/www/owncloud"|' | \
sed -r '/^#server.bind/s|(.*)|server.bind = "'"${server_ip}"'"|' | \
sed -r '/^\$SERVER\["socket"\]/s|"0.0.0.0:80"|"'"${server_ip}"':'"${server_port}"'"|' | \
sed -r '/^server.port/s|(.*)|server.port = '"${server_port}"'|' > \
"/usr/local/etc/lighttpd/lighttpd.conf"
echo " "
echo -e "${sep}"
echo -e "${msg} Adding stuff to lighttpd.conf file${nc}"
echo -e "${sep}"
echo " "
echo 'ssl.engine = "enable"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'ssl.pemfile = "/root/server.pem"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'ssl.ca-file = "/usr/local/etc/lighttpd/ssl/server.crt"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'ssl.cipher-list = "ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4-SHA:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'ssl.honor-cipher-order = "enable"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'ssl.disable-client-renegotiation = "enable"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '$HTTP["url"] =~ "^/data/" {' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'url.access-deny = ("")' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '}' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '$HTTP["url"] =~ "^($|/)" {' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'dir-listing.activate = "disable"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '}' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'cgi.assign = ( ".php" => "/usr/local/bin/php-cgi" )' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'server.modules += ( "mod_setenv" )' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '$HTTP["scheme"] == "https" {' >> /usr/local/etc/lighttpd/lighttpd.conf
echo ' setenv.add-response-header = ( "Strict-Transport-Security" => "max-age=15768000")' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '}' >> /usr/local/etc/lighttpd/lighttpd.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Enabling the fastcgi module${nc}"
echo -e "${sep}"
echo " "
cp /usr/local/etc/lighttpd/modules.conf /usr/local/etc/lighttpd/old_modules.bak
cat "/usr/local/etc/lighttpd/old_modules.bak" | \
sed -r '/^#include "conf.d\/fastcgi.conf"/s|#||' > \
"/usr/local/etc/lighttpd/modules.conf"
echo " "
echo -e "${sep}"
echo -e "${msg} Adding stuff to fastcgi.conf file${nc}"
echo -e "${sep}"
echo " "
echo 'fastcgi.server = ( ".php" =>' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '((' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"socket" => "/tmp/php.socket",' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"bin-path" => "/usr/local/bin/php-cgi",' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"allow-x-send-file" => "enable",' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"bin-environment" => (' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"MOD_X_SENDFILE2_ENABLED" => "1",' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"PHP_FCGI_CHILDREN" => "16",' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"PHP_FCGI_MAX_REQUESTS" => "10000"' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '),' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"min-procs" => 1,' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"max-procs" => 1,' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"idle-timeout" => 20' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '))' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo ' )' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Obtaining corrected MIME.conf file for lighttpd to use${nc}"
echo -e "${sep}"
echo " "
mv /usr/local/etc/lighttpd/conf.d/mime.conf /usr/local/etc/lighttpd/conf.d/mime_conf.bak
fetch -o /usr/local/etc/lighttpd/conf.d/mime.conf http://www.xenopsyche.com/mkempe/oc/mime.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Creating www folder and downloading ownCloud${nc}"
echo -e "${sep}"
echo " "
mkdir -p /usr/local/www
# Get ownCloud, extract it, copy it to the webserver
# and have the jail assign proper permissions
cd "/tmp"
fetch "https://download.owncloud.org/community/owncloud-${owncloud_version}.tar.bz2"
tar xf "owncloud-${owncloud_version}.tar.bz2" -C /usr/local/www
chown -R www:www /usr/local/www/
echo " "
echo -e "${sep}"
echo -e "${msg} Adding lighttpd to rc.conf${nc}"
echo -e "${sep}"
echo " "
echo 'lighttpd_enable="YES"' >> /etc/rc.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Done, lighttpd should start up automatically!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Attempting to start webserver.${nc}"
echo -e "${msg} If you get a Cannot 'start' lighttpd error, add:${nc}"
echo -e "\033[1;33m lighttpd_enable="YES"${nc} to \033[1;36m/etc/rc.conf${nc}"
echo -e "${msg} Command being run here is:"
echo -e "${cmd} /usr/local/etc/rc.d/lighttpd start${nc}"
echo -e "${sep}"
echo " "
/usr/local/etc/rc.d/lighttpd start
echo " "
echo -e "${sep}"
echo -e "${msg} Now to finish owncloud setup${nc}"
echo -e "${sep}"
echo " "
trusteddomain.error
echo " "
echo -e "${sep}"
echo -e "${msg} It looks like we finished here!!! NICE${nc}"
echo -e "${msg} Now you can head to ${url}https://$cloud_server_ip:$cloud_server_port${nc}"
echo -e "${msg} to use your owncloud whenever you wish!${nc}"
echo " "
echo " "
echo " "
echo -e "${emp} Memory Caching ${msg}is an optional feature that is not enabled by default${nc}"
echo -e "${msg} This is entirely optional and any messages about it can be safely ignored.${nc}"
echo -e "${msg} If you wish to enable it, head to the owncloud 'Other Options' menu.${nc}"
echo " "
echo " "
echo " "
echo -e "${msg} If you need any help, visit the forums here:${nc}"
echo -e "${url} http://forums.nas4free.org/viewtopic.php?f=79&t=9383${nc}"
echo -e "${msg} Or jump on my Discord server${nc}"
echo -e "${url} https://discord.gg/0bXnhqvo189oM8Cr${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### NEXTCLOUD INSTALL
install.nextcloud ()
{
nextcloud.continue ()
{
echo -e "${msep}"
echo -e "${emp} Press Enter To Continue${nc}"
echo -e "${msep}"
read -r -p " " response
case "$response" in
*)
;;
esac
}
nextcloud.options ()
{
echo " "
echo -e "${msg} What is your jails IP?${nc}"
echo -e "${alt} This MUST be your jails IP${nc}"
printf "${inf} Detected IP: ${nc}" ; ifconfig | grep -e "inet" -e "addr:" | grep -v "inet6" | grep -v "127.0.0.1" | head -n 1 | awk '{print $2}'
echo " "
printf "${emp} Set IP: ${nc}" ; read userselected_ip
echo -e "${fin} IP set to: ${msg}${userselected_ip}${nc}"
echo " "
echo -e "${msg} What port do you want to run it on?${nc}"
echo -e "${inf} Recommended: ${msg}81${nc}"
echo " "
printf "${emp} Set Port: ${nc}" ; read userselected_port
echo -e "${fin} Port set to: ${msg}${userselected_port}${nc}"
echo " "
echo -e "${msg} What version would you like to install${nc}"
echo -e "${inf} Tested & Confirmed Working: 11.0.0"
echo " "
printf "${emp} Set Version: ${nc}" ; read -r userselected_version
echo -e "${fin} Version set to: ${msg}${userselected_version}${nc}"
echo " "
nextcloud.continue
#echo " "
#echo -e "${emp} Only do so if you know what you're doing!${nc}"
#echo " Default Database name: nextcloud"
#read -r -p " Set Database name to something else? [y/N] " response
# case $response in
# [yY][eE][sS]|[yY])
# echo " "
# echo -e "${msg} What port do you want to run it on?${nc}"
# echo "Recommended: 81"
# echo " "
# echo " Input Port:"
# read userselected_dbname
# ;;
# *)
# database_name="nextcloud"
# ;;
# esac
}
echo " "
echo -e "${sep}"
echo -e "${msg} Welcome to the NextCloud installer!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} First, some configuration${nc}"
echo -e "${sep}"
echo " "
nextcloud.options
echo " "
echo -e "${sep}"
echo -e "${msg} Let's get to installing some stuff!!${nc}"
echo -e "${sep}"
echo " "
# Install packages
pkg install -y lighttpd php70-openssl php70-ctype php70-curl php70-dom php70-fileinfo php70-filter php70-gd php70-hash php70-iconv php70-json php70-mbstring php70-pdo php70-pdo_mysql php70-pdo_sqlite php70-session php70-simplexml php70-sqlite3 php70-xml php70-xmlrpc php70-xmlwriter php70-xmlreader php70-gettext php70-mcrypt php70-zip php70-zlib php70-posix mp3info mysql56-server
# php70-APCu - No longer in repositories
# Alternative
# php70-memcache php70-memcached
echo " "
echo -e "${sep}"
echo -e "${msg} Packages installed - now configuring MySQL${nc}"
echo -e "${sep}"
echo " "
echo 'mysql_enable="YES"' >> /etc/rc.conf
echo '[mysqld]' >> /var/db/mysql/my.cnf
echo 'skip-networking' >> /var/db/mysql/my.cnf
# Start MySQL Server
/usr/local/etc/rc.d/mysql-server start
echo " "
echo -e "${sep}"
echo -e "${msg} Creating database for nextcloud${nc}"
echo -e "${sep}"
echo " "
mysql -u root -e "create database ${database_name}";
echo -e "${msg} Database was created: ${database_name}.${nc}"
echo " "
echo -e "${sep}"
echo -e "${msg} Securing the install. Default root password is blank,${nc}"
echo -e "${msg} you want to provide a strong root password, remove the${nc}"
echo -e "${msg} anonymous accounts, disallow remote root access,${nc}"
echo -e "${msg} remove the test database, and reload privilege tables${nc}"
echo -e "${sep}"
echo " "
mysql_secure_installation
echo " "
echo -e "${sep}"
echo -e "${msg} Done hardening MySQL - Performing key operations now${nc}"
echo -e "${sep}"
echo " "
cd ~
openssl genrsa -des3 -out server.key 1024
echo " "
echo -e "${sep}"
echo -e "${msg} Removing password from key${nc}"
echo -e "${sep}"
echo " "
openssl rsa -in server.key -out no.pwd.server.key
echo " "
echo -e "${sep}"
echo -e "${msg} Creating cert request. The Common Name should match${nc}"
echo -e "${msg} the URL you want to use${nc}"
echo -e "${sep}"
echo " "
openssl req -new -key no.pwd.server.key -out server.csr
echo " "
echo -e "${sep}"
echo -e "${msg} Creating cert & pem file & moving to proper location${nc}"
echo -e "${sep}"
echo " "
openssl x509 -req -days 365 -in /root/server.csr -signkey /root/no.pwd.server.key -out /root/server.crt
cat no.pwd.server.key server.crt > server.pem
mkdir /usr/local/etc/lighttpd/ssl
cp server.crt /usr/local/etc/lighttpd/ssl
chown -R www:www /usr/local/etc/lighttpd/ssl/
chmod 0600 server.pem
echo " "
echo -e "${sep}"
echo -e "${msg} Creating backup of lighttpd config${nc}"
echo -e "${sep}"
echo " "
cp /usr/local/etc/lighttpd/lighttpd.conf /usr/local/etc/lighttpd/old_config.bak
echo " "
echo -e "${sep}"
echo -e "${msg} Modifying lighttpd.conf file${nc}"
echo -e "${sep}"
echo " "
cat "/usr/local/etc/lighttpd/old_config.bak" | \
sed -r '/^var.server_root/s|"(.*)"|"/usr/local/www/nextcloud"|' | \
sed -r '/^server.use-ipv6/s|"(.*)"|"disable"|' | \
sed -r '/^server.document-root/s|"(.*)"|"/usr/local/www/nextcloud"|' | \
sed -r '/^#server.bind/s|(.*)|server.bind = "'"${userselected_ip}"'"|' | \
sed -r '/^\$SERVER\["socket"\]/s|"0.0.0.0:80"|"'"${userselected_ip}"':'"${userselected_port}"'"|' | \
sed -r '/^server.port/s|(.*)|server.port = '"${userselected_port}"'|' > \
"/usr/local/etc/lighttpd/lighttpd.conf"
echo " "
echo -e "${sep}"
echo -e "${msg} Adding stuff to lighttpd.conf file${nc}"
echo -e "${sep}"
echo " "
echo 'ssl.engine = "enable"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'ssl.pemfile = "/root/server.pem"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'ssl.ca-file = "/usr/local/etc/lighttpd/ssl/server.crt"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'ssl.cipher-list = "ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4-SHA:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'ssl.honor-cipher-order = "enable"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'ssl.disable-client-renegotiation = "enable"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '$HTTP["url"] =~ "^/data/" {' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'url.access-deny = ("")' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '}' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '$HTTP["url"] =~ "^($|/)" {' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'dir-listing.activate = "disable"' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '}' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'cgi.assign = ( ".php" => "/usr/local/bin/php-cgi" )' >> /usr/local/etc/lighttpd/lighttpd.conf
echo 'server.modules += ( "mod_setenv" )' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '$HTTP["scheme"] == "https" {' >> /usr/local/etc/lighttpd/lighttpd.conf
echo ' setenv.add-response-header = ( "Strict-Transport-Security" => "max-age=15768000")' >> /usr/local/etc/lighttpd/lighttpd.conf
echo '}' >> /usr/local/etc/lighttpd/lighttpd.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Enabling the fastcgi module${nc}"
echo -e "${sep}"
echo " "
cp /usr/local/etc/lighttpd/modules.conf /usr/local/etc/lighttpd/old_modules.bak
cat "/usr/local/etc/lighttpd/old_modules.bak" | \
sed -r '/^#include "conf.d\/fastcgi.conf"/s|#||' > \
"/usr/local/etc/lighttpd/modules.conf"
echo " "
echo -e "${sep}"
echo -e "${msg} Adding stuff to fastcgi.conf file${nc}"
echo -e "${sep}"
echo " "
echo 'fastcgi.server = ( ".php" =>' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '((' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"socket" => "/tmp/php.socket",' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"bin-path" => "/usr/local/bin/php-cgi",' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"allow-x-send-file" => "enable",' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"bin-environment" => (' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"MOD_X_SENDFILE2_ENABLED" => "1",' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"PHP_FCGI_CHILDREN" => "16",' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"PHP_FCGI_MAX_REQUESTS" => "10000"' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '),' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"min-procs" => 1,' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"max-procs" => 1,' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '"idle-timeout" => 20' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo '))' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo ' )' >> /usr/local/etc/lighttpd/conf.d/fastcgi.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Obtaining corrected MIME.conf file for lighttpd to use${nc}"
echo -e "${sep}"
echo " "
mv /usr/local/etc/lighttpd/conf.d/mime.conf /usr/local/etc/lighttpd/conf.d/mime_conf.bak
fetch -o /usr/local/etc/lighttpd/conf.d/mime.conf http://www.xenopsyche.com/mkempe/oc/mime.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Modifying php.ini${nc}"
echo -e "${sep}"
echo " "
echo always_populate_raw_post_data = -1 > /usr/local/etc/php.ini
echo " "
echo -e "${sep}"
echo -e "${msg} Creating www folder and downloading NextCloud${nc}"
echo -e "${sep}"
echo " "
mkdir -p /usr/local/www
# Get NextCloud, extract it, copy it to the webserver
# and have the jail assign proper permissions
cd "/tmp"
fetch "https://download.nextcloud.com/server/releases/nextcloud-${userselected_version}.tar.bz2"
tar xf "nextcloud-${userselected_version}.tar.bz2" -C /usr/local/www
chown -R www:www /usr/local/www/
echo " "
echo -e "${sep}"
echo -e "${msg} Adding lighttpd to rc.conf${nc}"
echo -e "${sep}"
echo " "
echo 'lighttpd_enable="YES"' >> /etc/rc.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Done, lighttpd should start up automatically!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Attempting to start webserver.${nc}"
echo -e "${msg} If you get a Cannot 'start' lighttpd error, add:${nc}"
echo -e "\033[1;33m lighttpd_enable="YES"${nc} to \033[1;36m/etc/rc.conf${nc}"
echo -e "${msg} Command being run here is:"
echo -e "${cmd} /usr/local/etc/rc.d/lighttpd start${nc}"
echo -e "${sep}"
echo " "
/usr/local/etc/rc.d/lighttpd start
#echo " "
#echo -e "${sep}"
#echo -e "${msg} Enable Memory Caching${nc}"
#echo -e "${sep}"
#echo " "
#TODO: Enable Memory Caching by default
#echo " 'memcache.local' => '\OC\Memcache\APCu'," >> #/usr/local/www/nextcloud/config/memcache.txt
#cp /usr/local/www/nextcloud/config/config.php /usr/local/www/nextcloud/config/old_config.bak
#cat "/usr/local/www/nextcloud/config/old_config.bak" | \
# sed '21r /usr/local/www/nextcloud/config/memcache.txt' > \
# "/usr/local/www/nextcloud/config/config.php"
#rm /usr/local/www/nextcloud/config/memcache.txt
echo " "
echo -e "${sep}"
echo -e "${msg} Now to finish nextcloud setup${nc}"
echo -e "${sep}"
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} It looks like we finished here!!! NICE${nc}"
echo -e "${msg} Now you can head to ${url}https://$userselected_ip:$userselected_port${nc}"
echo -e "${msg} to use your nextcloud whenever you wish!${nc}"
echo " "
echo " "
echo " "
echo -e "${emp} Memory Caching ${msg}is an optional feature that is not enabled by default${nc}"
echo -e "${msg} This is entirely optional and any messages about it can be safely ignored.${nc}"
echo -e "${msg} If you wish to enable it, you can do so via the 'Other Options' menu.${nc}"
echo " "
echo " "
echo " "
echo -e "${msg} If you need any help, visit the forums here:${nc}"
echo -e "${url} http://forums.nas4free.org/viewtopic.php?f=79&t=9383${nc}"
echo -e "${msg} Or jump on my Discord server${nc}"
echo -e "${url} https://discord.gg/0bXnhqvo189oM8Cr${nc}"
echo -e "${sep}"
echo " "
nextcloud.continue
echo " "
}
#------------------------------------------------------------------------------#
### PYDIO INSTALL
install.pydio ()
{
echo " "
echo -e "${sep}"
echo -e "${msg} Pydio Install Script${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's start with installing the prerequisites${nc}"
echo -e "${sep}"
echo " "
pkg install nginx php70 php70-extensions php70-curl php70-gd php70-imap php70-mbstring php70-mcrypt php70-mysqli php70-openssl php70-pdo_mysql php70-zip php70-zlib mysql57-server
echo 'nginx_enable="YES"' >> /etc/rc.conf
echo 'php_fpm_enable="YES"' >> /etc/rc.conf
echo 'mysql_enable="YES"' >> /etc/rc.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Packages installed, configuring mysql${nc}"
echo -e "${sep}"
echo " "
#touch /usr/local/etc/my.cnf
echo '# The MySQL server configuration' >> /var/db/mysql/my.cnf
echo '[mysqld]' >> /var/db/mysql/my.cnf
echo 'socket = /tmp/mysql.sock' >> /var/db/mysql/my.cnf
echo '' >> /var/db/mysql/my.cnf
echo "# Don't listen on a TCP/IP port at all." >> /var/db/mysql/my.cnf
echo 'skip-networking' >> /var/db/mysql/my.cnf
echo 'skip-name-resolve' >> /var/db/mysql/my.cnf
echo '' >> /var/db/mysql/my.cnf
echo '#Expire binary logs after one day:' >> /var/db/mysql/my.cnf
echo 'expire_logs_days = 1' >> /var/db/mysql/my.cnf
service mysql-server start
mysql_secure_installation
#mysql -u root -e "create database ${pydio_database_name}";
mysql -u root -e "create database pydio";
# SSL Certificates setup
#cd /usr/local/etc/nginx
#openssl genrsa -des3 -out server.key 2048
#openssl req -new -key server.key -out server.csr
#openssl x509 -req -days 3650 -in server.csr -signkey server.key -out ssl-bundle.crt
#cp server.key server.key.orig
#openssl rsa -in server.key.orig -out server.key
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
service php-fpm start
fetch "https://download.pydio.com/pub/core/archives/pydio-core-7.0.3.tar.gz"
tar -xzvf pydio-*
mv pydio-core-5.x.x /usr/local/www/pydio
chown -R www:www /usr/local/www/pydio
chmod -R 770 /usr/local/www/pydio
service nginx start
}
#------------------------------------------------------------------------------#
### EMBY SERVER INSTALL
install.emby ()
{
echo " "
echo -e "${sep}"
echo -e "${msg} Emby Install Script${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's start with installing Emby from packages${nc}"
echo -e "${sep}"
echo " "
pkg install -y emby-server
echo " "
echo -e "${sep}"
echo -e "${msg} Enable automatic startup of Emby Server${nc}"
echo -e "${sep}"
echo " "
sysrc emby_server_enable="YES"
echo " "
echo -e "${sep}"
echo -e "${msg} Start the Emby Server${nc}"
echo -e "${sep}"
echo " "
service emby-server start
echo " "
echo -e "${sep}"
echo -e "${msg} Using a web browser, head to ${url}yourjailip:8096${nc}"
echo -e "${msg} to finish setting up your Emby server${nc}"
echo -e " "
echo -e "${msg} You should also recompile ffmpeg+imagemagick${nc}"
echo -e "${msg} This option can be found in the Emby submenu of this script${nc}"
echo -e "${msg} It's also advised to run the update option after a clean install.${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### PLEX SERVER INSTALL
install.plex ()
{
echo " "
echo -e "${sep}"
echo -e "${msg} Plex Install Script${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's start with downloading the install script${nc}"
echo -e "${sep}"
echo " "
cd ${myappsdir}
fetch https://raw.githubusercontent.com/JRGTH/nas4free-plex-extension/master/plex-install.sh && chmod +x plex-install.sh && ./plex-install.sh
}
#------------------------------------------------------------------------------#
### OMBI INSTALL
install.ombi ()
{
ombi.continue ()
{
echo -e "${msep}"
echo -e "${emp} Press Enter To Continue${nc}"
echo -e "${msep}"
read -r -p " " response
case "$response" in
*)
echo " "
;;
esac
}
echo " "
echo -e "${sep}"
echo -e "${msg} Ombi Install Script${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's start with some required packages${nc}"
echo -e "${sep}"
echo " "
#Install packages
pkg install wget mono screen unzip nano git sqlite3
# Set default editor
setenv EDITOR /usr/local/bin/nano
echo " "
echo -e "${sep}"
echo -e "${msg} Download Ombi${nc}"
echo -e "${sep}"
echo " "
# Download Ombi
wget -O /tmp/Ombi.zip https://github.com/tidusjar/Ombi/releases/download/v2.2.1/Ombi.zip
echo " "
echo -e "${sep}"
echo -e "${msg} Extract Ombi${nc}"
echo -e "${sep}"
echo " "
# Unzip Ombi
unzip /tmp/Ombi.zip -d /usr/local/share/
# Move Ombi
mv /usr/local/share/Release /usr/local/share/ombi/
echo " "
echo -e "${sep}"
echo -e "${msg} Create startup file${nc}"
echo -e "${sep}"
echo " "
# Create ombi file
touch /usr/local/bin/ombi
echo "#!/bin/sh" > /usr/local/bin/ombi
echo "cd /usr/local/share/ombi/" > /usr/local/bin/ombi
echo "/usr/local/bin/screen -d -m -S ombi /usr/local/bin/mono /usr/local/share/ombi/Ombi.exe" > /usr/local/bin/ombi
chmod 775 /usr/local/bin/ombi
echo " "
echo -e "${sep}"
echo -e "${msg} Add these lines to crontab${nc}"
echo -e "${msg} Copy the lines before pressing Enter then paste in to crontab${nc}"
echo -e "${msg} Close crontab afterwards with the following combination of keys${nc}"
echo -e "${msg} Ctrl+X then Y then Enter${nc}"
echo -e "${sep}"
echo " "
# Add to crontab
echo "SHELL=/bin/sh"
echo "PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin"
echo "#start ombi"
echo "@reboot /usr/local/bin/ombi"
echo " "
ombi.continue
crontab -e
echo " "
echo -e "${sep}"
echo -e "${msg} Restart jail and visit http://jailip:3579${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### SUBSONIC INSTALL
install.subsonic ()
{
echo " "
echo -e "${sep}"
echo -e "${msg} Welcome to the Subsonic installer!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's get started with some packages${nc}"
echo -e "${sep}"
echo " "
pkg install -y subsonic-standalone
pkg install -y xtrans xproto xextproto javavmwrapper flac openjdk8 ffmpeg
pkg install -y https://github.com/Nozza-VS/misc-code/blob/master/NAS4Free/Streaming/Subsonic/lame.tbz
echo " "
echo -e "${sep}"
echo -e "${msg} Create folders for Subsonic${nc}"
echo -e "${sep}"
echo " "
mkdir -p /var/subsonic/transcode
mkdir /var/subsonic/standalone
cp /usr/local/bin/lame /var/subsonic/transcode/
cp /usr/local/bin/flac /var/subsonic/transcode/
cp /usr/local/bin/ffmpeg /var/subsonic/transcode/
cd /tmp/
# Download Subsonic from sourceforge & extract
fetch http://heanet.dl.sourceforge.net/project/subsonic/subsonic/${subsonic_ver}/subsonic-${subsonic_ver}-standalone.tar.gz
tar xvzf /tmp/subsonic-${subsonic_ver}-standalone.tar.gz -C /var/subsonic/standalone
chmod 777 *.*
echo " "
echo -e "${sep}"
echo -e "${msg} Now let's make sure subsonic starts.${nc}"
echo -e "${msg} You can manually do this with:${nc}"
echo -e "${cmd} sh /var/subsonic/standalone/subsonic.sh${nc}"
echo -e "${msg} For now, this script will do it automatically.${nc}"
echo -e "${sep}"
echo " "
sh /var/subsonic/standalone/subsonic.sh
echo " "
echo -e "${sep}"
echo -e "${msg} If subsonic started as it should you can connect to it via the browser at the${nc}"
echo -e "${msg} following adress: Jail-IP:4040, default username is admin, and password admin.${nc}"
echo -e "${sep}"
echo " "
echo " "
echo -e "${sep}"
echo " That should be it!"
echo " Enjoy your Subsonic server!"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### MADSONIC INSTALL
install.madsonic ()
{
echo " "
echo -e "${sep}"
echo -e "${msg} Welcome to the Madsonic installer!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's get started with some packages${nc}"
echo -e "${sep}"
echo " "
#pkg install -y madsonic-jetty
pkg install -y madsonic-standalone
echo " "
echo -e "${sep}"
echo " Adding madsonic to rc.conf"
echo -e "${sep}"
echo " "
echo 'madsonic_enable="YES"' >> /etc/rc.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Now let's make sure madsonic starts.${nc}"
echo -e "${msg} You can manually do this with:${nc}"
echo -e "${cmd} /usr/local/etc/madsonic start${nc}"
echo -e "${msg} For now, this script will do it automatically.${nc}"
echo -e "${sep}"
echo " "
/usr/local/etc/rc.d/madsonic start
echo " "
echo -e "${sep}"
echo -e "${msg} If madsonic started as it should you can connect to it via your${nc}"
echo -e "${msg} browser with following adress: Jail-IP:4040${nc}"
echo -e "${msg} Default username is admin, and password admin.${nc}"
echo -e "${sep}"
echo " "
echo " "
echo -e "${sep}"
echo " That should be it!"
echo " Enjoy your Subsonic server!"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### SONARR INSTALL
install.sonarr ()
{
echo " "
echo -e "${sep}"
echo -e "${msg} Sonarr Install Script${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's start with installing Sonarr from packages${nc}"
echo -e "${sep}"
echo " "
pkg install -y sonarr mediainfo
echo " "
echo -e "${sep}"
echo -e "${msg} Start Sonarr${nc}"
echo -e "${sep}"
echo " "
service sonarr start
echo " "
echo -e "${sep}"
echo -e "${msg} Open your browser and go to: ${url}yourjailip:8989${nc}"
echo -e "${msg} to finish setting up Sonarr${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### COUCHPOTATO INSTALL
install.couchpotato ()
{
echo " "
echo -e "${sep}"
echo -e "${msg} CouchPotato Installer${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's install required packages first${nc}"
echo -e "${sep}"
echo " "
pkg install python py27-sqlite3 fpc-libcurl docbook-xml git-lite
echo " "
echo -e "${sep}"
echo -e "${msg} Grab CouchPotato from github${nc}"
echo -e "${msg} CouchPotato will be installed to:${nc}"
echo -e "${inf} /usr/local/CouchPotato${nc}"
echo -e "${sep}"
echo " "
#If running as root, expects python here
ln -s /usr/local/bin/python /usr/bin/python
git clone https://github.com/CouchPotato/CouchPotatoServer.git /usr/local/CouchPotato
echo " "
echo -e "${sep}"
echo -e "${msg} Copy startup script & make executable${nc}"
echo -e "${sep}"
echo " "
cp CouchPotatoServer/init/freebsd /usr/local/etc/rc.d/couchpotato
chmod +x /usr/local/etc/rc.d/couchpotato
chmod 555 /usr/local/etc/rc.d/couchpotato
echo " "
echo -e "${sep}"
echo -e "${msg} Enable CouchPotato at startup${nc}"
echo -e "${sep}"
echo " "
echo 'couchpotato_enable="YES"' >> /etc/rc.conf
#Read the options at the top of more /usr/local/etc/rc.d/couchpotato
#If not default install, specify options with startup flags in ee /etc/rc.conf
#Finally,
echo " "
echo -e "${sep}"
echo -e "${msg} Start CouchPotato${nc}"
echo -e "${sep}"
echo " "
service couchpotato start
echo " "
echo -e "${sep}"
echo -e "${msg} Open your browser and go to: ${url}yourjailip:5050${nc}"
echo -e "${msg} to finish setting up your CouchPotato server${nc}"
echo -e "${sep}"
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Done here!${nc}"
echo -e "${msg} Feel free to visit the project homepage at:${nc}"
echo -e "${url} https://github.com/CouchPotato/CouchPotatoServer${nc}"
echo -e "${url} https://couchpota.to${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### WATCHER INSTALL
install.watcher ()
{
echo -e "${sep}"
echo -e "${sep} Welcome to the Watcher installer!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${sep} Let's get started with some packages${nc}"
echo -e "${sep}"
echo " "
pkg update && pkg upgrade
pkg install git python3 sqlite3
cd /usr/local/
git clone https://github.com/nosmokingbandit/Watcher3.git
echo " "
echo -e "${sep}"
echo -e "${sep} Start watcher${nc}"
echo -e "${sep}"
echo " "
python watcher/watcher.py --daemon --log /var/log/ --db /var/db/watcher.sqlite --pid /var/run/watcher.pid
echo " "
echo -e "${sep}"
echo -e "${msg} Open your browser and go to: ${url}http://${jailip}:9090${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### RADARR INSTALL
install.radarr ()
{
echo -e "${sep}"
echo -e "${sep} Welcome to the Radarr installer!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${sep} Let's get started with some packages${nc}"
echo -e "${sep}"
echo " "
pkg update && pkg upgrade
pkg install -y mono mediainfo sqlite3 libgdiplus
cd /usr/local/
fetch https://github.com/Radarr/Radarr/releases/download/latest/Radarr.develop.latest.linux.tar.gz
tar -zxvf Radarr.develop.*.linux.tar.gz
rm Radarr.*.linux.tar.gz
echo "/usr/local/bin/mono /usr/local/Radarr/Radarr.exe" > /etc/rc.d/radarr
chmod 555 /etc/rc.d/radarr
#this is needed for updates within Radarr
ln -s /usr/local/bin/mono /bin
echo " "
echo -e "${sep}"
echo -e "${sep} Start watcher${nc}"
echo -e "${sep}"
echo " "
service radarr start
echo " "
echo -e "${sep}"
echo -e "${msg} Open your browser and go to: ${url}http://${jailip}:7878${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### HEADPHONES INSTALL
install.headphones ()
{
echo " "
echo -e "${sep}"
echo -e "${msg} Headphones Installer${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's install required packages first${nc}"
echo -e "${sep}"
echo " "
pkg install python py27-sqlite3 fpc-libcurl docbook-xml git-lite ffmpeg flac lame
echo " "
echo -e "${sep}"
echo -e "${msg} Grab Headphones from github${nc}"
echo -e "${msg} Headphones will be installed to:${nc}"
echo -e "${inf} /usr/local/Headphones${nc}"
echo -e "${sep}"
echo " "
git clone https://github.com/rembo10/headphones.git /usr/local/Headphones
echo " "
echo -e "${sep}"
echo -e "${msg} Fetch Headphones startup script from github${nc}"
echo -e "${sep}"
echo " "
# cp headphones/init-scripts/init.freebsd /usr/local/etc/rc.d/headphones
#Fetch Nozza-VS's startup script instead
fetch --no-verify-peer -o /usr/local/etc/rc.d/headphones "https://raw.githubusercontent.com/Nozza-VS/misc-code/master/NAS4Free/Search Tools/Headphones/headphones-init-script"
#Make startup script executable
chmod 555 /usr/local/etc/rc.d/headphones
chmod +x /usr/local/etc/rc.d/headphones
# Potentially need to modify the line:
#command_args = "- f -p $ {python headphones_pid} $ {} headphones_dir /Headphones.py $ {} headphones_flags --quiet --nolaunch"
# To:
#command_args = "- f -p $ {} headphones_pid python2.7 $ {} headphones_dir /Headphones.py $ {} headphones_flags --quiet --nolaunch"
# Further testing needed, will update my init script if deemed necessary.
echo " "
echo -e "${sep}"
echo -e "${msg} Enable automatic startup at boot for Headphones${nc}"
echo -e "${sep}"
echo " "
echo 'headphones_enable="YES"' >> /etc/rc.conf
echo " "
echo -e "${sep}"
echo -e "${msg} Start Headphones${nc}"
echo -e "${sep}"
echo " "
service headphones start
#
echo " "
echo -e "${sep}"
echo -e "${msg} Open your browser and go to: ${url}jailip:8181${nc}"
echo -e "${sep}"
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Done here!${nc}"
echo -e "${msg} Feel free to visit the project homepage at:${nc}"
#echo -e "${url} https://gitlab.com/sarakha63/headphones${nc}"
echo -e "${url} https://github.com/rembo10/headphones${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### THEBRIG EXPERIMENTAL INSTALL
install.thebrig.EXPERIMENTAL ()
{
confirmstorage ()
{
# Confirm with the user
read -r -p " Correct path? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
# If yes, then continue
echo -e "${url} Great! We'll install thebrig in '${mystorage}/Jails'.${nc}"
;;
*)
# Otherwise exit...
echo " "
echo -e "${alt} This needs to be correct.${nc}"
echo -e "${alt} Please modify the 'mystorage' at the start of${nc}"
echo -e "${alt} the script before running this again.${nc}"
echo " "
exit
;;
esac
}
confirmsuccess ()
{
# Confirm with the user
echo -e "${msg} Head to your NAS WebGUI - Refresh page if it's already open${nc}"
read -r -p " Can you seen an 'Extensions' tab with 'TheBrig' listed? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
# If yes, then continue
echo -e "${url} Good! Now follow the How-To for finalizing the setup.${nc}"
;;
*)
# Otherwise exit...
echo " "
echo -e "${alt} Seems this script had an issue somewhere ${nc}"
echo " "
exit
;;
esac
}
echo " "
echo -e "${sep}"
echo -e "${msg} Welcome to theBrig installer!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} This should hopefully install TheBrig for you without any problems!${nc}"
echo " "
echo -e "${msg} Let's start with double checking your storage path.${nc}"
echo -e "${msg} Is this the correct path to your mounted storage?${nc}."
echo -e "${qry} ${mystorage} ${nc}."
echo -e "${sep}"
echo -e " "
confirmstorage
echo " "
echo -e "${sep}"
echo -e "${msg} Let's get on with the install.${nc}"
echo -e "${sep}"
echo " "
# Make folder for TheBrig and it's jails to live in
mkdir ${mystorage}/Jails
# Head to the directory we just made
cd ${mystorage}/Jails
# Download the installer
fetch https://raw.githubusercontent.com/fsbruva/thebrig/alcatraz/thebrig_install.sh
# Run the installer
/bin/sh thebrig_install.sh ${mystorage}/Jails
echo " "
echo -e "${sep}"
echo -e "${msg} TheBrig should now be successfully installed${nc}"
echo -e "${sep}"
echo " "
# Confirm with user
confirmsuccess
}
#------------------------------------------------------------------------------#
### OBI INSTALL
install.obi ()
{
echo " "
echo -e "${sep}"
echo -e "${msg} Welcome to OneButtonInstaller... installer!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${msg} Let's get on with the install.${nc}"
echo -e "${sep}"
echo " "
fetch https://raw.github.com/crestAT/nas4free-onebuttoninstaller/master/OBI.php && mkdir -p ext/OBI && echo '<a href="OBI.php">OneButtonInstaller</a>' > ext/OBI/menu.inc && echo -e "\nDONE"
echo " "
echo -e "${sep}"
echo -e "${msg} OBI should now be successfully installed${nc}"
echo -e "${msg} Head to your NAS4Free WebGUI and you should find it under${nc}"
echo -e "${msg} EXTENSIONS | OneButtonInstaller${nc}"
echo -e "${msg} On this page choose where to install it to and hit 'Save'.${nc}"
echo -e "${msg} Now your done and ready to easily install things such as TheBrig!${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### HTPC MANAGER INSTALL
install.htpcmanager ()
{
echo -e "${sep}"
echo -e "${sep} Welcome to the HTPC installer!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${sep} Let's get started with some packages${nc}"
echo -e "${sep}"
echo " "
pkg update && pkg upgrade
pkg install -y python27 sqlite3 git
echo " "
echo -e "${sep}"
echo -e "${sep} Grab HTPC manager from github${nc}"
echo -e "${sep}"
echo " "
cd /usr/local/
git clone https://github.com/styxit/HTPC-Manager.git
echo " "
echo -e "${sep}"
echo -e "${msg} Open your browser and go to: ${url}http://${jailip}:9090${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### ORGANIZR INSTALL
install.organizr ()
{
echo -e "${sep}"
echo -e "${sep} Welcome to the Organizr installer!${nc}"
echo -e "${sep}"
echo " "
echo " "
echo " "
echo -e "${sep}"
echo -e "${sep} Let's get started with some packages${nc}"
echo -e "${sep}"
echo " "
pkg update && pkg upgrade
pkg install -y apache24 php56 mod_php56 php56-extensions php56-pdo php56-pdo_sqlite php56-simplexml php56-zip php56-openssl git
echo " "
echo -e "${sep}"
echo -e "${sep} Modify apache${nc}"
echo -e "${sep}"
echo " "
sysrc apache_enable=YES
service apache24 start
echo " "
echo -e "${sep}"
echo -e "${sep} Grab Organizer from github${nc}"
echo -e "${sep}"
echo " "
cd /usr/local/www/
git clone https://github.com/causefx/Organizr.git
echo " "
echo -e "${sep}"
echo -e "${msg} Open your browser and go to: ${url}http://${jailip}/${nc}"
echo -e "${sep}"
echo " "
}
#------------------------------------------------------------------------------#
### CALIBRE INSTALL
install.calibre ()
{
echo -e "${sep}"