--- /dev/null
+#!/bin/bash
+
+RUSER="xf0r3m"
+SERVER="192.168.122.99"
+SSH_OPTS=""
+ssh_opts=$(echo $SSH_OPTS | tr [A-Z] [a-z]);
+
+function help() {
+ echo "mmftp - script for handling Apache's user dirs";
+ echo "@ 2024 morketsmerke.org";
+ echo;
+ echo "Options: ";
+ echo;
+ echo "put <source> [dest] - upload file/s. Destination";
+ echo " should be from \${HOME}/public_html, if none files will be";
+ echo " placed in \${HOME}/public_html";
+ echo;
+ echo "get <source> [dest] - download file/s. Source";
+ echo " should be from \${HOME}/public_html. If destination";
+ echo " is none, then . (dot) will be used";
+ echo;
+ echo "weblinks [-n] <dir> - print URL-s for all files in dir";
+ echo " dir should be relative path from \${HOME}/public_html";
+ echo " -n - use IP address instead of FQDN in URL-s";
+ echo;
+ echo "list [dir] - list elements in dir, if dir is none then";
+ echo " \${HOME}/public_html will be used.";
+ echo;
+ echo "hide [dir] - emits index.html file to all subdirs in dir";
+ echo " dir should be relative path from \${HOME}/public_html";
+ echo " if dir is none emmision starts from \${HOME}/public_html";
+ echo;
+ echo "unhide [dir] - remove index.html from all subdirs in dir";
+ echo " dir should be relative path from \${HOME}/public_html";
+ echo " if dir is none deletion starts from \${HOME}/public_html";
+ echo;
+ echo "Configuration: ";
+ echo;
+ echo "Befor you use this script, you must point in script source";
+ echo "code: remote user, server address and extra SSH options";
+ echo "(eg. port). SSH options are optional.";
+ echo;
+ echo "RUSER = remote user";
+ echo "SERVER = server address";
+ echo "SSH_OPTS = extra SSH options (optional)";
+ echo;
+ echo "Usage: ";
+ echo "$ ./mmftp put images";
+ echo "$ ./mmftp get examples ~/Documents";
+ echo "$ ./mmftp weblinks images";
+ echo "$ ./mmftp list";
+ echo "$ ./mmftp hide images";
+ echo "$ ./mmftp unhide images";
+ echo;
+}
+
+if [ ! "$RUSER" ]; then help; exit 1; fi
+if [ ! "$SERVER" ]; then help; exit 1; fi
+
+if [ ! "$1" ]; then help; exit 1;
+else
+
+case $1 in
+ "put") scp ${SSH_OPTS} -r $2 ${RUSER}@${SERVER}:/home/${RUSER}/public_html/$3;;
+ "get") scp ${SSH_OPTS} -r ${RUSER}@${SERVER}:/home/${RUSER}/public_html/$2 ${3:-.};;
+ "weblinks") if [ "$2" ] && [ "$2" = "-n" ]; then
+ ssh ${ssh_opts} ${RUSER}@${SERVER} "weblinks -n $3";
+ else
+ ssh ${ssh_opts} ${RUSER}@${SERVER} "weblinks $2";
+ fi;;
+ "list") ssh ${ssh_opts} ${RUSER}@${SERVER} "ls -AF /home/${RUSER}/public_html/$2";;
+ "hide") ssh ${ssh_opts} ${RUSER}@${SERVER} "if [ -f ~/index.html ]; then propagate index.html $2; else echo 'It works\!' > ~/index.html; propagate index.html $2; fi";;
+ "unhide") ssh ${ssh_opts} ${RUSER}@${SERVER} "propagate -u index.html $2";;
+esac
+
+fi