Ændring af script - Sprog ukendt.
Hej Eksperten.Jeg har et script, som jeg har behov for at få tilpasset mit eget behov.
Det er et script til at tilføje nogle argumenter til en FTP server på min nas, og genstarte ftp serveren-
Jeg har udelukkende behov for et argument felt, og ikke de 3 muligheder som der er i scriptet. Så jeg selv bare kan skrive alle argumenterne ind.
Er der en af jer, der kan hjælpe mig med dette, da jeg ikke lige er så ferm i den her slags scripting.
Mvh:
Kim
---
PLUGIN=ftp
ftp_is_running()
{
local server=` /bin/ps | grep pure-ftpd | grep -v grep `
[ "$server" = "" ] && return 1
return 0
}
ftp_OnGet()
{
local title="FTP daemon"
local enabled=` ReadParam ${PLUGIN}_EnableAddress `
local forceftps=` ReadParam ${PLUGIN}_ForceFtpes `
local fxp=` ReadParam ${PLUGIN}_FXP `
[ -z $fxp ] && fxp=nobody
if [ "$1" = "title" ] ; then
[ "$enabled" = "1" ] && echo ${title}${2} && return 0
[ "$forceftps" = "1" ] && echo ${title}${2} && return 0
[ "$fxp" != 'nobody' ] && echo ${title}${2} && return 0
echo $title && return 0
fi
[ "$enabled" = "1" ] && ENABLEADDRESS=CHECKED
local address=` ReadParam ${PLUGIN}_Address `
[ -z "${address}" ] && address=` wget http://icanhazip.com/ -q -O - `
[ "$forceftps" = "1" ] && FORCEFTPS=CHECKED
cat >&1 <<__EOF__
<form method="GET">
<H3>$title</H3>
<input type="hidden" name="plugin" value="${PLUGIN}" >
<input type="checkbox" name="enableaddress" $ENABLEADDRESS >Change advertised IP address <input type="input" name="address" value="${address}" ><br>
Force the specified IP address in reply to a PASV/EPSV/SPSV command. If the server is behind a masquerading (NAT) box that doesn't properly handle stateful FTP masquerading, put the ip address of that box here. If you have a dynamic IP address, you can use a symbolic host name (probably the one of your gateway), that will be resolved every time a new client will connect.
# '
<br><br><input type="checkbox" name="forceftps" $FORCEFTPS >Force <a href="http://en.wikipedia.org/wiki/FTPS">FTPS</a><br>
<br>Enable <a href="https://en.wikipedia.org/wiki/File_eXchange_Protocol">FXP</a> for <select name="fxp" style="font-size:1.1em;" >
__EOF__
for option in nobody anonymous user
do
echo -ne "\t<option value=\"${option}\" "
[ "$option" = "$fxp" ] && echo -n selected # in XHTML: "selected=\"selected\""
echo ">${option}</option>"
done
cat >&1 <<__EOF__
</select><br>
<br><input type="submit" name="submit" value="Apply">
</form>
__EOF__
}
ftp_OnPut()
{
if [ "on" = "$enableaddress" ] ; then
WriteParam ${PLUGIN}_EnableAddress 1
else
WriteParam ${PLUGIN}_EnableAddress 0
fi
WriteParam ${PLUGIN}_Address ${address}
if [ "on" = "$forceftps" ] ; then
WriteParam ${PLUGIN}_ForceFtpes 1
else
WriteParam ${PLUGIN}_ForceFtpes 0
fi
WriteParam ${PLUGIN}_FXP ${fxp}
}
create_extra_params()
{
local extra=""
local enabled=` ReadParam ${PLUGIN}_EnableAddress `
if [ "$enabled" = "1" ] ; then
local address=` ReadParam ${PLUGIN}_Address `
[ -z "${address}" ] || extra="${extra} -P ${address}"
fi
local forceftps=` ReadParam ${PLUGIN}_ForceFtpes `
[ "${forceftps}" = "1" ] && extra="${extra} -f 0 -O stat:/var/log/pureftpd.log -Y 2"
local fxp=` ReadParam ${PLUGIN}_FXP `
case $fxp in
anonymous)
extra="${extra} -W"
;;
user)
extra="${extra} -w"
;;
nobody)
;;
*)
;;
esac
echo "${extra}"
}
PUREFTPD=/usr/local/sbin/pure-ftpd
ftp_restart()
{
ftp_is_running
[ $? -eq 0 ] && /usr/local/sbin/vsftpd_start_silent.sh
}
ftp_OnStop()
{
umount ${PUREFTPD}
rm ${TWEAKS_STORAGE}ftp_param
}
ftp_OnCommand()
{
local param=` create_extra_params `
[ -f ${TWEAKS_STORAGE}ftp_param ] && [ "${param}" = "` cat ${TWEAKS_STORAGE}ftp_param `" ] && return
ftp_OnStop
ftp_OnStart
[ "${param}" = "" ] && ftp_restart
}
ftp_OnStart()
{
local param=` create_extra_params `
echo "$param" >${TWEAKS_STORAGE}ftp_param
[ "$param" = "" ] && return
ret=` mount --bind ${TWEAKS_PLUGINDIR}ftp.sh ${PUREFTPD} `
ftp_restart
}
intercept_pure_ftpd()
{
PKGNAME=Tweaks
TWEAKS_STORAGE=/tmp/.${PKGNAME}/
. ${TWEAKS_STORAGE}env
[ -f /tmp/${PKGNAME}.log ] && echo "` date ` $0 $@ ` cat ${TWEAKS_STORAGE}ftp_param `" >>/tmp/${PKGNAME}.log
exec /ram_bin${PUREFTPD} $@ ` cat ${TWEAKS_STORAGE}ftp_param `
}
[ "` basename $0 `" = "pure-ftpd" ] && intercept_pure_ftpd "$@"
---