Initial commit...

This commit is contained in:
2021-02-18 17:45:52 -06:00
parent dc3906fa9b
commit 1180e3171f
2159 changed files with 45470 additions and 2 deletions

View File

@@ -0,0 +1,213 @@
#
# By Maxim F. Stewart
# Contact: [maxim2131@gmail.com] OR [gamer1119@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
#
#
# adds settings to this run if requested
chkr()
{
altSrvrName="nanoweb"
srvrName="Nanoweb"
plugChkr=$(ls /usr/bin/gnome-mplayer)
plugChkr2=$(ls /etc/${altSrvrName}/${altSrvrName}.conf)
plugChkr3=$(ls /usr/bin/php5-cgi)
pluginstld=$(echo /usr/bin/gnome-mplayer)
pluginstld2=$(echo /etc/${altSrvrName}/${altSrvrName}.conf)
pluginstld3=$(echo /usr/bin/php5-cgi)
if [[ ${plugChkr} == ${pluginstld} && \
${plugChkr2} == ${pluginstld2} && \
${plugChkr3} == ${pluginstld3} && \
${sttngsChkr} == ${sttngsChkr2} ]]; then
main;
else
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 -e $PASSWD | sudo -S apt-get update | zenity \
--title="Updating..." \
--progress --pulsate \
--auto-close
sleep 1
echo -e $PASSWD | sudo -S apt-get install gecko-mediaplayer \
"${altSrvrName}" php5-cgi -y
sleep 1
echo -e $PASSWD | sudo -S killall $altSrvrName
main;
elif [[ "${replyinst}" == "${noInstall}" ]]; then
main;
fi
fi
}
main()
{
declare -A movies=([.mkv]= [.mp4]= [.mpg]= [.avi]= [.mov]= [.MOV]= [.flv]= [.wmv]= [.ogv]= [,webm]= [.m4v]=)
ls ./ > ./dirList.txt ;
x=$(cat ./dirList.txt | wc -l) >> /dev/null ;
i="1"
while [ $i -le $x ]; do
line1=$(sed -n "${i}p" ./dirList.txt);
fileNm=$(echo "$line1" | sed 's/.*\///');
fileExtnsn=$(echo "$line1" | sed 's/^.*\././g');
outFile=$(echo ${line1%.*});
if [[ "${movies[$fileExtnsn]-X}" == "${movies[$fileExtnsn]}" ]]; then
if [ -f /home/LazyShare/resources/thumbnails/"${outFile}".jpg ]; then
echo "Not a video or already present...."
else
ffmpegthumbnailer -w -t="00:10:00" -c jpg -i "${fileNm}" -s 310 -o /home/LazyShare/resources/thumbnails/"${outFile}".jpg
fi
fi
i=$[$i++1] ;
done
rm dirList.txt
IFS=$'\n' bgs=($(ls -L /home/LazyShare/resources/backgrounds/))
numdirs=${#bgs[@]}
index=$(( (( RANDOM % $numdirs ) - 2) + 1 ))
if [ -f ./000.jpg ]; then
bg="<div id="bg"><img src="./000.jpg"/></div>";
else
bg="<div id="bg"><img src="/resources/backgrounds/${bgs[index]}"/></div>";
fi
echo '<!doctype html>
<html lang="en">
<head>
<title>LazyShare</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/resources/settings-notes/css.css" type="text/css">
<script type="text/javascript" src="http://www.midijs.net/lib/midi.js"></script>
</head>
<body>
'${bg}'
<a href="../">
<img src="/resources/icons/left.png" class="backbutton" alt="Can Not Display Picture" />
</a><br>
<div class="header">
<form action="/resources/settings-notes/upload.php" method="post" enctype="multipart/form-data">
Select a file to upload:
<input type="file" name="fileToUpload" id="fileToUpload"><br>
<input type="submit" value="Upload File" name="submit">
</form>
</div>' > ./index.php
absPth="/home/LazyShare/"
dirScan
}
dirScan()
{
touch /tmp/dirList.txt ;
ls -p | grep "/" > /tmp/dirList.txt ;
sed -i 's/\/$//' /tmp/dirList.txt
d=$(cat /tmp/dirList.txt | wc -l) >> /dev/null ;
i="1"
while [ $i -le $d ]; do
line=$(sed -n "${i}p" /tmp/dirList.txt);
fileNm=$(echo "$line" | sed 's/*\///');
if [[ "${fileNm}" == *"resources"* ]]; then
echo "In root dir; wont add resources as list option..."
else
if [ -f "${absPth}"resources/thumbnails/"${fileNm}".jpg ]; then
echo '
<div class="lnksNdirs"><a href="'${fileNm}'" style="color:#00E8FF;">
<img src="/resources/thumbnails/'${fileNm}'.jpg" /><br>'${fileNm}'</a>
</div>' >> ./index.php ;
else
echo '
<div class="lnksNdirs"><a href="'${fileNm}'" style="color:#00E8FF;">
<img src="/resources/icons/folder.png" /><br>'${fileNm}'</a>
</div>' >> ./index.php ;
fi
fi
i=$[$i++1];
done
mainScaner
}
mainScaner()
{
# Associative Arrays set to compare against the file extension
declare -A movies=([.mkv]= [.mp4]= [.mpg]= [.avi]= [.mov]= [.MOV]= [.flv]= [.wmv]= [.ogv]= [.webm]= [.m4v]=)
declare -A music=([.mp2]= [.mp3]= [.ogg]= [.flac]= [.mid]=)
declare -A docs=([.doc]= [.docx]= [.txt]= [.pdf]= [.odt]=)
declare -A pics=([.png]= [.jpg]= [.jpeg]= [.gif]=)
declare -A invis=([.sh]= [index.php]=)
ls ./ > /tmp/list.txt ;
x=$(cat /tmp/list.txt | wc -l) >> /dev/null ;
i="1"
while [ $i -le $x ]; do
line1=$(sed -n "${i}p" /tmp/list.txt) ;
fileNm=$(echo "$line1" | sed 's/.*\///') ;
fileExtnsn=$(echo "$line1" | sed 's/^.*\././g') ;
thbnal=$(echo ${fileNm%.*});
if [[ "${pics[$fileExtnsn]-X}" == "${pics[$fileExtnsn]}" ]]; then
echo '<a href="'${fileNm}'" target="frame"><img src="'${fileNm}'" class="imgsStyl" alt="Load Fail" /></a>' >> ./index.php ;
elif [[ "${music[$fileExtnsn]-X}" == "${music[$fileExtnsn]}" ]]; then
if [[ ${fileExtnsn} == *".mid"* ]]; then
echo '<div class="lnksNdirs">
<a href="#" style="color:#00E8FF;" onClick="MIDIjs.play('\'${fileNm}''\'');">Play '${fileNm}'</a>
</div>' >> ./index.php ;
else
echo '<div class="lnksNdirs">
<a href="'${fileNm}'" target="frame" style="color:#00E8FF;">'${fileNm}'</a></div>' >> ./index.php ;
fi
elif [[ "${movies[$fileExtnsn]-X}" == "${movies[$fileExtnsn]}" ]]; then
if [ -f "${absPth}"resources/thumbnails/"${thbnal}".jpg ]; then
echo '<div class="lnksNdirs">
<a href="'${fileNm}'" target="frame" style="color:#00E8FF;">
<img src="/resources/thumbnails/'${thbnal}'.jpg" /><br>'${fileNm}'</a></div>' >> ./index.php ;
else
echo '<div class="lnksNdirs">
<a href="'${fileNm}'" target="frame" style="color:#00E8FF;">'${fileNm}'</a></div>' >> ./index.php ;
fi
elif [[ "${docs[$fileExtnsn]-X}" == "${docs[$fileExtnsn]}" ]]; then
echo '<a class="lnksNdirs" target="frame" href="'${fileNm}'" style="color:#00E8FF;">'${fileNm}'</a><br>' >> ./index.php ;
elif [[ "${invis[$fileExtnsn]-X}" == "${invis[$fileExtnsn]}" ]]; then
echo "File not added to index.php!!" ;
fi
i=$[$i++1] ;
done
echo '<iframe id="frame" name="frame" frameborder="0" class="iframer"></iframe>
</body>
</html>' >> ./index.php
exit
}
chkr

View File

@@ -0,0 +1,36 @@
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html"; charset=utf-8" />
<title>Page List</title>
<link rel="stylesheet" href="./resources/settings-notes/css.css" type="text/css">
</head>
<body>
<div id="bg"><img src="./resources/backgrounds/waterFall.gif"/></div>
<div class="section"><header style="font-size:200%;color:green;">LazyShare</header></div>
<br>
<div style="margin-left:15%;">
<a href="./Pictures">
<div class="homeSection">
<img style="margin-top:2em;" src="./resources/icons/pics.png"/>
<br>Pictures</div></a>
<a href="./Movies-TV-Music">
<div class="homeSection">
<img style="margin-top:2em;" src="./resources/icons/video.png"/>
<img style="margin-top:2em;" src="./resources/icons/music.png"/>
<br>Movies-TV-Music</div></a>
<a href="./Documents">
<div class="homeSection">
<img style="margin-top:2em;" src="./resources/icons/docs.png"/>
<br>Documents</div></a>
<a href="./Uploads">
<div class="homeSection">
<img style="margin-top:2em;" src="./resources/icons/docs.png"/>
<br>Uploads</div></a>
</body>
</html>

View File

@@ -0,0 +1,247 @@
#!/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