270 lines
10 KiB
Bash
Executable File
270 lines
10 KiB
Bash
Executable File
#
|
|
# By Maxim F. Stewart
|
|
# Contact: [maximstewart1@gmail.com]
|
|
#
|
|
# Copyright 2013 Maxim F. Stewart
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
#-------------------------------------------------------------------------#
|
|
#!/bin/bash
|
|
|
|
|
|
main() {
|
|
dir=$(pwd)
|
|
altSrvrName="nanoweb"
|
|
srvrName="Nanoweb"
|
|
|
|
ansr=$(zenity --text "Please chose an option." --radiolist --list \
|
|
--column "Options" --column "Descriptions" --height=220 --width=250 \
|
|
TRUE "Scan Dirs?" \
|
|
FALSE "Edit main settings" \
|
|
FALSE "Requirements Check" \
|
|
FALSE "Start or Stop ${srvrName}")
|
|
case "$ansr" in
|
|
"Scan Dirs?" ) dirScan;;
|
|
"Edit main settings" ) passwdReq;;
|
|
"Requirements Check" ) chkr;;
|
|
"Start or Stop ${srvrName}" ) webSrvrStrt;;
|
|
esac
|
|
}
|
|
|
|
dirScan() {
|
|
find . -type d > /tmp/lzyDirList.txt
|
|
filename="/tmp/lzyDirList.txt"
|
|
while read -r line ; do
|
|
pre=\""${line}"
|
|
name=`echo ${pre} | sed "s|\".|"${dir}"|g" | sed "s|*|*\"|g"`
|
|
if [[ "${name}" == *"resources"* ]] || \
|
|
[[ "${name}" == *"Uploads"* ]] || \
|
|
[[ "${name}" == *"Homepage"* ]] || \
|
|
[[ "${name}" == *"tonido-server"* ]] || \
|
|
[[ "${name}" == *"vpnCredintial"* ]] || \
|
|
[[ "${name}" == *"Website Testing Platform"* ]]; then
|
|
echo "This is a resources dir..."
|
|
else
|
|
if [ -f "${name}"/index.php ]; then
|
|
echo "Index.php for "${name}" already present..."
|
|
else
|
|
work
|
|
fi
|
|
fi
|
|
done < "${filename}"
|
|
}
|
|
|
|
work() {
|
|
mv lazyShareScan.sh "${name}/"
|
|
cd "${name}/"
|
|
bash ./lazyShareScan.sh
|
|
mv lazyShareScan.sh "${dir}"
|
|
cd "${dir}"
|
|
}
|
|
|
|
################## SETTINGS SECTION ##################
|
|
passwdReq()
|
|
{
|
|
PASSWD="$(zenity --password --title=Authentication)\n"
|
|
srvrEdit;
|
|
}
|
|
|
|
srvrEdit() {
|
|
auto="Turn psudo auto scan ON or Off"
|
|
theme="Change Theme"
|
|
portng="Set Port"
|
|
polcing="Set User And Group"
|
|
logng="Set Logging Status"
|
|
docdir="Set DocumentRoot"
|
|
nanoSrvr="Open The ServerConf In Nano"
|
|
main="START MENU"
|
|
exit="Exit Script"
|
|
|
|
selec=$(zenity --list \
|
|
--text "What would you like to edit in the ServerConf file?" \
|
|
--radiolist --column "Select" --column "Options" \
|
|
TRUE "Change Theme" \
|
|
FALSE "Set Port" \
|
|
FALSE "Set User And Group" \
|
|
FALSE "Set Logging Status" \
|
|
FALSE "Set DocumentRoot" \
|
|
FALSE "Open The ServerConf In Nano" \
|
|
FALSE "START MENU" FALSE "Exit Script" \
|
|
--height 300);
|
|
case "$selec" in
|
|
"${theme}" ) theme;;
|
|
"${portng}" ) port;;
|
|
"${polcing}" ) policy;;
|
|
"${logng}" ) logs;;
|
|
"${docdir}" ) docRoot;;
|
|
"${nanoSrvr}" ) nanoSrvrConf;;
|
|
"${main}" ) main;;
|
|
"${exit}" ) exit;;
|
|
esac
|
|
}
|
|
|
|
autoOnNOff() {
|
|
x=$(zenity --entry --text "Turn On/Off psudo auto scanning?
|
|
Default is : off .
|
|
" --entry-text "off");
|
|
sed -i 1s/"auto=*.*;"/"auto=${x};"/g $HOME/.config/lazyShareSettings/config.txt
|
|
srvrEdit;
|
|
}
|
|
|
|
theme() {
|
|
theme=$(zenity --list \
|
|
--text "What would you like to edit in the ServerConf file?" \
|
|
--radiolist --column "Select" --column "Options" \
|
|
TRUE "List On The Left" \
|
|
FALSE "List Centered" \
|
|
FALSE "Horizontal List" \
|
|
FALSE "Grid List" \
|
|
--height 175);
|
|
case "${theme}" in
|
|
"List On The Left" ) echo "" > ./resources/settings-notes/css.css
|
|
cat ./resources/themes/"List On The Left.css" > ./resources/settings-notes/css.css;;
|
|
"List Centered" ) echo "" > ./resources/settings-notes/css.css
|
|
cat ./resources/themes/"List Centered.css" > ./resources/settings-notes/css.css;;
|
|
"Horizontal List" ) echo "" > ./resources/settings-notes/css.css
|
|
cat ./resources/themes/"Horizontal List.css" > ./resources/settings-notes/css.css;;
|
|
"Grid List" ) echo "" > ./resources/settings-notes/css.css
|
|
cat ./resources/themes/"Grid List.css" > ./resources/settings-notes/css.css;;
|
|
esac
|
|
srvrEdit
|
|
}
|
|
|
|
|
|
port() {
|
|
x=$(zenity --entry --text "What will be the port that the server runs on?
|
|
Anything bellow 1024 means the server must run as root.
|
|
Default is port: 80 .
|
|
" --entry-text "80");
|
|
echo -e $PASSWD | sudo -S sed -i 13s/"ListenPort = *.*"/"ListenPort = ${x}"/g /etc/nanoweb/nanoweb.conf
|
|
srvrEdit;
|
|
}
|
|
policy() {
|
|
User=$(zenity --entry --text "What will be the User for the server?
|
|
(::-WARNING-::) Please leave as default unless you know EXACTLY
|
|
what you are doing! Changing user and group policies can
|
|
affect security of the system!
|
|
The default is : www-data ." --entry-text "www-data");
|
|
echo -e $PASSWD | sudo -S sed -i 187s/"User = *.*"/"User = ${User}"/g /etc/nanoweb/nanoweb.conf
|
|
|
|
Group=$(zenity --entry --text "What will be the Group for the server?
|
|
(::-WARNING-::) Please leave as default unless you know EXACTLY
|
|
what you are doing! Changing user and group policies can
|
|
affect security of the system!
|
|
The default is : www-data." --entry-text "www-data");
|
|
echo -e $PASSWD | sudo -S sed -i 188s/"Group = *.*"/"Group = ${Group}"/g /etc/nanoweb/nanoweb.conf
|
|
srvrEdit;
|
|
}
|
|
logs() {
|
|
logs=$(zenity --list --text "Do you wish to have AccessLog and ErrorLog enabled?
|
|
If this server isn't running 24/7 nor a production server then it can be OK to keep
|
|
logging off. It may also lessen the system resource load and speed up the server.
|
|
If this server runs 24/7 or is a production server then we advise keeping logging on
|
|
as added security. Respectively, it may add more resource demands and slow down the server.
|
|
Frankly, the effects are negligible in both instances so it's up to you.
|
|
The default is : Enabled .
|
|
" --radiolist --column "Select" --column "Options" TRUE Enable FALSE Disable --height 280);
|
|
yes="Enable"
|
|
no="Disable"
|
|
|
|
if [[ "${logs}" == "${yes}" ]]; then
|
|
echo -e $PASSWD | sudo -S sed -i 194s/"#LoggerProcess = *.*"/"LoggerProcess = 2"/g /etc/nanoweb/nanoweb.conf
|
|
echo -e $PASSWD | sudo -S sed -i 197s/"#LoggerUser"/"LoggerUser"/g /etc/nanoweb/nanoweb.conf
|
|
echo -e $PASSWD | sudo -S sed -i 198s/"#LoggerGroup"/"LoggerGroup"/g /etc/nanoweb/nanoweb.conf
|
|
echo -e $PASSWD | sudo -S sed -i 201s/"#LogDir"/"LogDir"/g /etc/nanoweb/nanoweb.conf
|
|
echo -e $PASSWD | sudo -S sed -i 207s/"#Log"/"Log"/g /etc/nanoweb/nanoweb.conf
|
|
elif [[ "${logs}" == "${no}" ]]; then
|
|
echo -e $PASSWD | sudo -S sed -i 194s/"LoggerProcess = *.*"/"#LoggerProcess = 0"/g /etc/nanoweb/nanoweb.conf
|
|
echo -e $PASSWD | sudo -S sed -i 197s/"LoggerUser"/"#LoggerUser"/g /etc/nanoweb/nanoweb.conf
|
|
echo -e $PASSWD | sudo -S sed -i 198s/"LoggerGroup"/"#LoggerGroup"/g /etc/nanoweb/nanoweb.conf
|
|
echo -e $PASSWD | sudo -S sed -i 201s/"LogDir"/"#LogDir"/g /etc/nanoweb/nanoweb.conf
|
|
echo -e $PASSWD | sudo -S sed -i 207s/"Log"/"#Log"/g /etc/nanoweb/nanoweb.conf
|
|
fi
|
|
srvrEdit;
|
|
}
|
|
nanoSrvrConf() {
|
|
echo -e $PASSWD | sudo -S xterm -e nano /etc/nanoweb/nanoweb.conf
|
|
srvrEdit;
|
|
}
|
|
docRoot() {
|
|
docDir=$(zenity --entry \
|
|
--text "What do you wish to set as DocumentRoot?
|
|
Document root is what the server defines as the directory in which files will
|
|
be served from. Group permissions must allow for the directory to be used so
|
|
please be aware of that.
|
|
The default is : /var/www/nanoweb ." --entry-text "/var/www/nanoweb");
|
|
echo -e $PASSWD | sudo -S sed -i 204s,"DocumentRoot = *.*","DocumentRoot = ${docDir}",g /etc/nanoweb/nanoweb.conf
|
|
srvrEdit;
|
|
}
|
|
|
|
webSrvrStrt() {
|
|
noRtStrt="Start $srvrName No Root?" ; noRtStp="Stop $srvrName No Root?" ;
|
|
rtStrt="Start $srvrName Root?" ; rtStp="Stop $srvrName Root?";
|
|
main="START MENU" ; exit="Exit Script" ;
|
|
ansr=$(zenity --list --text "Please select an option bellow to apply!!
|
|
" --radiolist --column "Select" --column "Options
|
|
" TRUE "Start $srvrName No Root?" FALSE "Stop $srvrName No Root?
|
|
" FALSE "Start $srvrName Root?" FALSE "Stop $srvrName Root?
|
|
" FALSE "START MENU" FALSE "Exit Script" --height 330);
|
|
|
|
case "${ansr}" in
|
|
"${noRtStrt}" ) $altSrvrName & main;;
|
|
"${noRtStp}" ) pkill $altSrvrName & main;;
|
|
"${rtStrt}" ) PASSWD="$(zenity --password --title=Authentication)\n"
|
|
echo -e $PASSWD | sudo -S $altSrvrName & main;;
|
|
"${rtStp}" ) PASSWD="$(zenity --password --title=Authentication)\n"
|
|
echo -e $PASSWD | sudo -S pkill $altSrvrName & main;;
|
|
"${main}" ) main;;
|
|
"${exit}" ) exit;;
|
|
esac
|
|
}
|
|
chkr() {
|
|
altSrvrName="nanoweb"
|
|
srvrName="Nanoweb"
|
|
|
|
plugChkr=`which gnome-mplayer`
|
|
plugChkr2=`ls /etc/${altSrvrName}/${altSrvrName}.conf`
|
|
plugChkr3=`which php5-cgi`
|
|
|
|
if [[ ${plugChkr} == "" || \
|
|
${plugChkr2} == "" || \
|
|
${plugChkr3} == "" ]]; then
|
|
Install="Install"
|
|
noInstall="Do Not Install"
|
|
|
|
replyinst=$(zenity --list \
|
|
--text "We need to install one or more pre-requsit programs or
|
|
settings are missing. The missing program(s) is/are
|
|
gecko-mediaplayer, $srvrName, and/or php5-cgi." \
|
|
--radiolist --column "Select" \
|
|
--column "Options" TRUE "Install" FALSE "Do Not Install" \
|
|
--height 220);
|
|
|
|
if [[ "${replyinst}" == "${Install}" ]]; then
|
|
PASSWD="$(zenity --password --title=Authentication)\n"
|
|
|
|
echo "# Installing gecko-mediaplayer..." ; sleep 1
|
|
echo -e $PASSWD | sudo apt-get install gecko-mediaplayer -y
|
|
echo "# Installing "${altSrvrName}"..." ; sleep 1
|
|
echo -e $PASSWD | sudo apt-get install "${altSrvrName}" -y
|
|
echo "# Installing php5-cgi..." ; sleep 1
|
|
echo -e $PASSWD | sudo apt-get install php5-cgi -y
|
|
echo "# Killing "${altSrvrName}"..." ; sleep 1
|
|
echo -e $PASSWD | sudo killall $altSrvrName -y
|
|
echo "# Finished!" ; sleep 1
|
|
fi
|
|
fi
|
|
}
|
|
main
|