248 lines
8.5 KiB
Bash
248 lines
8.5 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
main()
|
||
|
{
|
||
|
dir=$(pwd)
|
||
|
altSrvrName="nanoweb"
|
||
|
srvrName="Nanoweb"
|
||
|
|
||
|
|
||
|
ansr=$(zenity --text "Please chose an option." --radiolist --list \
|
||
|
--column "Options" --column "Descriptions" \
|
||
|
TRUE "Scan Dirs?" \
|
||
|
FALSE "Edit main settings" \
|
||
|
FALSE "Start or Stop ${srvrName}")
|
||
|
if [[ "${ansr}" == "Scan Dirs?" ]]; then
|
||
|
dirScan;
|
||
|
elif [[ "${ansr}" == "Edit main settings" ]]; then
|
||
|
passwdReq;
|
||
|
elif [[ "${ansr}" == "Start or Stop ${srvrName}" ]]; then
|
||
|
webSrvrStrt;
|
||
|
else
|
||
|
zenity --warning --text "Incorect Input!"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
dirScan()
|
||
|
{
|
||
|
find . -type d > /tmp/lzyDirList.txt
|
||
|
filename="/tmp/lzyDirList.txt"
|
||
|
|
||
|
while read -r line ; do
|
||
|
work()
|
||
|
{
|
||
|
mv ./lazyShareScan.sh "${name}/"
|
||
|
cd "${name}/"
|
||
|
./lazyShareScan.sh
|
||
|
mv ./lazyShareScan.sh "${dir}"
|
||
|
cd "${dir}"
|
||
|
}
|
||
|
name="${line}"
|
||
|
if [[ "${name}" == *"./resources"* ]] || \
|
||
|
[[ "${name}" == *"./Uploads"* ]]; then
|
||
|
echo "This is the resources dir..."
|
||
|
else
|
||
|
if [ -f "${name}"/index.php ]; then
|
||
|
echo "Index.php for "${name}" already present..."
|
||
|
else
|
||
|
work
|
||
|
fi
|
||
|
fi
|
||
|
done < "${filename}"
|
||
|
}
|
||
|
|
||
|
################## 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);
|
||
|
|
||
|
if [[ "${selec}" == "${theme}" ]]; then
|
||
|
theme;
|
||
|
elif [[ "${selec}" == "${portng}" ]]; then
|
||
|
port;
|
||
|
elif [[ "${selec}" == "${polcing}" ]]; then
|
||
|
policy;
|
||
|
elif [[ "${selec}" == "${logng}" ]]; then
|
||
|
logs;
|
||
|
elif [[ "${selec}" == "${docdir}" ]]; then
|
||
|
docRoot;
|
||
|
elif [[ "${selec}" == "${nanoSrvr}" ]]; then
|
||
|
nanoSrvrConf
|
||
|
elif [[ "${selec}" == "${main}" ]]; then
|
||
|
main;
|
||
|
elif [[ "${selec}" == "${exit}" ]]; then
|
||
|
exit;
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
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()
|
||
|
{
|
||
|
lOnLft="List On The Left"
|
||
|
lCntr="List Centered"
|
||
|
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);
|
||
|
if [[ "${theme}" == "List On The Left" ]]; then
|
||
|
echo "" > ./resources/settings-notes/css.css
|
||
|
cat ./resources/themes/"List On The Left.css" > ./resources/settings-notes/css.css
|
||
|
elif [[ "${theme}" == "List Centered" ]]; then
|
||
|
echo "" > ./resources/settings-notes/css.css
|
||
|
cat ./resources/themes/"List Centered.css" > ./resources/settings-notes/css.css
|
||
|
elif [[ "${theme}" == "Horizontal List" ]]; then
|
||
|
echo "" > ./resources/settings-notes/css.css
|
||
|
cat ./resources/themes/"Horizontal List.css" > ./resources/settings-notes/css.css
|
||
|
elif [[ "${theme}" == "Grid List" ]]; then
|
||
|
echo "" > ./resources/settings-notes/css.css
|
||
|
cat ./resources/themes/"Grid List.css" > ./resources/settings-notes/css.css
|
||
|
|
||
|
else
|
||
|
echo "An unknown error occured!"
|
||
|
fi
|
||
|
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);
|
||
|
if [[ "${ansr}" == "${noRtStrt}" ]]; then
|
||
|
$altSrvrName &
|
||
|
main;
|
||
|
elif [[ "${ansr}" == "${noRtStp}" ]]; then
|
||
|
pkill $altSrvrName &
|
||
|
main;
|
||
|
elif [[ "${ansr}" == "${rtStrt}" ]]; then
|
||
|
PASSWD="$(zenity --password --title=Authentication)\n"
|
||
|
echo -e $PASSWD | sudo -S $altSrvrName &
|
||
|
main;
|
||
|
elif [[ "${ansr}" == "${rtStp}" ]]; then
|
||
|
PASSWD="$(zenity --password --title=Authentication)\n"
|
||
|
echo -e $PASSWD | sudo -S pkill $altSrvrName &
|
||
|
main;
|
||
|
elif [[ "${ansr}" == "${main}" ]]; then
|
||
|
main;
|
||
|
elif [[ "${ansr}" == "${exit}" ]]; then
|
||
|
exit
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
main
|