Last active
August 29, 2015 14:06
-
-
Save garlandkr/5e90d82d798bca2689d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#============== | |
# Start | |
#============== | |
init() { | |
sudo apt-get update | |
sudo apt-get -y dist-upgrade | |
sudo apt-get -y autoclean | |
# Call the main menu | |
main | |
} | |
#============== | |
# Time sync | |
#============== | |
timesync() { | |
# We force America/New York timezone so TV shows download at the correct time. | |
sed -i '1c\America/New_York' /etc/timezone | |
# Making sure the server stays in time sync. | |
sudo apt-get -y -q install ntp | |
if grep -q "server 2.nz.pool.ntp.org" /etc/ntp.conf; then | |
echo "NTP server already setup" | |
else | |
echo "server 2.nz.pool.ntp.org" >> /etc/ntp.conf | |
echo "server 3.oceania.pool.ntp.org" >> /etc/ntp.conf | |
echo "server 2.oceania.pool.ntp.org" >> /etc/ntp.conf | |
fi | |
sudo service ntp restart | |
} | |
#============== | |
# Map Network Drives | |
#============== | |
mapdrive() { | |
# Only manual thing to change in this script... unsure how else to solve this. | |
SHARES=( Media Downloads ) | |
# Get users NAS address | |
printf " Enter the IP address of your NAS: " | |
read -r NAS_IP | |
# Install required software | |
sudo apt-get -y -q install cifs-utils | |
# Loop over the shares and add the values to the fstab file | |
for shares in ${SHARES[@]} | |
do | |
sudo mkdir -p /media/${shares} | |
sudo sed -i '$ a\//'${NAS_IP}'/'${shares}' /media/'${shares}' cifs guest,uid=1000,iocharset=utf8,sec=ntlm 0 0' /etc/fstab | |
done | |
# Mount the shares | |
sudo mount -a | |
} | |
#============== | |
# LaSi Script | |
#============== | |
lasi() { | |
# Install required software and get the script | |
sudo apt-get -y -q install git | |
sudo git clone https://github.com/Mar2zz/LaSi.git /tmp/LaSi | |
sudo sh /tmp/LaSi/LaSi.sh | |
} | |
#============== | |
# Rtorrent/Rutorrent | |
#============== | |
rutorrent() { | |
# Get username and password for rutorrent | |
printf " Enter a username for the webui: " | |
read -r RUTORRENT_USER | |
printf " Enter a password for the webui: " | |
read -r RUTORRENT_PASSWORD | |
# Install required software and get the script | |
sudo apt-get -y -q install git unrar-free screen | |
sudo git clone https://gist.github.com/503ea057df083a008377.git /tmp/rutorrent | |
sudo sh /tmp/rutorrent/rutorrent.sh -u ${USER}::${RUTORRENT_USER}:${RUTORRENT_PASSWORD} -w --apache --rtorrent --rutorrent | |
# Install missing _task plugin.. Unsure why this is being skipped... | |
sudo svn co http://rutorrent.googlecode.com/svn/trunk/plugins/_task /var/rutorrent/rutorrent/plugins/_task | |
# Ensure rtorrent starts at boot | |
sudo sed -i "14i\screen -fa -d -m rtorrent" /etc/rc.local | |
sudo /etc/rc.local | |
} | |
#============== | |
# Plex Media Server | |
#============== | |
plex() { | |
# Get the download URL for plex. Use the 64bit Ubuntu download | |
printf " Enter URL for PMS download: " | |
read -r PLEX_URL | |
# Install required software | |
sudo apt-get -y -q install avahi-utils | |
# Download and install PMS | |
wget -P /tmp/plex ${PLEX_URL} | |
sudo dpkg -i /tmp/plex/plexmediaserver_* | |
} | |
#============== | |
# Quit | |
#============== | |
quit() { | |
exit 99 | |
} | |
#============== | |
# Menu | |
#============== | |
main() { | |
clear | |
until [ "$REPLY" = "q" ]; do | |
echo '#-----------------------------------------------#' | |
echo '# Media Server Setup #' | |
echo '#-----------------------------------------------#' | |
echo '' | |
echo '1. Timesync' | |
echo '2. LaSi' | |
echo '3. Rutorrent' | |
echo '4. Plex' | |
echo '5. Map Network Drives (Customize the SHARES array first!)' | |
echo '' | |
echo '#-----------------------------------------------#' | |
echo 'q. Quit' | |
echo '' | |
read -p 'Command : ' REPLY | |
case $REPLY in | |
1) clear && timesync ;; | |
2) clear && lasi ;; | |
3) clear && rutorrent ;; | |
4) clear && plex ;; | |
5) clear && mapdrive ;; | |
[Qq]*) clear && quit ;; | |
esac | |
done | |
} | |
init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment