mirror of
https://github.com/3proxy/3proxy.git
synced 2026-04-06 21:30:12 +08:00
Use non-chroot configuration in cmake; remove older script
This commit is contained in:
parent
b0db65dfde
commit
d502ecb0fd
@ -509,6 +509,56 @@ if(NOT WIN32)
|
|||||||
install(FILES scripts/add3proxyuser.sh DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(FILES scripts/add3proxyuser.sh DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Install service files (systemd or init.d)
|
||||||
|
if(NOT WIN32)
|
||||||
|
# Check for systemd
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
if(PkgConfig_FOUND)
|
||||||
|
pkg_check_modules(SYSTEMD QUIET systemd)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SYSTEMD_FOUND)
|
||||||
|
# systemd is available - install systemd service
|
||||||
|
# Get systemd unit directory
|
||||||
|
pkg_get_variable(SYSTEMD_UNIT_DIR systemd systemdsystemunitdir)
|
||||||
|
if(NOT SYSTEMD_UNIT_DIR)
|
||||||
|
# Fallback to common location
|
||||||
|
set(SYSTEMD_UNIT_DIR "/lib/systemd/system")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Configure and install systemd service file
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/scripts/3proxy.service.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/3proxy.service
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/3proxy.service
|
||||||
|
DESTINATION ${SYSTEMD_UNIT_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Install tmpfiles.d configuration for runtime directory
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/scripts/3proxy.tmpfiles.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/3proxy.conf
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/3proxy.conf
|
||||||
|
DESTINATION /usr/lib/tmpfiles.d
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS " systemd: YES (${SYSTEMD_UNIT_DIR})")
|
||||||
|
else()
|
||||||
|
# No systemd - install init.d script
|
||||||
|
install(FILES scripts/init.d/3proxy.sh
|
||||||
|
DESTINATION /etc/init.d
|
||||||
|
RENAME 3proxy
|
||||||
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS " systemd: NO (using init.d)")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Install man pages
|
# Install man pages
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
file(GLOB MAN3_FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/*.3")
|
file(GLOB MAN3_FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/*.3")
|
||||||
|
|||||||
@ -50,6 +50,7 @@ install: all
|
|||||||
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
||||||
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
||||||
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
||||||
|
install scripts/init.d/proxy.sh /usr/local/etc/rc.d/3proxy
|
||||||
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
||||||
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
||||||
|
|||||||
@ -72,8 +72,8 @@ INSTALL_OBJS = bin/3proxy \
|
|||||||
|
|
||||||
|
|
||||||
INSTALL_CFG = scripts/3proxy.cfg.chroot
|
INSTALL_CFG = scripts/3proxy.cfg.chroot
|
||||||
INSTALL_CFG_OBJS = scripts/3proxy.cfg \
|
INSTALL_CFG_INCHROOT = scripts/3proxy.cfg.inchroot
|
||||||
scripts/add3proxyuser.sh
|
INSTALL_CFG_OBJS = scripts/add3proxyuser.sh
|
||||||
|
|
||||||
INSTALL_CFG_OBJS2 = counters bandlimiters
|
INSTALL_CFG_OBJS2 = counters bandlimiters
|
||||||
|
|
||||||
@ -117,6 +117,7 @@ install-etc-default-config: install-chroot-dir
|
|||||||
ln -s $(CHROOTREL)/conf $(INSTALL_CFG_DEST); \
|
ln -s $(CHROOTREL)/conf $(INSTALL_CFG_DEST); \
|
||||||
$(INSTALL_BIN) $(INSTALL_CFG) $(ETCDIR)/3proxy.cfg; \
|
$(INSTALL_BIN) $(INSTALL_CFG) $(ETCDIR)/3proxy.cfg; \
|
||||||
$(INSTALL_BIN) $(INSTALL_CFG_OBJS) $(INSTALL_CFG_DEST); \
|
$(INSTALL_BIN) $(INSTALL_CFG_OBJS) $(INSTALL_CFG_DEST); \
|
||||||
|
$(INSTALL_BIN) $(INSTALL_CFG_INCHROOT) $(INSTALL_CFG_DEST)/3proxy.cfg; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install-etc: install-etc-dir install-etc-default-config
|
install-etc: install-etc-dir install-etc-default-config
|
||||||
|
|||||||
@ -48,23 +48,17 @@ endif
|
|||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
if [ ! -d /usr/local/etc/3proxy/bin ]; then mkdir -p /usr/local/etc/3proxy/bin/; fi
|
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
||||||
install bin/3proxy /usr/local/etc/3proxy/bin/3proxy
|
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
||||||
install bin/mycrypt /usr/local/etc/3proxy/bin/mycrypt
|
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
||||||
install scripts/rc.d/proxy.sh /usr/local/etc/rc.d/proxy.sh
|
install scripts/init.d/proxy.sh /usr/local/etc/rc.d/3proxy
|
||||||
install scripts/add3proxyuser.sh /usr/local/etc/3proxy/bin/
|
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then
|
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
||||||
echo /usr/local/etc/3proxy/3proxy.cfg already exists
|
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
||||||
else
|
touch /usr/local/3proxy/passwd
|
||||||
install scripts/3proxy.cfg /usr/local/etc/3proxy/
|
touch /usr/local/3proxy/counters
|
||||||
if [ ! -d /var/log/3proxy/ ]; then
|
touch /usr/local/3proxy/bandlimiters
|
||||||
mkdir /var/log/3proxy/
|
echo Run /usr/local/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
||||||
fi
|
|
||||||
touch /usr/local/etc/3proxy/passwd
|
|
||||||
touch /usr/local/etc/3proxy/counters
|
|
||||||
touch /usr/local/etc/3proxy/bandlimiters
|
|
||||||
echo Run /usr/local/etc/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
|
||||||
fi
|
|
||||||
|
|
||||||
allplugins:
|
allplugins:
|
||||||
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
||||||
|
|||||||
@ -1,59 +0,0 @@
|
|||||||
DESTDIR =
|
|
||||||
prefix = /usr/local
|
|
||||||
exec_prefix = $(prefix)
|
|
||||||
man_prefix = $(prefix)/share
|
|
||||||
|
|
||||||
INSTALL = /usr/bin/install
|
|
||||||
INSTALL_BIN = $(INSTALL) -m 755
|
|
||||||
INSTALL_DATA = $(INSTALL) -m 644
|
|
||||||
INSTALL_OBJS = bin/3proxy \
|
|
||||||
bin/ftppr \
|
|
||||||
bin/mycrypt \
|
|
||||||
bin/pop3p \
|
|
||||||
bin/proxy \
|
|
||||||
bin/socks \
|
|
||||||
bin/tcppm \
|
|
||||||
bin/udppm \
|
|
||||||
scripts/add3proxyuser.sh
|
|
||||||
|
|
||||||
INSTALL_CFG_OBJS = scripts/3proxy.cfg
|
|
||||||
INSTALL_CFG_DEST = config
|
|
||||||
|
|
||||||
INSTALL_CFG_OBJS2 = passwd counters bandlimiters
|
|
||||||
|
|
||||||
MANDIR1 = $(DESTDIR)$(man_prefix)/man/man1
|
|
||||||
MANDIR3 = $(DESTDIR)$(man_prefix)/man/man3
|
|
||||||
MANDIR8 = $(DESTDIR)$(man_prefix)/man/man8
|
|
||||||
BINDIR = $(DESTDIR)$(exec_prefix)/bin
|
|
||||||
ETCDIR = $(DESTDIR)$(prefix)/etc/3proxy
|
|
||||||
|
|
||||||
install-bin:
|
|
||||||
$(INSTALL_BIN) -d $(BINDIR)
|
|
||||||
$(INSTALL_BIN) -s $(INSTALL_OBJS) $(BINDIR)
|
|
||||||
|
|
||||||
install-etc-dir:
|
|
||||||
$(INSTALL_BIN) -d $(ETCDIR)
|
|
||||||
|
|
||||||
install-etc-default-config:
|
|
||||||
if [ -f $(ETCDIR)/$(INSTALL_CFG_DEST) ]; then \
|
|
||||||
: ; \
|
|
||||||
else \
|
|
||||||
$(INSTALL_DATA) $(INSTALL_CFG_OBJS) $(ETCDIR)/$(INSTALL_CFG_DEST) \
|
|
||||||
fi
|
|
||||||
|
|
||||||
install-etc: install-etc-dir
|
|
||||||
for file in $(INSTALL_CFG_OBJS2); \
|
|
||||||
do \
|
|
||||||
touch $(ETCDIR)/$$file; chmod 0600 $(ETCDIR)/$$file; \
|
|
||||||
done;
|
|
||||||
|
|
||||||
install-man:
|
|
||||||
$(INSTALL_BIN) -d $(MANDIR1)
|
|
||||||
$(INSTALL_BIN) -d $(MANDIR3)
|
|
||||||
$(INSTALL_BIN) -d $(MANDIR8)
|
|
||||||
$(INSTALL_DATA) man/*.1 $(MANDIR1)
|
|
||||||
$(INSTALL_DATA) man/*.3 $(MANDIR3)
|
|
||||||
$(INSTALL_DATA) man/*.8 $(MANDIR8)
|
|
||||||
|
|
||||||
install: install-bin install-etc install-man
|
|
||||||
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for GCC/windows
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
|
||||||
# library support
|
|
||||||
|
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
|
||||||
CC = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
|
||||||
CFLAGS = -O2 -s -c -mthreads -DNOODBC -D_WINCE -D_WIN32 -DNORADIUS -D__USE_W32_SOCKETS
|
|
||||||
COUT = -o
|
|
||||||
LN = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
|
||||||
LDFLAGS = -O2 -s -mthreads
|
|
||||||
DLFLAGS = -shared
|
|
||||||
DLSUFFICS = .dll
|
|
||||||
LIBS = -lws2
|
|
||||||
LNOUT = -o
|
|
||||||
EXESUFFICS = .exe
|
|
||||||
OBJSUFFICS = .o
|
|
||||||
DEFINEOPTION = -D
|
|
||||||
COMPFILES = *.tmp
|
|
||||||
REMOVECOMMAND = rm -f
|
|
||||||
TYPECOMMAND = more
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.winCE
|
|
||||||
PLUGINS = TrafficPlugin StringsPlugin
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; rm *.o ; cd ../.. ; done
|
|
||||||
@ -1,985 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# 3proxy build and install script for Debian Linux
|
|
||||||
# Release 2.0 at 29.12.2016
|
|
||||||
# (с) Evgeniy Solovyev
|
|
||||||
# mail-to: eugen-soloviov@yandex.ru
|
|
||||||
|
|
||||||
ScriptPath=""
|
|
||||||
Src3proxyDirPath=""
|
|
||||||
ScriptName=""
|
|
||||||
ScriptFullName=""
|
|
||||||
SourceRoot=""
|
|
||||||
|
|
||||||
ResourcesData=""
|
|
||||||
|
|
||||||
|
|
||||||
ProxyVersion=""
|
|
||||||
LasestProxyVersion=""
|
|
||||||
LasestProxyVersionLink=""
|
|
||||||
UseSudo=0
|
|
||||||
PacketFiles=""
|
|
||||||
NeedSourceUpdate=0
|
|
||||||
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
local msgNewVersion
|
|
||||||
local msgInsertYorN
|
|
||||||
|
|
||||||
VarsInit
|
|
||||||
LoadResources
|
|
||||||
CheckRunConditions
|
|
||||||
|
|
||||||
if [ $UseSudo == 1 ]
|
|
||||||
then
|
|
||||||
sudo bash "${0}"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
CheckLocation
|
|
||||||
GetLasestVersionInfo
|
|
||||||
|
|
||||||
SourceDownloadOrUpdate
|
|
||||||
|
|
||||||
cd "${SourceRoot}"
|
|
||||||
|
|
||||||
Build3Proxy
|
|
||||||
BinInstall
|
|
||||||
ManInstall
|
|
||||||
CreateLogDir
|
|
||||||
CopyConfig
|
|
||||||
SetInit
|
|
||||||
Pack3proxyFiles
|
|
||||||
}
|
|
||||||
|
|
||||||
VarsInit()
|
|
||||||
{
|
|
||||||
cd `dirname $0`
|
|
||||||
ScriptPath="${PWD}"
|
|
||||||
ScriptName=`basename $0`
|
|
||||||
ScriptFullName="${ScriptPath}/${ScriptName}"
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckLocation()
|
|
||||||
{
|
|
||||||
Src3proxyDirPath="${ScriptPath}"
|
|
||||||
|
|
||||||
if echo ${ScriptPath} | grep -e "/scripts$"
|
|
||||||
then
|
|
||||||
if [ -e "../src/version.h" ]
|
|
||||||
then
|
|
||||||
ProxyVersion=`cat "../src/version.h" | awk '/VERSION/ { gsub("\"", "\n"); print; exit }' | grep "3proxy"`
|
|
||||||
cd ../
|
|
||||||
SourceRoot="${PWD}"
|
|
||||||
cd ../
|
|
||||||
Src3proxyDirPath="${PWD}"
|
|
||||||
cd "${ScriptPath}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
GetLasestVersionInfo()
|
|
||||||
{
|
|
||||||
local Githublink
|
|
||||||
local msg
|
|
||||||
|
|
||||||
Githublink=`wget https://github.com/3proxy/3proxy/releases/latest -O /dev/stdout |
|
|
||||||
awk '/<a.+href=.+\.tar\.gz/ { gsub("\"", "\n"); print; exit }' |
|
|
||||||
grep -e ".tar.gz"`
|
|
||||||
if [ $? != 0 ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgInternetConnectionError"`
|
|
||||||
echo -e "${msg}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
LasestProxyVersionLink="https://github.com${Githublink}"
|
|
||||||
|
|
||||||
LasestProxyVersion=`basename "${Githublink}" | awk 'gsub(".tar.gz", "") { print "3proxy-" $0 }'`
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckRunConditions()
|
|
||||||
{
|
|
||||||
local UserName
|
|
||||||
local answer
|
|
||||||
local msg
|
|
||||||
local msgContinueWork
|
|
||||||
local msgInsertYorN
|
|
||||||
|
|
||||||
UserName=`whoami`
|
|
||||||
|
|
||||||
if [ $UID != 0 ]
|
|
||||||
then
|
|
||||||
if [ `CheckPacketInstall "sudo"` == 0 ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgSudoNotInstalled"`
|
|
||||||
echo -e "${msg}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
UseSudo=1
|
|
||||||
|
|
||||||
if [ -z `cat /etc/group | grep -e "^sudo" | grep "${UserName}"` ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgUserNotMemberOfSudoGroup"`
|
|
||||||
echo -e "${msg}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ `env | grep -e ^http_proxy` != "" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgSystemUseProxy"`
|
|
||||||
echo -e "${msg}"
|
|
||||||
|
|
||||||
msgContinueWork=`GetResource "msgDoYouWishContinue"`
|
|
||||||
msgInsertYorN=`GetResource "msgPleaseInsertYorN"`
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -s -n1 -p "${msgContinueWork}" answer
|
|
||||||
case $answer in
|
|
||||||
[Yy]* ) echo -ne "\n";break;;
|
|
||||||
[Nn]* ) echo -ne "\n"; sleep 0; exit 0;;
|
|
||||||
* ) echo -e "${msgInsertYorN}";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DonwnloadSource()
|
|
||||||
{
|
|
||||||
if [ ! -e "${Src3proxyDirPath}/${LasestProxyVersion}.tar.gz" ]
|
|
||||||
then
|
|
||||||
wget "${LasestProxyVersionLink}" -O "${Src3proxyDirPath}/${LasestProxyVersion}.tar.gz"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ProxyVersion="${LasestProxyVersion}"
|
|
||||||
}
|
|
||||||
|
|
||||||
UnpackSource()
|
|
||||||
{
|
|
||||||
if [ ! -d "${Src3proxyDirPath}/${LasestProxyVersion}" ]
|
|
||||||
then
|
|
||||||
tar -xvf "${Src3proxyDirPath}/${LasestProxyVersion}.tar.gz" -C "${Src3proxyDirPath}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
SourceRoot="${Src3proxyDirPath}/${LasestProxyVersion}"
|
|
||||||
}
|
|
||||||
|
|
||||||
SourceDownloadOrUpdate()
|
|
||||||
{
|
|
||||||
if [ -z "${ProxyVersion}" ]
|
|
||||||
then
|
|
||||||
NeedSourceUpdate=1
|
|
||||||
else
|
|
||||||
if [ "${ProxyVersion}" != "${LasestProxyVersion}" ]
|
|
||||||
then
|
|
||||||
msgNewVersion=`GetResource "msgNewVersion"`
|
|
||||||
msgInsertYorN=`GetResource "msgPleaseInsertYorN"`
|
|
||||||
|
|
||||||
echo -ne "\a"
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -s -n1 -p "${msgNewVersion}" answer
|
|
||||||
case $answer in
|
|
||||||
[Yy]* ) echo -ne "\n"; NeedSourceUpdate=1; sleep 0; break;;
|
|
||||||
[Nn]* ) echo -ne "\n"; NeedSourceUpdate=0; sleep 0; break;;
|
|
||||||
* ) echo -e "${msgInsertYorN}";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $NeedSourceUpdate == 1 ]
|
|
||||||
then
|
|
||||||
DonwnloadSource
|
|
||||||
UnpackSource
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
Build3Proxy()
|
|
||||||
{
|
|
||||||
local msg
|
|
||||||
|
|
||||||
if [ `CheckPacketInstall "build-essential"` == 0 ]
|
|
||||||
then
|
|
||||||
apt-get -y install build-essential
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ `CheckPacketInstall "build-essential"` == 0 ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgBuildEssentialNotInstalled"`
|
|
||||||
echo -e "${msg}"
|
|
||||||
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
make -f Makefile.Linux
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BinInstall()
|
|
||||||
{
|
|
||||||
local binlist
|
|
||||||
local liblist
|
|
||||||
|
|
||||||
if [! -d bin]
|
|
||||||
then
|
|
||||||
mkdir bin
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd bin
|
|
||||||
|
|
||||||
binlist=`ls -l --time-style="+%d.%m.%Y %H:%m" | awk '$1 ~ /x$/ && $1 ~ /^[^d]/ && $8 !~ /\.so$/ { print $8 }'`
|
|
||||||
|
|
||||||
for file in $binlist
|
|
||||||
do
|
|
||||||
cp -vf "${file}" /usr/bin
|
|
||||||
PacketFiles=`echo -e "${PacketFiles}\n/usr/bin/${file}"`
|
|
||||||
done
|
|
||||||
|
|
||||||
liblist=`ls -l --time-style="+%d.%m.%Y %H:%m" | awk '$1 ~ /x$/ && $1 ~ /^[^d]/ && $8 ~ /\.so$/ { print $8 }'`
|
|
||||||
|
|
||||||
for file in $liblist
|
|
||||||
do
|
|
||||||
cp -vf "${file}" /usr/lib
|
|
||||||
PacketFiles=`echo -e "${PacketFiles}\n/usr/lib/${file}"`
|
|
||||||
done
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
}
|
|
||||||
|
|
||||||
ManInstall()
|
|
||||||
{
|
|
||||||
local man3list
|
|
||||||
local man8list
|
|
||||||
|
|
||||||
cd man
|
|
||||||
|
|
||||||
man3list=`ls -l --time-style="+%d.%m.%Y %H:%m" | awk '$8 ~ /\.3$/ { print $8 }'`
|
|
||||||
gzip -vfk $man3list
|
|
||||||
|
|
||||||
man3list=`echo "${man3list}" | awk '{ print $1 ".gz" }'`
|
|
||||||
|
|
||||||
for file in $man3list
|
|
||||||
do
|
|
||||||
mv -vf "${file}" /usr/share/man/man3
|
|
||||||
PacketFiles="${PacketFiles}\n/usr/share/man/man3/${file}"
|
|
||||||
done
|
|
||||||
|
|
||||||
man8list=`ls -l --time-style="+%d.%m.%Y %H:%m" | awk '$8 ~ /\.8$/ { print $8 }'`
|
|
||||||
|
|
||||||
gzip -vfk $man8list
|
|
||||||
|
|
||||||
man8list=`echo "${man8list}" | awk '{ print $1 ".gz" }'`
|
|
||||||
|
|
||||||
for file in $man8list
|
|
||||||
do
|
|
||||||
mv -vf "${file}" /usr/share/man/man8
|
|
||||||
PacketFiles=`echo -e "${PacketFiles}\n/usr/share/man/man8/${file}"`
|
|
||||||
done
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CreateLogDir()
|
|
||||||
{
|
|
||||||
local LogDir
|
|
||||||
LogDir="/var/log/3proxy"
|
|
||||||
|
|
||||||
if [ ! -d "${LogDir}" ]
|
|
||||||
then
|
|
||||||
mkdir "${LogDir}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
chown nobody:nogroup "${LogDir}"
|
|
||||||
chmod 775 "${LogDir}"
|
|
||||||
PacketFiles="${PacketFiles}\n${LogDir}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CopyConfig()
|
|
||||||
{
|
|
||||||
local ConfigDir
|
|
||||||
ConfigDir="/etc/3proxy"
|
|
||||||
|
|
||||||
if [ ! -d "${ConfigDir}" ]
|
|
||||||
then
|
|
||||||
mkdir "${ConfigDir}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
LoadGlobalResource "ConfigFile" > "${ConfigDir}/3proxy.cfg"
|
|
||||||
|
|
||||||
PacketFiles=`echo -e "${PacketFiles}\n${ConfigDir}/3proxy.cfg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SetInit()
|
|
||||||
{
|
|
||||||
LoadGlobalResource "InitScript" > "/etc/init.d/3proxy"
|
|
||||||
chown root:root "/etc/init.d/3proxy"
|
|
||||||
chmod 755 "/etc/init.d/3proxy"
|
|
||||||
|
|
||||||
PacketFiles=`echo -e "${PacketFiles}\n/etc/init.d/3proxy"`
|
|
||||||
update-rc.d 3proxy defaults
|
|
||||||
}
|
|
||||||
|
|
||||||
Pack3proxyFiles()
|
|
||||||
{
|
|
||||||
local CPU_Arc
|
|
||||||
CPU_Arc=`uname -m`
|
|
||||||
cd ../
|
|
||||||
tar -czPpvf "${ProxyVersion}-${CPU_Arc}.tar.gz" $PacketFiles
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadResources()
|
|
||||||
{
|
|
||||||
local StartRow
|
|
||||||
local EndRow
|
|
||||||
local LngLabel
|
|
||||||
local msgResourceErr="\aError! Script could not find resources!"
|
|
||||||
|
|
||||||
if env | grep -q 'LANG=ru_RU.UTF-8'
|
|
||||||
then
|
|
||||||
LngLabel="RU"
|
|
||||||
#LngLabel="EN"
|
|
||||||
else
|
|
||||||
LngLabel="EN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
StartRow=`cat "${ScriptFullName}" | awk "/^#Resources_${LngLabel}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${StartRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
EndRow=`cat "${ScriptFullName}" | awk "NR > ${StartRow} && /^#Resources_${LngLabel}_end/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${EndRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
ResourcesData=`cat "${ScriptFullName}" | awk -v StartRow="${StartRow}" -v EndRow="${EndRow}" 'NR > StartRow && NR < EndRow { print $0 }'`
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# $1 - Name of Resource
|
|
||||||
GetResource()
|
|
||||||
{
|
|
||||||
local StartRow
|
|
||||||
local EndRow
|
|
||||||
local msgResourceErr="\aError! Script could not find resource \"${1}\"!"
|
|
||||||
|
|
||||||
StartRow=`echo "${ResourcesData}" | awk "/^#Resource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${StartRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
EndRow=`echo "${ResourcesData}" | awk "NR > ${StartRow} && /^#endResource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${EndRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${ResourcesData}" | awk -v StartRow="${StartRow}" -v EndRow="${EndRow}" 'NR > StartRow && NR < EndRow { print $0 }'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# $1 - Name of Resource
|
|
||||||
LoadGlobalResource()
|
|
||||||
{
|
|
||||||
local StartRow
|
|
||||||
local EndRow
|
|
||||||
local LngLabel
|
|
||||||
local msgResourceErr="\aError! Script could not find resource \"${1}\"!"
|
|
||||||
|
|
||||||
|
|
||||||
StartRow=`cat "${ScriptFullName}" | awk "/^#Resource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${StartRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
EndRow=`cat "${ScriptFullName}" | awk "NR > ${StartRow} && /^#endResource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${EndRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat "${ScriptFullName}" | awk -v StartRow="${StartRow}" -v EndRow="${EndRow}" 'NR > StartRow && NR < EndRow { print $0 }'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CheckPacketInstall()
|
|
||||||
{
|
|
||||||
if [ `dpkg -l ${1} 2>&1 | wc -l` -le 1 ]
|
|
||||||
then
|
|
||||||
echo 0
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ `dpkg -l ${1} | grep -e ^un | wc -l` == 1 ]
|
|
||||||
then
|
|
||||||
echo 0
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo 1
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
#Resources_EN
|
|
||||||
|
|
||||||
#Resource=msgSudoNotInstalled
|
|
||||||
\aThe script is running under the account a non-privileged user.
|
|
||||||
"Sudo" package is not installed in the system.
|
|
||||||
The script can not continue, as the execution of operations,
|
|
||||||
requiring rights "root" - is not possible!
|
|
||||||
Please run the script under the account "root",
|
|
||||||
or install and configure "sudo" package!
|
|
||||||
#endResource=msgSudoNotInstalled
|
|
||||||
|
|
||||||
#Resource=msgUserNotMemberOfSudoGroup
|
|
||||||
\aThe script is running under account a non-privileged user.
|
|
||||||
The account of the current user is not included in the "sudo" group!
|
|
||||||
The script can not continue, as the execution of operations,
|
|
||||||
requiring rights "root" - is not possible!
|
|
||||||
Please run the script under the account "root",
|
|
||||||
or configure "sudo" package!
|
|
||||||
#endResource=msgUserNotMemberOfSudoGroup
|
|
||||||
|
|
||||||
#Resource=msgSystemUseProxy
|
|
||||||
\aAttention! The operating system uses proxy-server.
|
|
||||||
For correctly work of package manager "apt"
|
|
||||||
in the file "/etc/sudoers" should be present line:
|
|
||||||
Defaults env_keep = "http_proxy https_proxy"
|
|
||||||
#endResource=msgSystemUseProxy
|
|
||||||
|
|
||||||
#Resource=msgDoYouWishContinue
|
|
||||||
Do you wish to the script continued executing? (y/n):
|
|
||||||
#endResource=msgDoYouWishContinue
|
|
||||||
|
|
||||||
#Resource=msgPleaseInsertYorN
|
|
||||||
\a\nPlease insert "y" or "n"!
|
|
||||||
#endResource=msgPleaseInsertYorN
|
|
||||||
|
|
||||||
#Resource=msgInternetConnectionError
|
|
||||||
\aError downloading "https://github.com/z3APA3A/3proxy/releases/latest"!
|
|
||||||
Please check the settings of the Internet connection.
|
|
||||||
#endResource=msgInternetConnectionError
|
|
||||||
|
|
||||||
#Resource=msgNewVersion
|
|
||||||
The new version of "3proxy" detected, do you want download it?
|
|
||||||
#endResource=msgNewVersion
|
|
||||||
|
|
||||||
#Resource=msgBuildEssentialNotInstalled
|
|
||||||
\aPackage "build-essential" was not installed.
|
|
||||||
The installation can not be continued!
|
|
||||||
#endResource=msgBuildEssentialNotInstalled
|
|
||||||
|
|
||||||
#Resources_EN_end
|
|
||||||
|
|
||||||
#Resources_RU
|
|
||||||
|
|
||||||
#Resource=msgSudoNotInstalled
|
|
||||||
\aСкрипт запущен под учётной записью обычного пользователя.
|
|
||||||
В системе не установлен пакет "sudo".
|
|
||||||
Скрипт не может продолжить работу, так как выполнение операций,
|
|
||||||
требующих прав "root" - не представляется возможным!
|
|
||||||
Пожалуйста, запустите скрипт под учётной записью "root",
|
|
||||||
либо установите и настройте пакет "sudo"!
|
|
||||||
#endResource=msgSudoNotInstalled
|
|
||||||
|
|
||||||
#Resource=msgUserNotMemberOfSudoGroup
|
|
||||||
\aСкрипт запущен под учётной записью обычного пользователя.
|
|
||||||
Учётная запись текущего пользователя не включена в группу "sudo"!
|
|
||||||
Скрипт не может продолжить работу, так как выполнение операций,
|
|
||||||
требующих прав "root" - не представляется возможным!
|
|
||||||
Пожалуйста, запустите скрипт под учётной записью "root",
|
|
||||||
либо настройте пакет "sudo"!
|
|
||||||
#endResource=msgUserNotMemberOfSudoGroup
|
|
||||||
|
|
||||||
#Resource=msgSystemUseProxy
|
|
||||||
\aВнимание! В системе используется прокси-сервер.
|
|
||||||
Чтобы менеджер пакетов "apt" работал корректно,
|
|
||||||
в файле "/etc/sudoers" должна присутствовать строка:
|
|
||||||
Defaults env_keep = "http_proxy https_proxy"
|
|
||||||
#endResource=msgSystemUseProxy
|
|
||||||
|
|
||||||
#Resource=msgDoYouWishContinue
|
|
||||||
Хотите чтобы скрипт дальше продолжил работу? (y/n):
|
|
||||||
#endResource=msgDoYouWishContinue
|
|
||||||
|
|
||||||
#Resource=msgPleaseInsertYorN
|
|
||||||
\a\nПожалуйста введите "y" или "n"!
|
|
||||||
#endResource=msgPleaseInsertYorN
|
|
||||||
|
|
||||||
#Resource=msgInternetConnectionError
|
|
||||||
\aОшибка закачки "https://github.com/z3APA3A/3proxy/releases/latest"!
|
|
||||||
Пожалуйста, проверьте настройки интернет соединения.
|
|
||||||
#endResource=msgInternetConnectionError
|
|
||||||
|
|
||||||
#Resource=msgNewVersion
|
|
||||||
Обнаружена новая версия "3proxy", скачать её (y/n)?
|
|
||||||
#endResource=msgNewVersion
|
|
||||||
|
|
||||||
#Resource=msgBuildEssentialNotInstalled
|
|
||||||
\aПакет "build-essential" не был установлен.
|
|
||||||
Дальнейшая установка не может быть продолжена!
|
|
||||||
#endResource=msgBuildEssentialNotInstalled
|
|
||||||
|
|
||||||
#Resources_RU_end
|
|
||||||
|
|
||||||
|
|
||||||
#Resource=ConfigFile
|
|
||||||
noconfig
|
|
||||||
# If in this file have line "noconfig", then 3proxy not to be runned!
|
|
||||||
# For usung this configuration file 3proxy you must to delete
|
|
||||||
# or comment out the line with "noconfig".
|
|
||||||
|
|
||||||
daemon
|
|
||||||
# Parameter "daemon" - means run 3proxy as daemon
|
|
||||||
|
|
||||||
|
|
||||||
pidfile /tmp/3proxy.pid
|
|
||||||
# PID file location
|
|
||||||
# This parameter must have the same value as
|
|
||||||
# the variable "PidFile" in the script "/etc/init.d/3proxy"
|
|
||||||
|
|
||||||
|
|
||||||
# Configuration file location
|
|
||||||
config /etc/3proxy/3proxy.cfg
|
|
||||||
|
|
||||||
|
|
||||||
internal 127.0.0.1
|
|
||||||
# Internal is address of interface proxy will listen for incoming requests
|
|
||||||
# 127.0.0.1 means only localhost will be able to use this proxy. This is
|
|
||||||
# address you should specify for clients as proxy IP.
|
|
||||||
# You MAY use 0.0.0.0 but you shouldn't, because it's a chance for you to
|
|
||||||
# have open proxy in your network in this case.
|
|
||||||
|
|
||||||
external 192.168.0.1
|
|
||||||
# External is address 3proxy uses for outgoing connections. 0.0.0.0 means any
|
|
||||||
# interface. Using 0.0.0.0 is not good because it allows to connect to 127.0.0.1
|
|
||||||
|
|
||||||
|
|
||||||
# DNS IP addresses
|
|
||||||
nserver 8.8.8.8
|
|
||||||
nserver 8.8.4.4
|
|
||||||
|
|
||||||
|
|
||||||
# DNS cache size
|
|
||||||
nscache 65536
|
|
||||||
|
|
||||||
# Timeouts settings
|
|
||||||
timeouts 1 5 30 60 180 1800 15 60
|
|
||||||
|
|
||||||
|
|
||||||
# log file location
|
|
||||||
log /var/log/3proxy/3proxy.log D
|
|
||||||
|
|
||||||
# log file format
|
|
||||||
logformat "L%C - %U [%d-%o-%Y %H:%M:%S %z] ""%T"" %E %I %O %N/%R:%r"
|
|
||||||
|
|
||||||
archiver gz /usr/bin/gzip %F
|
|
||||||
# If archiver specified log file will be compressed after closing.
|
|
||||||
# you should specify extension, path to archiver and command line, %A will be
|
|
||||||
# substituted with archive file name, %f - with original file name.
|
|
||||||
# Original file will not be removed, so archiver should care about it.
|
|
||||||
|
|
||||||
rotate 30
|
|
||||||
# We will keep last 30 log files
|
|
||||||
|
|
||||||
proxy -p3128
|
|
||||||
# Run http/https proxy on port 3128
|
|
||||||
|
|
||||||
auth none
|
|
||||||
# No authentication is requires
|
|
||||||
|
|
||||||
setgid 65534
|
|
||||||
setuid 65534
|
|
||||||
# Run 3proxy under account "nobody" with group "nobody"
|
|
||||||
#endResource=ConfigFile
|
|
||||||
|
|
||||||
|
|
||||||
#Resource=InitScript
|
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# 3proxy daemon control script
|
|
||||||
#
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: 3proxy
|
|
||||||
# Required-Start: $network $remote_fs $syslog
|
|
||||||
# Required-Stop: $network $remote_fs $syslog
|
|
||||||
# Should-Start: $named
|
|
||||||
# Should-Stop: $named
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: 3proxy HTTP Proxy
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
|
|
||||||
ScriptName="3proxy"
|
|
||||||
ScriptFullName="/etc/init.d/3proxy"
|
|
||||||
|
|
||||||
ConfigFile="/etc/3proxy/3proxy.cfg"
|
|
||||||
LogDir="/var/log/3proxy"
|
|
||||||
PidFile="/tmp/3proxy.pid"
|
|
||||||
|
|
||||||
ResourcesData=""
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
LoadResources
|
|
||||||
|
|
||||||
if [ ! -d "${LogDir}" ]
|
|
||||||
then
|
|
||||||
mkdir -p "${LogDir}";
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start) Start ;;
|
|
||||||
stop) Stop ;;
|
|
||||||
restart) Stop; Start ;;
|
|
||||||
status) Status ;;
|
|
||||||
*) ShowHelp;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
Start()
|
|
||||||
{
|
|
||||||
local msg
|
|
||||||
local ProxyPID
|
|
||||||
|
|
||||||
if [ ! -f "${ConfigFile}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgConfigFileNotFound"`
|
|
||||||
printf "${msg}" "${ConfigFile}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if cat "${ConfigFile}" | grep -qe "^noconfig"
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgNoconfigDetected"`
|
|
||||||
printf "${msg}" "${ConfigFile}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
ProxyPID=`Get3proxyPID`
|
|
||||||
|
|
||||||
if [ ! -z "${ProxyPID}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msg3proxyAlreadyRunning"`
|
|
||||||
printf "${msg}" "${ProxyPID}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
3proxy "${ConfigFile}"
|
|
||||||
sleep 1
|
|
||||||
|
|
||||||
ProxyPID=`Get3proxyPID`
|
|
||||||
|
|
||||||
if [ ! -f "${PidFile}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msg3proxyStartProblems"`
|
|
||||||
printf "${msg}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ `cat "${PidFile}"` != "${ProxyPID}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msg3proxyStartProblems"`
|
|
||||||
printf "${msg}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
msg=`GetResource "msg3proxyStartedSuccessfully"`
|
|
||||||
printf "${msg}" `date +%d-%m-%Y" "%H:%M:%S` "${ProxyPID}"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Stop()
|
|
||||||
{
|
|
||||||
local msg
|
|
||||||
local ProxyPID
|
|
||||||
|
|
||||||
ProxyPID=`Get3proxyPID`
|
|
||||||
|
|
||||||
if [ -f "${PidFile}" ]
|
|
||||||
then
|
|
||||||
if [ `cat "${PidFile}"` = "${ProxyPID}" ]
|
|
||||||
then
|
|
||||||
kill -9 "${ProxyPID}"
|
|
||||||
rm -f "${PidFile}"
|
|
||||||
|
|
||||||
msg=`GetResource "msg3proxyStoppedSuccessfully"`
|
|
||||||
printf "${msg}" `date +%d-%m-%Y" "%H:%M:%S`
|
|
||||||
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${ProxyPID}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msg3proxyProxyNotDetected"`
|
|
||||||
printf "${msg}"
|
|
||||||
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
pkill -o 3proxy
|
|
||||||
|
|
||||||
msg=`GetResource "msg3proxyStoppedByKillall"`
|
|
||||||
printf "${msg}" `date +%d-%m-%Y" "%H:%M:%S` "${PidFile}"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Status()
|
|
||||||
{
|
|
||||||
local msg
|
|
||||||
local ProxyPID
|
|
||||||
|
|
||||||
if [ -f "${PidFile}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgPidFileExists"`
|
|
||||||
printf "${msg}" "${PidFile}" `cat "${PidFile}"`
|
|
||||||
else
|
|
||||||
msg=`GetResource "msgPidFileNotExists"`
|
|
||||||
printf "${msg}" "${PidFile}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ProxyPID=`Get3proxyPID`
|
|
||||||
|
|
||||||
if [ ! -z "${ProxyPID}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msg3proxyProcessDetected"`
|
|
||||||
printf "${msg}"
|
|
||||||
ps -ef | awk '$8 ~ /^3proxy/ { print "User: " $1 "\tPID: " $2 }'
|
|
||||||
else
|
|
||||||
msg=`GetResource "msg3proxyProcessNotDetected"`
|
|
||||||
printf "${msg}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowHelp()
|
|
||||||
{
|
|
||||||
local msg
|
|
||||||
|
|
||||||
msg=`GetResource "msg3proxyHelp"`
|
|
||||||
printf "${msg}" "${ScriptFullName}" "${ScriptName}"
|
|
||||||
}
|
|
||||||
|
|
||||||
Get3proxyPID()
|
|
||||||
{
|
|
||||||
ps -ef | awk '$8 ~ /^3proxy/ { print $2; exit }'
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadResources()
|
|
||||||
{
|
|
||||||
local StartRow
|
|
||||||
local EndRow
|
|
||||||
local LngLabel
|
|
||||||
local msgResourceErr="\aError! Script could not find resources!"
|
|
||||||
|
|
||||||
if env | grep -q 'LANG=ru_RU.UTF-8'
|
|
||||||
then
|
|
||||||
LngLabel="RU"
|
|
||||||
else
|
|
||||||
LngLabel="EN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
StartRow=`cat "${ScriptFullName}" | awk "/^#Resources_${LngLabel}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${StartRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
EndRow=`cat "${ScriptFullName}" | awk "NR > ${StartRow} && /^#Resources_${LngLabel}_end/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${EndRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
ResourcesData=`cat "${ScriptFullName}" | awk -v StartRow="${StartRow}" -v EndRow="${EndRow}" 'NR > StartRow && NR < EndRow { print $0 }'`
|
|
||||||
}
|
|
||||||
|
|
||||||
# $1 - Name of Resource
|
|
||||||
GetResource()
|
|
||||||
{
|
|
||||||
local StartRow
|
|
||||||
local EndRow
|
|
||||||
local msgResourceErr="\aError! Script could not find resource \"${1}\"!"
|
|
||||||
|
|
||||||
StartRow=`echo "${ResourcesData}" | awk "/^#Resource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${StartRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
EndRow=`echo "${ResourcesData}" | awk "NR > ${StartRow} && /^#endResource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${EndRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${ResourcesData}" | awk -v StartRow="${StartRow}" -v EndRow="${EndRow}" 'NR > StartRow && NR < EndRow { print $0 }'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
main $@
|
|
||||||
exit 0;
|
|
||||||
|
|
||||||
#Resources_EN
|
|
||||||
|
|
||||||
#Resource=msg3proxyHelp
|
|
||||||
Usage:
|
|
||||||
\t%s {start|stop|restart}
|
|
||||||
or
|
|
||||||
\tservice %s {start|stop|restart|status}\\n
|
|
||||||
#endResource=msg3proxyHelp
|
|
||||||
|
|
||||||
#Resource=msgConfigFileNotFound
|
|
||||||
\a3proxy configuration file - "%s" is not found!\\n
|
|
||||||
#endResource=msgConfigFileNotFound
|
|
||||||
|
|
||||||
#Resource=msgNoconfigDetected
|
|
||||||
Parameter "noconfig" found in 3proxy configuration file -
|
|
||||||
"% s" !
|
|
||||||
To run 3proxy this parameter should be disabled.\\n
|
|
||||||
#endResource=msgNoconfigDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyAlreadyRunning
|
|
||||||
\a3proxy already running PID: %s\\n
|
|
||||||
#endResource=msg3proxyAlreadyRunning
|
|
||||||
|
|
||||||
#Resource=msg3proxyStartProblems
|
|
||||||
With the start of 3proxy, something is wrong!
|
|
||||||
Use: service 3proxy status\\n
|
|
||||||
#endResource=msg3proxyStartProblems
|
|
||||||
|
|
||||||
#Resource=msg3proxyStartedSuccessfully
|
|
||||||
[ %s %s ] 3proxy started successfully! PID: %s\\n
|
|
||||||
#endResource=msg3proxyStartedSuccessfully
|
|
||||||
|
|
||||||
#Resource=msg3proxyStoppedSuccessfully
|
|
||||||
[ %s %s ] 3proxy stopped successfully!\\n
|
|
||||||
#endResource=msg3proxyStoppedSuccessfully
|
|
||||||
|
|
||||||
#Resource=msg3proxyProxyNotDetected
|
|
||||||
Process "3proxy" is not detected!\\n
|
|
||||||
#endResource=msg3proxyProxyNotDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyStoppedByKillall
|
|
||||||
[ %s %s ] Command "pkill -o 3proxy" was executed,
|
|
||||||
because process number was not stored in "%s",
|
|
||||||
but in fact 3proxy was runned!\\n
|
|
||||||
#endResource=msg3proxyStoppedByKillall
|
|
||||||
|
|
||||||
#Resource=msgPidFileExists
|
|
||||||
File "%s" exists. It contains the PID: %s\\n
|
|
||||||
#endResource=msgPidFileExists
|
|
||||||
|
|
||||||
#Resource=msgPidFileNotExists
|
|
||||||
File "%s" not found, that is, PID 3proxy was not stored!\\n
|
|
||||||
#endResource=msgPidFileNotExists
|
|
||||||
|
|
||||||
#Resource=msg3proxyProcessDetected
|
|
||||||
Process 3proxy detected:\\n
|
|
||||||
#endResource=msg3proxyProcessDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyProcessNotDetected
|
|
||||||
Processes of 3proxy is not found!\\n
|
|
||||||
#endResource=msg3proxyProcessNotDetected
|
|
||||||
|
|
||||||
#Resources_EN_end
|
|
||||||
|
|
||||||
|
|
||||||
#Resources_RU
|
|
||||||
|
|
||||||
#Resource=msg3proxyHelp
|
|
||||||
Используйте:
|
|
||||||
\t%s {start|stop|restart}
|
|
||||||
или
|
|
||||||
\tservice %s {start|stop|restart|status}\\n
|
|
||||||
#endResource=msg3proxyHelp
|
|
||||||
|
|
||||||
#Resource=msgConfigFileNotFound
|
|
||||||
\aФайл конфигурации 3proxy - "%s", не найден!\\n
|
|
||||||
#endResource=msgConfigFileNotFound
|
|
||||||
|
|
||||||
#Resource=msgNoconfigDetected
|
|
||||||
\aОбнаружен параметр "noconfig" в файле конфигурации 3proxy -
|
|
||||||
"%s" !
|
|
||||||
Для запуска 3proxy этот параметр нужно отключить.\\n
|
|
||||||
#endResource=msgNoconfigDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyAlreadyRunning
|
|
||||||
\a3proxy уже запущен PID: %s\\n
|
|
||||||
#endResource=msg3proxyAlreadyRunning
|
|
||||||
|
|
||||||
#Resource=msg3proxyStartProblems
|
|
||||||
\aСо стартом 3proxy, что-то не так!
|
|
||||||
Используйте: service 3proxy status\\n
|
|
||||||
#endResource=msg3proxyStartProblems
|
|
||||||
|
|
||||||
#Resource=msg3proxyStartedSuccessfully
|
|
||||||
[ %s %s ] 3proxy успешно стартовал! PID: %s\\n
|
|
||||||
#endResource=msg3proxyStartedSuccessfully
|
|
||||||
|
|
||||||
#Resource=msg3proxyStoppedSuccessfully
|
|
||||||
[ %s %s ] 3proxy успешно остановлен!\\n
|
|
||||||
#endResource=msg3proxyStoppedSuccessfully
|
|
||||||
|
|
||||||
#Resource=msg3proxyProxyNotDetected
|
|
||||||
Процесс "3proxy" не обнаружен!\\n
|
|
||||||
#endResource=msg3proxyProxyNotDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyStoppedByKillall
|
|
||||||
[ %s %s ] Выполнена команда "pkill -o 3proxy",
|
|
||||||
т.к. номер процесса не записан в "%s",
|
|
||||||
но по факту 3proxy рабатал!\\n
|
|
||||||
#endResource=msg3proxyStoppedByKillall
|
|
||||||
|
|
||||||
#Resource=msgPidFileExists
|
|
||||||
Файл "%s" есть. Он содержит PID: %s\\n
|
|
||||||
#endResource=msgPidFileExists
|
|
||||||
|
|
||||||
#Resource=msgPidFileNotExists
|
|
||||||
Файл "%s" не найден, т.е. PID 3proxy не был сохранён!\\n
|
|
||||||
#endResource=msgPidFileNotExists
|
|
||||||
|
|
||||||
#Resource=msg3proxyProcessDetected
|
|
||||||
Обнаружен процесс 3proxy:\\n
|
|
||||||
#endResource=msg3proxyProcessDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyProcessNotDetected
|
|
||||||
Процессов 3proxy не обнаружено!\\n
|
|
||||||
#endResource=msg3proxyProcessNotDetected
|
|
||||||
|
|
||||||
#Resources_RU_end
|
|
||||||
#endResource=InitScript
|
|
||||||
@ -1,25 +1,2 @@
|
|||||||
nscache 65536
|
#!/usr/local/bin/3proxy
|
||||||
nserver 8.8.8.8
|
#path to plugins:
|
||||||
nserver 8.8.4.4
|
|
||||||
|
|
||||||
config /conf/3proxy.cfg
|
|
||||||
monitor /conf/3proxy.cfg
|
|
||||||
|
|
||||||
log /logs/3proxy-%y%m%d.log D
|
|
||||||
rotate 60
|
|
||||||
counter /count/3proxy.3cf
|
|
||||||
|
|
||||||
users $/conf/passwd
|
|
||||||
|
|
||||||
include /conf/counters
|
|
||||||
include /conf/bandlimiters
|
|
||||||
|
|
||||||
auth strong
|
|
||||||
deny * * 127.0.0.1
|
|
||||||
allow *
|
|
||||||
proxy -n
|
|
||||||
socks
|
|
||||||
flush
|
|
||||||
allow admin
|
|
||||||
|
|
||||||
admin -p8080
|
|
||||||
25
scripts/3proxy.cfg.inchroot
Normal file
25
scripts/3proxy.cfg.inchroot
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
nscache 65536
|
||||||
|
nserver 8.8.8.8
|
||||||
|
nserver 8.8.4.4
|
||||||
|
|
||||||
|
config /conf/3proxy.cfg
|
||||||
|
monitor /conf/3proxy.cfg
|
||||||
|
|
||||||
|
log /logs/3proxy-%y%m%d.log D
|
||||||
|
rotate 60
|
||||||
|
counter /count/3proxy.3cf
|
||||||
|
|
||||||
|
users $/conf/passwd
|
||||||
|
|
||||||
|
include /conf/counters
|
||||||
|
include /conf/bandlimiters
|
||||||
|
|
||||||
|
auth strong
|
||||||
|
deny * * 127.0.0.1
|
||||||
|
allow *
|
||||||
|
proxy -n
|
||||||
|
socks
|
||||||
|
flush
|
||||||
|
allow admin
|
||||||
|
|
||||||
|
admin -p8080
|
||||||
19
scripts/3proxy.service.in
Normal file
19
scripts/3proxy.service.in
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=3proxy tiny proxy server
|
||||||
|
Documentation=man:3proxy(1)
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=CONFIGFILE=/etc/3proxy/3proxy.cfg
|
||||||
|
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/3proxy ${CONFIGFILE}
|
||||||
|
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||||
|
KillMode=process
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=60s
|
||||||
|
LimitNOFILE=65536
|
||||||
|
LimitNPROC=32768
|
||||||
|
RuntimeDirectory=3proxy
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
Alias=3proxy.service
|
||||||
3
scripts/3proxy.tmpfiles.in
Normal file
3
scripts/3proxy.tmpfiles.in
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# tmpfiles.d configuration for 3proxy
|
||||||
|
# This creates the runtime directory for 3proxy
|
||||||
|
d /run/3proxy 0755 root root -
|
||||||
@ -1,22 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
cd ..
|
|
||||||
cp Makefile.unix Makefile
|
|
||||||
make
|
|
||||||
if [ ! -d /usr/local/etc/3proxy/bin ]; then mkdir -p /usr/local/etc/3proxy/bin/; fi
|
|
||||||
install bin/3proxy /usr/local/bin/3proxy
|
|
||||||
install bin/mycrypt /usr/local/bin/mycrypt
|
|
||||||
install scripts/rc.d/proxy.sh /usr/local/etc/rc.d/proxy.sh
|
|
||||||
install scripts/add3proxyuser.sh /usr/local/etc/3proxy/bin/
|
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then
|
|
||||||
echo /usr/local/etc/3proxy/3proxy.cfg already exists
|
|
||||||
else
|
|
||||||
install scripts/3proxy.cfg /usr/local/etc/3proxy/
|
|
||||||
if [ ! -d /var/log/3proxy/ ]; then
|
|
||||||
mkdir /var/log/3proxy/
|
|
||||||
fi
|
|
||||||
touch /usr/local/etc/3proxy/passwd
|
|
||||||
touch /usr/local/etc/3proxy/counters
|
|
||||||
touch /usr/local/etc/3proxy/bandlimiters
|
|
||||||
echo Run /usr/local/etc/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
|
||||||
fi
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user