mirror of
https://github.com/teddysun/across.git
synced 2025-09-19 04:54:25 +08:00
Compare commits
3 Commits
master
...
6ba63a9f59
Author | SHA1 | Date | |
---|---|---|---|
|
6ba63a9f59 | ||
|
e76ceea346 | ||
|
6d95140d11 |
345
InstallNET.sh
345
InstallNET.sh
@@ -150,37 +150,39 @@ while [[ $# -ge 1 ]]; do
|
|||||||
*)
|
*)
|
||||||
if [[ "$1" != 'error' ]]; then echo -ne "\nInvaild option: '$1'\n\n"; fi
|
if [[ "$1" != 'error' ]]; then echo -ne "\nInvaild option: '$1'\n\n"; fi
|
||||||
echo -ne " Usage:\n\tbash $(basename $0)\t-d/--debian [\033[33m\033[04mdists-name\033[0m]\n\t\t\t\t-u/--ubuntu [\033[04mdists-name\033[0m]\n\t\t\t\t-c/--centos [\033[04mdists-name\033[0m]\n\t\t\t\t-v/--ver [32/i386|64/\033[33m\033[04mamd64\033[0m] [\033[33m\033[04mdists-verison\033[0m]\n\t\t\t\t--ip-addr/--ip-gate/--ip-mask\n\t\t\t\t-apt/-yum/--mirror\n\t\t\t\t-dd/--image\n\t\t\t\t-p [linux password]\n\t\t\t\t-port [linux ssh port]\n"
|
echo -ne " Usage:\n\tbash $(basename $0)\t-d/--debian [\033[33m\033[04mdists-name\033[0m]\n\t\t\t\t-u/--ubuntu [\033[04mdists-name\033[0m]\n\t\t\t\t-c/--centos [\033[04mdists-name\033[0m]\n\t\t\t\t-v/--ver [32/i386|64/\033[33m\033[04mamd64\033[0m] [\033[33m\033[04mdists-verison\033[0m]\n\t\t\t\t--ip-addr/--ip-gate/--ip-mask\n\t\t\t\t-apt/-yum/--mirror\n\t\t\t\t-dd/--image\n\t\t\t\t-p [linux password]\n\t\t\t\t-port [linux ssh port]\n"
|
||||||
exit 1
|
exit 1;
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ "$EUID" -ne '0' ]] && echo "Error:This script must be run as root!" && exit 1
|
[[ "$EUID" -ne '0' ]] && echo "Error:This script must be run as root!" && exit 1;
|
||||||
|
|
||||||
function dependence(){
|
function dependence(){
|
||||||
Full='0'
|
Full='0';
|
||||||
for BIN_DEP in $(echo "$1" | sed 's/,/\n/g'); do
|
for BIN_DEP in `echo "$1" |sed 's/,/\n/g'`
|
||||||
|
do
|
||||||
if [[ -n "$BIN_DEP" ]]; then
|
if [[ -n "$BIN_DEP" ]]; then
|
||||||
Found='0'
|
Found='0';
|
||||||
for BIN_PATH in $(echo "$PATH" | sed 's/:/\n/g'); do
|
for BIN_PATH in `echo "$PATH" |sed 's/:/\n/g'`
|
||||||
ls $BIN_PATH/$BIN_DEP >/dev/null 2>&1
|
do
|
||||||
|
ls $BIN_PATH/$BIN_DEP >/dev/null 2>&1;
|
||||||
if [ $? == '0' ]; then
|
if [ $? == '0' ]; then
|
||||||
Found='1'
|
Found='1';
|
||||||
break
|
break;
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ "$Found" == '1' ]; then
|
if [ "$Found" == '1' ]; then
|
||||||
echo -en "[\033[32mok\033[0m]\t"
|
echo -en "[\033[32mok\033[0m]\t";
|
||||||
else
|
else
|
||||||
Full='1'
|
Full='1';
|
||||||
echo -en "[\033[31mNot Install\033[0m]"
|
echo -en "[\033[31mNot Install\033[0m]";
|
||||||
fi
|
fi
|
||||||
echo -en "\t$BIN_DEP\n"
|
echo -en "\t$BIN_DEP\n";
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ "$Full" == '1' ]; then
|
if [ "$Full" == '1' ]; then
|
||||||
echo -ne "\n\033[31mError! \033[0mPlease use '\033[33mapt-get\033[0m' or '\033[33myum\033[0m' install it.\n\n\n"
|
echo -ne "\n\033[31mError! \033[0mPlease use '\033[33mapt-get\033[0m' or '\033[33myum\033[0m' install it.\n\n\n"
|
||||||
exit 1
|
exit 1;
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,35 +204,37 @@ function selectMirror() {
|
|||||||
declare -A MirrorBackup
|
declare -A MirrorBackup
|
||||||
MirrorBackup=(["debian0"]="" ["debian1"]="http://deb.debian.org/debian" ["debian2"]="http://archive.debian.org/debian" ["ubuntu0"]="" ["ubuntu1"]="http://archive.ubuntu.com/ubuntu" ["ubuntu2"]="http://ports.ubuntu.com" ["centos0"]="" ["centos1"]="http://mirror.centos.org/centos" ["centos2"]="http://vault.centos.org")
|
MirrorBackup=(["debian0"]="" ["debian1"]="http://deb.debian.org/debian" ["debian2"]="http://archive.debian.org/debian" ["ubuntu0"]="" ["ubuntu1"]="http://archive.ubuntu.com/ubuntu" ["ubuntu2"]="http://ports.ubuntu.com" ["centos0"]="" ["centos1"]="http://mirror.centos.org/centos" ["centos2"]="http://vault.centos.org")
|
||||||
echo "$New" |grep -q '^http://\|^https://\|^ftp://' && MirrorBackup[${Relese}0]="$New"
|
echo "$New" |grep -q '^http://\|^https://\|^ftp://' && MirrorBackup[${Relese}0]="$New"
|
||||||
for mirror in $(echo "${!MirrorBackup[@]}" | sed 's/\ /\n/g' | sort -n | grep "^$Relese"); do
|
for mirror in $(echo "${!MirrorBackup[@]}" |sed 's/\ /\n/g' |sort -n |grep "^$Relese")
|
||||||
|
do
|
||||||
Current="${MirrorBackup[$mirror]}"
|
Current="${MirrorBackup[$mirror]}"
|
||||||
[ -n "$Current" ] || continue
|
[ -n "$Current" ] || continue
|
||||||
MirrorURL=$(echo "$TEMP" | sed "s#SUB_MIRROR#${Current}#g")
|
MirrorURL=`echo "$TEMP" |sed "s#SUB_MIRROR#${Current}#g"`
|
||||||
wget --no-check-certificate --spider --timeout=3 -o /dev/null "$MirrorURL"
|
wget --no-check-certificate --spider --timeout=3 -o /dev/null "$MirrorURL"
|
||||||
[ $? -eq 0 ] && mirrorStatus=1 && break
|
[ $? -eq 0 ] && mirrorStatus=1 && break
|
||||||
done
|
done
|
||||||
[ ${mirrorStatus} -eq 1 ] && echo "$Current" || exit 1
|
[ $mirrorStatus -eq 1 ] && echo "$Current" || exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function netmask() {
|
function netmask() {
|
||||||
n="${1:-32}"
|
n="${1:-32}"
|
||||||
b=""
|
b=""
|
||||||
m=""
|
m=""
|
||||||
for ((i = 0; i < 32; i++)); do
|
for((i=0;i<32;i++)){
|
||||||
[ $i -lt $n ] && b="${b}1" || b="${b}0"
|
[ $i -lt $n ] && b="${b}1" || b="${b}0"
|
||||||
done
|
}
|
||||||
for ((i = 0; i < 4; i++)); do
|
for((i=0;i<4;i++)){
|
||||||
s=$(echo "$b" | cut -c$(($(($i * 8)) + 1))-$(($(($i + 1)) * 8)))
|
s=`echo "$b"|cut -c$[$[$i*8]+1]-$[$[$i+1]*8]`
|
||||||
[ "$m" == "" ] && m="$((2#${s}))" || m="${m}.$((2#${s}))"
|
[ "$m" == "" ] && m="$((2#${s}))" || m="${m}.$((2#${s}))"
|
||||||
done
|
}
|
||||||
echo "$m"
|
echo "$m"
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInterface(){
|
function getInterface(){
|
||||||
interface=""
|
interface=""
|
||||||
Interfaces=$(cat /proc/net/dev | grep ':' | cut -d':' -f1 | sed 's/\s//g' | grep -iv '^lo\|^sit\|^stf\|^gif\|^dummy\|^vmnet\|^vir\|^gre\|^ipip\|^ppp\|^bond\|^tun\|^tap\|^ip6gre\|^ip6tnl\|^teql\|^ocserv\|^vpn')
|
Interfaces=`cat /proc/net/dev |grep ':' |cut -d':' -f1 |sed 's/\s//g' |grep -iv '^lo\|^sit\|^stf\|^gif\|^dummy\|^vmnet\|^vir\|^gre\|^ipip\|^ppp\|^bond\|^tun\|^tap\|^ip6gre\|^ip6tnl\|^teql\|^ocserv\|^vpn'`
|
||||||
defaultRoute=$(ip route show default | grep "^default")
|
defaultRoute=`ip route show default |grep "^default"`
|
||||||
for item in $(echo "$Interfaces"); do
|
for item in `echo "$Interfaces"`
|
||||||
|
do
|
||||||
[ -n "$item" ] || continue
|
[ -n "$item" ] || continue
|
||||||
echo "$defaultRoute" |grep -q "$item"
|
echo "$defaultRoute" |grep -q "$item"
|
||||||
[ $? -eq 0 ] && interface="$item" && break
|
[ $? -eq 0 ] && interface="$item" && break
|
||||||
@@ -239,27 +243,27 @@ function getInterface() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDisk(){
|
function getDisk(){
|
||||||
disks=$(lsblk | sed 's/[[:space:]]*$//g' | grep "disk$" | cut -d' ' -f1 | grep -v "fd[0-9]*\|sr[0-9]*" | head -n1)
|
disks=`lsblk | sed 's/[[:space:]]*$//g' |grep "disk$" |cut -d' ' -f1 |grep -v "fd[0-9]*\|sr[0-9]*" |head -n1`
|
||||||
[ -n "$disks" ] || echo ""
|
[ -n "$disks" ] || echo ""
|
||||||
echo "$disks" |grep -q "/dev"
|
echo "$disks" |grep -q "/dev"
|
||||||
[ $? -eq 0 ] && echo "$disks" || echo "/dev/$disks"
|
[ $? -eq 0 ] && echo "$disks" || echo "/dev/$disks"
|
||||||
}
|
}
|
||||||
|
|
||||||
function diskType(){
|
function diskType(){
|
||||||
echo $(udevadm info --query all "$1" 2>/dev/null | grep 'ID_PART_TABLE_TYPE' | cut -d'=' -f2)
|
echo `udevadm info --query all "$1" 2>/dev/null |grep 'ID_PART_TABLE_TYPE' |cut -d'=' -f2`
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGrub(){
|
function getGrub(){
|
||||||
Boot="${1:-/boot}"
|
Boot="${1:-/boot}"
|
||||||
folder=$(find "$Boot" -type d -name "grub*" 2>/dev/null | sort | tail -n1)
|
folder=`find "$Boot" -type d -name "grub*" 2>/dev/null | sort | tail -n1`
|
||||||
[ -n "$folder" ] || return
|
[ -n "$folder" ] || return
|
||||||
fileName=$(ls -1 "$folder" 2>/dev/null | grep '^grub.conf$\|^grub.cfg$')
|
fileName=`ls -1 "$folder" 2>/dev/null |grep '^grub.conf$\|^grub.cfg$'`
|
||||||
if [ -z "$fileName" ]; then
|
if [ -z "$fileName" ]; then
|
||||||
ls -1 "$folder" 2>/dev/null |grep -q '^grubenv$'
|
ls -1 "$folder" 2>/dev/null |grep -q '^grubenv$'
|
||||||
[ $? -eq 0 ] || return
|
[ $? -eq 0 ] || return
|
||||||
folder=$(find "$Boot" -type f -name "grubenv" 2>/dev/null | xargs dirname | grep -v "^$folder" | head -n1)
|
folder=`find "$Boot" -type f -name "grubenv" 2>/dev/null |xargs dirname |grep -v "^$folder" |head -n1`
|
||||||
[ -n "$folder" ] || return
|
[ -n "$folder" ] || return
|
||||||
fileName=$(ls -1 "$folder" 2>/dev/null | grep '^grub.conf$\|^grub.cfg$')
|
fileName=`ls -1 "$folder" 2>/dev/null |grep '^grub.conf$\|^grub.cfg$'`
|
||||||
fi
|
fi
|
||||||
[ -n "$fileName" ] || return
|
[ -n "$fileName" ] || return
|
||||||
[ "$fileName" == "grub.cfg" ] && ver="0" || ver="1"
|
[ "$fileName" == "grub.cfg" ] && ver="0" || ver="1"
|
||||||
@@ -267,17 +271,17 @@ function getGrub() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function lowMem(){
|
function lowMem(){
|
||||||
mem=$(grep "^MemTotal:" /proc/meminfo 2>/dev/null | grep -o "[0-9]*")
|
mem=`grep "^MemTotal:" /proc/meminfo 2>/dev/null |grep -o "[0-9]*"`
|
||||||
[ -n "$mem" ] || return 0
|
[ -n "$mem" ] || return 0
|
||||||
[ "$mem" -le "524288" ] && return 1 || return 0
|
[ "$mem" -le "524288" ] && return 1 || return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$loaderMode" == "0" ]]; then
|
if [[ "$loaderMode" == "0" ]]; then
|
||||||
Grub=$(getGrub "/boot")
|
Grub=`getGrub "/boot"`
|
||||||
[ -z "$Grub" ] && echo -ne "Error! Not Found grub.\n" && exit 1
|
[ -z "$Grub" ] && echo -ne "Error! Not Found grub.\n" && exit 1;
|
||||||
GRUBDIR=$(echo "$Grub" | cut -d':' -f1)
|
GRUBDIR=`echo "$Grub" |cut -d':' -f1`
|
||||||
GRUBFILE=$(echo "$Grub" | cut -d':' -f2)
|
GRUBFILE=`echo "$Grub" |cut -d':' -f2`
|
||||||
GRUBVER=$(echo "$Grub" | cut -d':' -f3)
|
GRUBVER=`echo "$Grub" |cut -d':' -f3`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "$Relese" ] || Relese='Debian'
|
[ -n "$Relese" ] || Relese='Debian'
|
||||||
@@ -285,95 +289,92 @@ linux_relese=$(echo "$Relese" | sed 's/\ //g' | sed -r 's/(.*)/\L\1/')
|
|||||||
clear && echo -e "\n\033[36m# Check Dependence\033[0m\n"
|
clear && echo -e "\n\033[36m# Check Dependence\033[0m\n"
|
||||||
|
|
||||||
if [[ "$ddMode" == '1' ]]; then
|
if [[ "$ddMode" == '1' ]]; then
|
||||||
dependence iconv
|
dependence iconv;
|
||||||
linux_relese='debian'
|
linux_relese='debian';
|
||||||
tmpDIST='bookworm'
|
tmpDIST='bullseye';
|
||||||
tmpVER='amd64'
|
tmpVER='amd64';
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "$ipAddr" ] && [ -n "$ipMask" ] && [ -n "$ipGate" ] && setNet='1'
|
[ -n "$ipAddr" ] && [ -n "$ipMask" ] && [ -n "$ipGate" ] && setNet='1';
|
||||||
if [ "$setNet" == "0" ]; then
|
if [ "$setNet" == "0" ]; then
|
||||||
dependence ip
|
dependence ip
|
||||||
[ -n "$interface" ] || interface=$(getInterface)
|
[ -n "$interface" ] || interface=`getInterface`
|
||||||
iAddr=$(ip addr show dev $interface | grep "inet.*" | head -n1 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\/[0-9]\{1,2\}')
|
iAddr=`ip addr show dev $interface |grep "inet.*" |head -n1 |grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\/[0-9]\{1,2\}'`
|
||||||
ipAddr=$(echo ${iAddr} | cut -d'/' -f1)
|
ipAddr=`echo ${iAddr} |cut -d'/' -f1`
|
||||||
ipMask=$(netmask $(echo ${iAddr} | cut -d'/' -f2))
|
ipMask=`netmask $(echo ${iAddr} |cut -d'/' -f2)`
|
||||||
ipGate=$(ip route show default | grep "^default" | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | head -n1)
|
ipGate=`ip route show default |grep "^default" |grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' |head -n1`
|
||||||
fi
|
fi
|
||||||
if [ -z "$interface" ]; then
|
if [ -z "$interface" ]; then
|
||||||
dependence ip
|
dependence ip
|
||||||
[ -n "$interface" ] || interface=$(getInterface)
|
[ -n "$interface" ] || interface=`getInterface`
|
||||||
fi
|
fi
|
||||||
IPv4="$ipAddr"
|
IPv4="$ipAddr"; MASK="$ipMask"; GATE="$ipGate";
|
||||||
MASK="$ipMask"
|
|
||||||
GATE="$ipGate"
|
|
||||||
|
|
||||||
[ -n "$IPv4" ] && [ -n "$MASK" ] && [ -n "$GATE" ] && [ -n "$ipDNS" ] || {
|
[ -n "$IPv4" ] && [ -n "$MASK" ] && [ -n "$GATE" ] && [ -n "$ipDNS" ] || {
|
||||||
echo -ne '\nError: Invalid network config\n\n'
|
echo -ne '\nError: Invalid network config\n\n'
|
||||||
bash $0 error
|
bash $0 error;
|
||||||
exit 1
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$Relese" == 'Debian' ]] || [[ "$Relese" == 'Ubuntu' ]]; then
|
if [[ "$Relese" == 'Debian' ]] || [[ "$Relese" == 'Ubuntu' ]]; then
|
||||||
dependence wget,awk,grep,sed,cut,cat,lsblk,cpio,gzip,find,dirname,basename
|
dependence wget,awk,grep,sed,cut,cat,lsblk,cpio,gzip,find,dirname,basename;
|
||||||
elif [[ "$Relese" == 'CentOS' ]]; then
|
elif [[ "$Relese" == 'CentOS' ]]; then
|
||||||
dependence wget,awk,grep,sed,cut,cat,lsblk,cpio,gzip,find,dirname,basename,file,xz
|
dependence wget,awk,grep,sed,cut,cat,lsblk,cpio,gzip,find,dirname,basename,file,xz;
|
||||||
fi
|
fi
|
||||||
[[ -n "$tmpWORD" ]] && dependence openssl
|
[ -n "$tmpWORD" ] && dependence openssl
|
||||||
[[ -n "$tmpWORD" ]] && myPASSWORD="$(openssl passwd -1 "$tmpWORD")"
|
[[ -n "$tmpWORD" ]] && myPASSWORD="$(openssl passwd -1 "$tmpWORD")";
|
||||||
[[ -z "$myPASSWORD" ]] && myPASSWORD='$1$4BJZaD0A$y1QykUnJ6mXprENfwpseH0'
|
[[ -z "$myPASSWORD" ]] && myPASSWORD='$1$4BJZaD0A$y1QykUnJ6mXprENfwpseH0';
|
||||||
|
|
||||||
tempDisk=$(getDisk)
|
tempDisk=`getDisk`; [ -n "$tempDisk" ] && IncDisk="$tempDisk"
|
||||||
[ -n "$tempDisk" ] && IncDisk="$tempDisk"
|
|
||||||
|
|
||||||
case $(uname -m) in aarch64 | arm64) VER="arm64" ;; x86 | i386 | i686) VER="i386" ;; x86_64 | amd64) VER="amd64" ;; *) VER="" ;; esac
|
case `uname -m` in aarch64|arm64) VER="arm64";; x86|i386|i686) VER="i386";; x86_64|amd64) VER="amd64";; *) VER="";; esac
|
||||||
tmpVER="$(echo "$tmpVER" | sed -r 's/(.*)/\L\1/')"
|
tmpVER="$(echo "$tmpVER" |sed -r 's/(.*)/\L\1/')";
|
||||||
if [[ "$VER" != "arm64" ]] && [[ -n "$tmpVER" ]]; then
|
if [[ "$VER" != "arm64" ]] && [[ -n "$tmpVER" ]]; then
|
||||||
case "$tmpVER" in i386|i686|x86|32) VER="i386";; amd64|x86_64|x64|64) [[ "$Relese" == 'CentOS' ]] && VER='x86_64' || VER='amd64';; *) VER='';; esac
|
case "$tmpVER" in i386|i686|x86|32) VER="i386";; amd64|x86_64|x64|64) [[ "$Relese" == 'CentOS' ]] && VER='x86_64' || VER='amd64';; *) VER='';; esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -n "$VER" ]]; then
|
if [[ ! -n "$VER" ]]; then
|
||||||
echo "Error! Not Architecture."
|
echo "Error! Not Architecture."
|
||||||
bash $0 error
|
bash $0 error;
|
||||||
exit 1
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$tmpDIST" ]]; then
|
if [[ -z "$tmpDIST" ]]; then
|
||||||
[ "$Relese" == 'Debian' ] && tmpDIST='buster'
|
[ "$Relese" == 'Debian' ] && tmpDIST='buster';
|
||||||
[ "$Relese" == 'Ubuntu' ] && tmpDIST='bionic'
|
[ "$Relese" == 'Ubuntu' ] && tmpDIST='bionic';
|
||||||
[ "$Relese" == 'CentOS' ] && tmpDIST='6.10'
|
[ "$Relese" == 'CentOS' ] && tmpDIST='6.10';
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$tmpDIST" ]]; then
|
if [[ -n "$tmpDIST" ]]; then
|
||||||
if [[ "$Relese" == 'Debian' ]]; then
|
if [[ "$Relese" == 'Debian' ]]; then
|
||||||
SpikCheckDIST='0'
|
SpikCheckDIST='0'
|
||||||
DIST="$(echo "$tmpDIST" | sed -r 's/(.*)/\L\1/')"
|
DIST="$(echo "$tmpDIST" |sed -r 's/(.*)/\L\1/')";
|
||||||
echo "$DIST" | grep -q '[0-9]'
|
echo "$DIST" |grep -q '[0-9]';
|
||||||
[[ $? -eq '0' ]] && {
|
[[ $? -eq '0' ]] && {
|
||||||
isDigital="$(echo "$DIST" | grep -o '[\.0-9]\{1,\}' | sed -n '1h;1!H;$g;s/\n//g;$p' | cut -d'.' -f1)"
|
isDigital="$(echo "$DIST" |grep -o '[\.0-9]\{1,\}' |sed -n '1h;1!H;$g;s/\n//g;$p' |cut -d'.' -f1)";
|
||||||
[[ -n $isDigital ]] && {
|
[[ -n $isDigital ]] && {
|
||||||
[[ "$isDigital" == '7' ]] && DIST='wheezy'
|
[[ "$isDigital" == '7' ]] && DIST='wheezy';
|
||||||
[[ "$isDigital" == '8' ]] && DIST='jessie'
|
[[ "$isDigital" == '8' ]] && DIST='jessie';
|
||||||
[[ "$isDigital" == '9' ]] && DIST='stretch'
|
[[ "$isDigital" == '9' ]] && DIST='stretch';
|
||||||
[[ "$isDigital" == '10' ]] && DIST='buster'
|
[[ "$isDigital" == '10' ]] && DIST='buster';
|
||||||
[[ "$isDigital" == '11' ]] && DIST='bullseye'
|
[[ "$isDigital" == '11' ]] && DIST='bullseye';
|
||||||
[[ "$isDigital" == '12' ]] && DIST='bookworm'
|
[[ "$isDigital" == '12' ]] && DIST='bookworm';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LinuxMirror=$(selectMirror "$Relese" "$DIST" "$VER" "$tmpMirror")
|
LinuxMirror=$(selectMirror "$Relese" "$DIST" "$VER" "$tmpMirror")
|
||||||
fi
|
fi
|
||||||
if [[ "$Relese" == 'Ubuntu' ]]; then
|
if [[ "$Relese" == 'Ubuntu' ]]; then
|
||||||
SpikCheckDIST='0'
|
SpikCheckDIST='0'
|
||||||
DIST="$(echo "$tmpDIST" | sed -r 's/(.*)/\L\1/')"
|
DIST="$(echo "$tmpDIST" |sed -r 's/(.*)/\L\1/')";
|
||||||
echo "$DIST" | grep -q '[0-9]'
|
echo "$DIST" |grep -q '[0-9]';
|
||||||
[[ $? -eq '0' ]] && {
|
[[ $? -eq '0' ]] && {
|
||||||
isDigital="$(echo "$DIST" | grep -o '[\.0-9]\{1,\}' | sed -n '1h;1!H;$g;s/\n//g;$p')"
|
isDigital="$(echo "$DIST" |grep -o '[\.0-9]\{1,\}' |sed -n '1h;1!H;$g;s/\n//g;$p')";
|
||||||
[[ -n $isDigital ]] && {
|
[[ -n $isDigital ]] && {
|
||||||
[[ "$isDigital" == '12.04' ]] && DIST='precise'
|
[[ "$isDigital" == '12.04' ]] && DIST='precise';
|
||||||
[[ "$isDigital" == '14.04' ]] && DIST='trusty'
|
[[ "$isDigital" == '14.04' ]] && DIST='trusty';
|
||||||
[[ "$isDigital" == '16.04' ]] && DIST='xenial'
|
[[ "$isDigital" == '16.04' ]] && DIST='xenial';
|
||||||
[[ "$isDigital" == '18.04' ]] && DIST='bionic'
|
[[ "$isDigital" == '18.04' ]] && DIST='bionic';
|
||||||
[[ "$isDigital" == '20.04' ]] && DIST='focal'
|
[[ "$isDigital" == '20.04' ]] && DIST='focal';
|
||||||
# [[ "$isDigital" == '22.04' ]] && DIST='jammy';
|
# [[ "$isDigital" == '22.04' ]] && DIST='jammy';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,49 +382,50 @@ if [[ -n "$tmpDIST" ]]; then
|
|||||||
fi
|
fi
|
||||||
if [[ "$Relese" == 'CentOS' ]]; then
|
if [[ "$Relese" == 'CentOS' ]]; then
|
||||||
SpikCheckDIST='1'
|
SpikCheckDIST='1'
|
||||||
DISTCheck="$(echo "$tmpDIST" | grep -o '[\.0-9]\{1,\}' | head -n1)"
|
DISTCheck="$(echo "$tmpDIST" |grep -o '[\.0-9]\{1,\}' |head -n1)";
|
||||||
LinuxMirror=$(selectMirror "$Relese" "$DISTCheck" "$VER" "$tmpMirror")
|
LinuxMirror=$(selectMirror "$Relese" "$DISTCheck" "$VER" "$tmpMirror")
|
||||||
ListDIST="$(wget --no-check-certificate -qO- "$LinuxMirror/dir_sizes" |cut -f2 |grep '^[0-9]')"
|
ListDIST="$(wget --no-check-certificate -qO- "$LinuxMirror/dir_sizes" |cut -f2 |grep '^[0-9]')"
|
||||||
DIST="$(echo "$ListDIST" |grep "^$DISTCheck" |head -n1)"
|
DIST="$(echo "$ListDIST" |grep "^$DISTCheck" |head -n1)"
|
||||||
[[ -z "$DIST" ]] && {
|
[[ -z "$DIST" ]] && {
|
||||||
echo -ne '\nThe dists version not found in this mirror, Please check it! \n\n'
|
echo -ne '\nThe dists version not found in this mirror, Please check it! \n\n'
|
||||||
bash $0 error
|
bash $0 error;
|
||||||
exit 1
|
exit 1;
|
||||||
}
|
}
|
||||||
wget --no-check-certificate -qO- "$LinuxMirror/$DIST/os/$VER/.treeinfo" | grep -q 'general'
|
wget --no-check-certificate -qO- "$LinuxMirror/$DIST/os/$VER/.treeinfo" |grep -q 'general';
|
||||||
[[ $? != '0' ]] && {
|
[[ $? != '0' ]] && {
|
||||||
echo -ne "\nThe version not found in this mirror, Please change mirror try again! \n\n"
|
echo -ne "\nThe version not found in this mirror, Please change mirror try again! \n\n";
|
||||||
exit 1
|
exit 1;
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$LinuxMirror" ]]; then
|
if [[ -z "$LinuxMirror" ]]; then
|
||||||
echo -ne "\033[31mError! \033[0mInvaild mirror! \n"
|
echo -ne "\033[31mError! \033[0mInvaild mirror! \n"
|
||||||
[ "$Relese" == 'Debian' ] && echo -en "\033[33mexample:\033[0m http://deb.debian.org/debian\n\n"
|
[ "$Relese" == 'Debian' ] && echo -en "\033[33mexample:\033[0m http://deb.debian.org/debian\n\n";
|
||||||
[ "$Relese" == 'Ubuntu' ] && echo -en "\033[33mexample:\033[0m http://archive.ubuntu.com/ubuntu\n\n"
|
[ "$Relese" == 'Ubuntu' ] && echo -en "\033[33mexample:\033[0m http://archive.ubuntu.com/ubuntu\n\n";
|
||||||
[ "$Relese" == 'CentOS' ] && echo -en "\033[33mexample:\033[0m http://mirror.centos.org/centos\n\n"
|
[ "$Relese" == 'CentOS' ] && echo -en "\033[33mexample:\033[0m http://mirror.centos.org/centos\n\n";
|
||||||
bash $0 error
|
bash $0 error;
|
||||||
exit 1
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$SpikCheckDIST" == '0' ]]; then
|
if [[ "$SpikCheckDIST" == '0' ]]; then
|
||||||
DistsList="$(wget --no-check-certificate -qO- "$LinuxMirror/dists/" | grep -o 'href=.*/"' | cut -d'"' -f2 | sed '/-\|old\|Debian\|experimental\|stable\|test\|sid\|devel/d' | grep '^[^/]' | sed -n '1h;1!H;$g;s/\n//g;s/\//\;/g;$p')"
|
DistsList="$(wget --no-check-certificate -qO- "$LinuxMirror/dists/" |grep -o 'href=.*/"' |cut -d'"' -f2 |sed '/-\|old\|Debian\|experimental\|stable\|test\|sid\|devel/d' |grep '^[^/]' |sed -n '1h;1!H;$g;s/\n//g;s/\//\;/g;$p')";
|
||||||
for CheckDEB in $(echo "$DistsList" | sed 's/;/\n/g'); do
|
for CheckDEB in `echo "$DistsList" |sed 's/;/\n/g'`
|
||||||
[[ "$CheckDEB" == "$DIST" ]] && FindDists='1' && break
|
do
|
||||||
|
[[ "$CheckDEB" == "$DIST" ]] && FindDists='1' && break;
|
||||||
done
|
done
|
||||||
[[ "$FindDists" == '0' ]] && {
|
[[ "$FindDists" == '0' ]] && {
|
||||||
echo -ne '\nThe dists version not found, Please check it! \n\n'
|
echo -ne '\nThe dists version not found, Please check it! \n\n'
|
||||||
bash $0 error
|
bash $0 error;
|
||||||
exit 1
|
exit 1;
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$ddMode" == '1' ]]; then
|
if [[ "$ddMode" == '1' ]]; then
|
||||||
if [[ -n "$tmpURL" ]]; then
|
if [[ -n "$tmpURL" ]]; then
|
||||||
DDURL="$tmpURL"
|
DDURL="$tmpURL"
|
||||||
echo "$DDURL" | grep -q '^http://\|^ftp://\|^https://'
|
echo "$DDURL" | grep -q '^http://\|^ftp://\|^https://';
|
||||||
[[ $? -ne '0' ]] && echo 'Please input vaild URL, Only support http://, ftp:// and https:// !' && exit 1
|
[[ $? -ne '0' ]] && echo 'Please input vaild URL, Only support http://, ftp:// and https:// !' && exit 1;
|
||||||
# Decompress command selection
|
# Decompress command selection
|
||||||
if echo "$DDURL" | grep -q '.gz'; then
|
if echo "$DDURL" | grep -q '.gz'; then
|
||||||
DEC_CMD="gunzip -dc"
|
DEC_CMD="gunzip -dc"
|
||||||
@@ -433,8 +435,8 @@ if [[ "$ddMode" == '1' ]]; then
|
|||||||
echo 'Please input vaild URL, Only support gz or xz file!' && exit 1
|
echo 'Please input vaild URL, Only support gz or xz file!' && exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo 'Please input vaild image URL! '
|
echo 'Please input vaild image URL! ';
|
||||||
exit 1
|
exit 1;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -454,13 +456,13 @@ if [[ "$linux_relese" == 'centos' ]]; then
|
|||||||
if [[ "$DIST" != "$UNVER" ]]; then
|
if [[ "$DIST" != "$UNVER" ]]; then
|
||||||
awk 'BEGIN{print '${UNVER}'-'${DIST}'}' |grep -q '^-'
|
awk 'BEGIN{print '${UNVER}'-'${DIST}'}' |grep -q '^-'
|
||||||
if [ $? != '0' ]; then
|
if [ $? != '0' ]; then
|
||||||
UNKNOWHW='1'
|
UNKNOWHW='1';
|
||||||
echo -en "\033[33mThe version lower then \033[31m$UNVER\033[33m may not support in auto mode! \033[0m\n"
|
echo -en "\033[33mThe version lower then \033[31m$UNVER\033[33m may not support in auto mode! \033[0m\n";
|
||||||
fi
|
fi
|
||||||
awk 'BEGIN{print '${UNVER}'-'${DIST}'+0.59}' |grep -q '^-'
|
awk 'BEGIN{print '${UNVER}'-'${DIST}'+0.59}' |grep -q '^-'
|
||||||
if [ $? == '0' ]; then
|
if [ $? == '0' ]; then
|
||||||
echo -en "\n\033[31mThe version higher then \033[33m6.10 \033[31mis not support in current! \033[0m\n\n"
|
echo -en "\n\033[31mThe version higher then \033[33m6.10 \033[31mis not support in current! \033[0m\n\n"
|
||||||
exit 1
|
exit 1;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -473,8 +475,8 @@ if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
|||||||
[[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'initrd.img' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
[[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'initrd.img' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
||||||
wget --no-check-certificate -qO '/tmp/vmlinuz' "${LinuxMirror}/dists/${DIST}${inUpdate}/main/installer-${VER}/current/${legacy}images/netboot/${linux_relese}-installer/${VER}/linux"
|
wget --no-check-certificate -qO '/tmp/vmlinuz' "${LinuxMirror}/dists/${DIST}${inUpdate}/main/installer-${VER}/current/${legacy}images/netboot/${linux_relese}-installer/${VER}/linux"
|
||||||
[[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'vmlinuz' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
[[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'vmlinuz' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
||||||
MirrorHost="$(echo "$LinuxMirror" | awk -F'://|/' '{print $2}')"
|
MirrorHost="$(echo "$LinuxMirror" |awk -F'://|/' '{print $2}')";
|
||||||
MirrorFolder="$(echo "$LinuxMirror" | awk -F''${MirrorHost}'' '{print $2}')"
|
MirrorFolder="$(echo "$LinuxMirror" |awk -F''${MirrorHost}'' '{print $2}')";
|
||||||
[ -n "$MirrorFolder" ] || MirrorFolder="/"
|
[ -n "$MirrorFolder" ] || MirrorFolder="/"
|
||||||
elif [[ "$linux_relese" == 'centos' ]]; then
|
elif [[ "$linux_relese" == 'centos' ]]; then
|
||||||
wget --no-check-certificate -qO '/tmp/initrd.img' "${LinuxMirror}/${DIST}/os/${VER}/isolinux/initrd.img"
|
wget --no-check-certificate -qO '/tmp/initrd.img' "${LinuxMirror}/${DIST}/os/${VER}/isolinux/initrd.img"
|
||||||
@@ -482,8 +484,8 @@ elif [[ "$linux_relese" == 'centos' ]]; then
|
|||||||
wget --no-check-certificate -qO '/tmp/vmlinuz' "${LinuxMirror}/${DIST}/os/${VER}/isolinux/vmlinuz"
|
wget --no-check-certificate -qO '/tmp/vmlinuz' "${LinuxMirror}/${DIST}/os/${VER}/isolinux/vmlinuz"
|
||||||
[[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'vmlinuz' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
[[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'vmlinuz' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
||||||
else
|
else
|
||||||
bash $0 error
|
bash $0 error;
|
||||||
exit 1
|
exit 1;
|
||||||
fi
|
fi
|
||||||
if [[ "$linux_relese" == 'debian' ]]; then
|
if [[ "$linux_relese" == 'debian' ]]; then
|
||||||
if [[ "$IncFirmware" == '1' ]]; then
|
if [[ "$IncFirmware" == '1' ]]; then
|
||||||
@@ -491,17 +493,17 @@ if [[ "$linux_relese" == 'debian' ]]; then
|
|||||||
[[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'firmware' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
[[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'firmware' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
||||||
fi
|
fi
|
||||||
if [[ "$ddMode" == '1' ]]; then
|
if [[ "$ddMode" == '1' ]]; then
|
||||||
vKernel_udeb=$(wget --no-check-certificate -qO- "http://$LinuxMirror/dists/$DIST/main/installer-$VER/current/images/udeb.list" | grep '^acpi-modules' | head -n1 | grep -o '[0-9]\{1,2\}.[0-9]\{1,2\}.[0-9]\{1,2\}-[0-9]\{1,2\}' | head -n1)
|
vKernel_udeb=$(wget --no-check-certificate -qO- "http://$DISTMirror/dists/$DIST/main/installer-$VER/current/images/udeb.list" |grep '^acpi-modules' |head -n1 |grep -o '[0-9]\{1,2\}.[0-9]\{1,2\}.[0-9]\{1,2\}-[0-9]\{1,2\}' |head -n1)
|
||||||
[[ -z "vKernel_udeb" ]] && vKernel_udeb="6.1.0-10"
|
[[ -z "vKernel_udeb" ]] && vKernel_udeb="4.19.0-17"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$loaderMode" == "0" ]]; then
|
if [[ "$loaderMode" == "0" ]]; then
|
||||||
[[ ! -f "${GRUBDIR}/${GRUBFILE}" ]] && echo "Error! Not Found ${GRUBFILE}. " && exit 1
|
[[ ! -f "${GRUBDIR}/${GRUBFILE}" ]] && echo "Error! Not Found ${GRUBFILE}. " && exit 1;
|
||||||
|
|
||||||
[[ ! -f "${GRUBDIR}/${GRUBFILE}.old" ]] && [[ -f "${GRUBDIR}/${GRUBFILE}.bak" ]] && mv -f "${GRUBDIR}/${GRUBFILE}.bak" "${GRUBDIR}/${GRUBFILE}.old"
|
[[ ! -f "${GRUBDIR}/${GRUBFILE}.old" ]] && [[ -f "${GRUBDIR}/${GRUBFILE}.bak" ]] && mv -f "${GRUBDIR}/${GRUBFILE}.bak" "${GRUBDIR}/${GRUBFILE}.old";
|
||||||
mv -f "${GRUBDIR}/${GRUBFILE}" "${GRUBDIR}/${GRUBFILE}.bak"
|
mv -f "${GRUBDIR}/${GRUBFILE}" "${GRUBDIR}/${GRUBFILE}.bak";
|
||||||
[[ -f "${GRUBDIR}/${GRUBFILE}.old" ]] && cat "${GRUBDIR}/${GRUBFILE}.old" >"${GRUBDIR}/${GRUBFILE}" || cat "${GRUBDIR}/${GRUBFILE}.bak" >"${GRUBDIR}/${GRUBFILE}"
|
[[ -f "${GRUBDIR}/${GRUBFILE}.old" ]] && cat "${GRUBDIR}/${GRUBFILE}.old" >"${GRUBDIR}/${GRUBFILE}" || cat "${GRUBDIR}/${GRUBFILE}.bak" >"${GRUBDIR}/${GRUBFILE}";
|
||||||
else
|
else
|
||||||
GRUBVER='-1'
|
GRUBVER='-1'
|
||||||
fi
|
fi
|
||||||
@@ -511,49 +513,50 @@ fi
|
|||||||
cat $GRUBDIR/$GRUBFILE |sed -n '1h;1!H;$g;s/\n/%%%%%%%/g;$p' |grep -om 1 'menuentry\ [^{]*{[^}]*}%%%%%%%' |sed 's/%%%%%%%/\n/g' >$READGRUB
|
cat $GRUBDIR/$GRUBFILE |sed -n '1h;1!H;$g;s/\n/%%%%%%%/g;$p' |grep -om 1 'menuentry\ [^{]*{[^}]*}%%%%%%%' |sed 's/%%%%%%%/\n/g' >$READGRUB
|
||||||
LoadNum="$(cat $READGRUB |grep -c 'menuentry ')"
|
LoadNum="$(cat $READGRUB |grep -c 'menuentry ')"
|
||||||
if [[ "$LoadNum" -eq '1' ]]; then
|
if [[ "$LoadNum" -eq '1' ]]; then
|
||||||
cat $READGRUB | sed '/^$/d' >/tmp/grub.new
|
cat $READGRUB |sed '/^$/d' >/tmp/grub.new;
|
||||||
elif [[ "$LoadNum" -gt '1' ]]; then
|
elif [[ "$LoadNum" -gt '1' ]]; then
|
||||||
CFG0="$(awk '/menuentry /{print NR}' $READGRUB | head -n 1)"
|
CFG0="$(awk '/menuentry /{print NR}' $READGRUB|head -n 1)";
|
||||||
CFG2="$(awk '/menuentry /{print NR}' $READGRUB | head -n 2 | tail -n 1)"
|
CFG2="$(awk '/menuentry /{print NR}' $READGRUB|head -n 2 |tail -n 1)";
|
||||||
CFG1=""
|
CFG1="";
|
||||||
for tmpCFG in $(awk '/}/{print NR}' $READGRUB); do
|
for tmpCFG in `awk '/}/{print NR}' $READGRUB`
|
||||||
[ "$tmpCFG" -gt "$CFG0" -a "$tmpCFG" -lt "$CFG2" ] && CFG1="$tmpCFG"
|
do
|
||||||
|
[ "$tmpCFG" -gt "$CFG0" -a "$tmpCFG" -lt "$CFG2" ] && CFG1="$tmpCFG";
|
||||||
done
|
done
|
||||||
[[ -z "$CFG1" ]] && {
|
[[ -z "$CFG1" ]] && {
|
||||||
echo "Error! read $GRUBFILE. "
|
echo "Error! read $GRUBFILE. ";
|
||||||
exit 1
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sed -n "$CFG0,$CFG1"p $READGRUB >/tmp/grub.new
|
sed -n "$CFG0,$CFG1"p $READGRUB >/tmp/grub.new;
|
||||||
[[ -f /tmp/grub.new ]] && [[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || {
|
[[ -f /tmp/grub.new ]] && [[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || {
|
||||||
echo -ne "\033[31mError! \033[0mNot configure $GRUBFILE. \n"
|
echo -ne "\033[31mError! \033[0mNot configure $GRUBFILE. \n";
|
||||||
exit 1
|
exit 1;
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
[ ! -f /tmp/grub.new ] && echo "Error! $GRUBFILE. " && exit 1
|
[ ! -f /tmp/grub.new ] && echo "Error! $GRUBFILE. " && exit 1;
|
||||||
sed -i "/menuentry.*/c\menuentry\ \'Install OS \[$DIST\ $VER\]\'\ --class debian\ --class\ gnu-linux\ --class\ gnu\ --class\ os\ \{" /tmp/grub.new
|
sed -i "/menuentry.*/c\menuentry\ \'Install OS \[$DIST\ $VER\]\'\ --class debian\ --class\ gnu-linux\ --class\ gnu\ --class\ os\ \{" /tmp/grub.new
|
||||||
sed -i "/echo.*Loading/d" /tmp/grub.new
|
sed -i "/echo.*Loading/d" /tmp/grub.new;
|
||||||
INSERTGRUB="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
|
INSERTGRUB="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ "$GRUBVER" == '1' ]] && {
|
[[ "$GRUBVER" == '1' ]] && {
|
||||||
CFG0="$(awk '/title[\ ]|title[\t]/{print NR}' $GRUBDIR/$GRUBFILE | head -n 1)"
|
CFG0="$(awk '/title[\ ]|title[\t]/{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)";
|
||||||
CFG1="$(awk '/title[\ ]|title[\t]/{print NR}' $GRUBDIR/$GRUBFILE | head -n 2 | tail -n 1)"
|
CFG1="$(awk '/title[\ ]|title[\t]/{print NR}' $GRUBDIR/$GRUBFILE|head -n 2 |tail -n 1)";
|
||||||
[[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 == $CFG0 ] && sed -n "$CFG0,$"p $GRUBDIR/$GRUBFILE >/tmp/grub.new
|
[[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 == $CFG0 ] && sed -n "$CFG0,$"p $GRUBDIR/$GRUBFILE >/tmp/grub.new;
|
||||||
[[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 != $CFG0 ] && sed -n "$CFG0,$(($CFG1 - 1))"p $GRUBDIR/$GRUBFILE >/tmp/grub.new
|
[[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 != $CFG0 ] && sed -n "$CFG0,$[$CFG1-1]"p $GRUBDIR/$GRUBFILE >/tmp/grub.new;
|
||||||
[[ ! -f /tmp/grub.new ]] && echo "Error! configure append $GRUBFILE. " && exit 1
|
[[ ! -f /tmp/grub.new ]] && echo "Error! configure append $GRUBFILE. " && exit 1;
|
||||||
sed -i "/title.*/c\title\ \'Install OS \[$DIST\ $VER\]\'" /tmp/grub.new
|
sed -i "/title.*/c\title\ \'Install OS \[$DIST\ $VER\]\'" /tmp/grub.new;
|
||||||
sed -i '/^#/d' /tmp/grub.new
|
sed -i '/^#/d' /tmp/grub.new;
|
||||||
INSERTGRUB="$(awk '/title[\ ]|title[\t]/{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
|
INSERTGRUB="$(awk '/title[\ ]|title[\t]/{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$loaderMode" == "0" ]]; then
|
if [[ "$loaderMode" == "0" ]]; then
|
||||||
[[ -n "$(grep 'linux.*/\|kernel.*/' /tmp/grub.new | awk '{print $2}' | tail -n 1 | grep '^/boot/')" ]] && Type='InBoot' || Type='NoBoot'
|
[[ -n "$(grep 'linux.*/\|kernel.*/' /tmp/grub.new |awk '{print $2}' |tail -n 1 |grep '^/boot/')" ]] && Type='InBoot' || Type='NoBoot';
|
||||||
|
|
||||||
LinuxKernel="$(grep 'linux.*/\|kernel.*/' /tmp/grub.new | awk '{print $1}' | head -n 1)"
|
LinuxKernel="$(grep 'linux.*/\|kernel.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)";
|
||||||
[[ -z "$LinuxKernel" ]] && echo "Error! read grub config! " && exit 1
|
[[ -z "$LinuxKernel" ]] && echo "Error! read grub config! " && exit 1;
|
||||||
LinuxIMG="$(grep 'initrd.*/' /tmp/grub.new | awk '{print $1}' | tail -n 1)"
|
LinuxIMG="$(grep 'initrd.*/' /tmp/grub.new |awk '{print $1}' |tail -n 1)";
|
||||||
[ -z "$LinuxIMG" ] && sed -i "/$LinuxKernel.*\//a\\\tinitrd\ \/" /tmp/grub.new && LinuxIMG='initrd'
|
[ -z "$LinuxIMG" ] && sed -i "/$LinuxKernel.*\//a\\\tinitrd\ \/" /tmp/grub.new && LinuxIMG='initrd';
|
||||||
|
|
||||||
[[ "$setInterfaceName" == "1" ]] && Add_OPTION="net.ifnames=0 biosdevname=0" || Add_OPTION=""
|
[[ "$setInterfaceName" == "1" ]] && Add_OPTION="net.ifnames=0 biosdevname=0" || Add_OPTION=""
|
||||||
[[ "$setIPv6" == "1" ]] && Add_OPTION="$Add_OPTION ipv6.disable=1"
|
[[ "$setIPv6" == "1" ]] && Add_OPTION="$Add_OPTION ipv6.disable=1"
|
||||||
@@ -569,34 +572,35 @@ if [[ "$loaderMode" == "0" ]]; then
|
|||||||
[ -n "$setConsole" ] && BOOT_OPTION="$BOOT_OPTION --- console=$setConsole"
|
[ -n "$setConsole" ] && BOOT_OPTION="$BOOT_OPTION --- console=$setConsole"
|
||||||
|
|
||||||
[[ "$Type" == 'InBoot' ]] && {
|
[[ "$Type" == 'InBoot' ]] && {
|
||||||
sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/boot\/vmlinuz $BOOT_OPTION" /tmp/grub.new
|
sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/boot\/vmlinuz $BOOT_OPTION" /tmp/grub.new;
|
||||||
sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/boot\/initrd.img" /tmp/grub.new
|
sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/boot\/initrd.img" /tmp/grub.new;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ "$Type" == 'NoBoot' ]] && {
|
[[ "$Type" == 'NoBoot' ]] && {
|
||||||
sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/vmlinuz $BOOT_OPTION" /tmp/grub.new
|
sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/vmlinuz $BOOT_OPTION" /tmp/grub.new;
|
||||||
sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/initrd.img" /tmp/grub.new
|
sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/initrd.img" /tmp/grub.new;
|
||||||
}
|
}
|
||||||
|
|
||||||
sed -i '$a\\n' /tmp/grub.new
|
sed -i '$a\\n' /tmp/grub.new;
|
||||||
|
|
||||||
sed -i ''${INSERTGRUB}'i\\n' $GRUBDIR/$GRUBFILE
|
sed -i ''${INSERTGRUB}'i\\n' $GRUBDIR/$GRUBFILE;
|
||||||
sed -i ''${INSERTGRUB}'r /tmp/grub.new' $GRUBDIR/$GRUBFILE
|
sed -i ''${INSERTGRUB}'r /tmp/grub.new' $GRUBDIR/$GRUBFILE;
|
||||||
[[ -f $GRUBDIR/grubenv ]] && sed -i 's/saved_entry/#saved_entry/g' $GRUBDIR/grubenv
|
[[ -f $GRUBDIR/grubenv ]] && sed -i 's/saved_entry/#saved_entry/g' $GRUBDIR/grubenv;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -d /tmp/boot ]] && rm -rf /tmp/boot
|
[[ -d /tmp/boot ]] && rm -rf /tmp/boot;
|
||||||
mkdir -p /tmp/boot
|
mkdir -p /tmp/boot;
|
||||||
cd /tmp/boot
|
cd /tmp/boot;
|
||||||
|
|
||||||
if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
||||||
COMPTYPE="gzip"
|
COMPTYPE="gzip";
|
||||||
elif [[ "$linux_relese" == 'centos' ]]; then
|
elif [[ "$linux_relese" == 'centos' ]]; then
|
||||||
COMPTYPE="$(file ../initrd.img |grep -o ':.*compressed data' |cut -d' ' -f2 |sed -r 's/(.*)/\L\1/' |head -n1)"
|
COMPTYPE="$(file ../initrd.img |grep -o ':.*compressed data' |cut -d' ' -f2 |sed -r 's/(.*)/\L\1/' |head -n1)"
|
||||||
[[ -z "$COMPTYPE" ]] && echo "Detect compressed type fail." && exit 1
|
[[ -z "$COMPTYPE" ]] && echo "Detect compressed type fail." && exit 1;
|
||||||
fi
|
fi
|
||||||
CompDected='0'
|
CompDected='0'
|
||||||
for COMP in $(echo -en 'gzip\nlzma\nxz'); do
|
for COMP in `echo -en 'gzip\nlzma\nxz'`
|
||||||
|
do
|
||||||
if [[ "$COMPTYPE" == "$COMP" ]]; then
|
if [[ "$COMPTYPE" == "$COMP" ]]; then
|
||||||
CompDected='1'
|
CompDected='1'
|
||||||
if [[ "$COMPTYPE" == 'gzip' ]]; then
|
if [[ "$COMPTYPE" == 'gzip' ]]; then
|
||||||
@@ -605,18 +609,18 @@ for COMP in $(echo -en 'gzip\nlzma\nxz'); do
|
|||||||
NewIMG="initrd.img.$COMPTYPE"
|
NewIMG="initrd.img.$COMPTYPE"
|
||||||
fi
|
fi
|
||||||
mv -f "/tmp/initrd.img" "/tmp/$NewIMG"
|
mv -f "/tmp/initrd.img" "/tmp/$NewIMG"
|
||||||
break
|
break;
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
[[ "$CompDected" != '1' ]] && echo "Detect compressed type not support." && exit 1
|
[[ "$CompDected" != '1' ]] && echo "Detect compressed type not support." && exit 1;
|
||||||
[[ "$COMPTYPE" == 'lzma' ]] && UNCOMP='xz --format=lzma --decompress'
|
[[ "$COMPTYPE" == 'lzma' ]] && UNCOMP='xz --format=lzma --decompress';
|
||||||
[[ "$COMPTYPE" == 'xz' ]] && UNCOMP='xz --decompress'
|
[[ "$COMPTYPE" == 'xz' ]] && UNCOMP='xz --decompress';
|
||||||
[[ "$COMPTYPE" == 'gzip' ]] && UNCOMP='gzip -d'
|
[[ "$COMPTYPE" == 'gzip' ]] && UNCOMP='gzip -d';
|
||||||
|
|
||||||
$UNCOMP < /tmp/$NewIMG | cpio --extract --verbose --make-directories --no-absolute-filenames >>/dev/null 2>&1
|
$UNCOMP < /tmp/$NewIMG | cpio --extract --verbose --make-directories --no-absolute-filenames >>/dev/null 2>&1
|
||||||
|
|
||||||
if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
||||||
CurrentKernelVersion=$(ls -1 ./lib/modules 2>/dev/null | head -n1)
|
CurrentKernelVersion=`ls -1 ./lib/modules 2>/dev/null |head -n1`
|
||||||
[ -n "$CurrentKernelVersion" ] && SelectLowmem="di-utils-exit-installer,driver-injection-disk-detect,fdisk-udeb,netcfg-static,parted-udeb,partman-auto,partman-ext3,ata-modules-${CurrentKernelVersion}-di,efi-modules-${CurrentKernelVersion}-di,sata-modules-${CurrentKernelVersion}-di,scsi-modules-${CurrentKernelVersion}-di,scsi-nic-modules-${CurrentKernelVersion}-di" || SelectLowmem=""
|
[ -n "$CurrentKernelVersion" ] && SelectLowmem="di-utils-exit-installer,driver-injection-disk-detect,fdisk-udeb,netcfg-static,parted-udeb,partman-auto,partman-ext3,ata-modules-${CurrentKernelVersion}-di,efi-modules-${CurrentKernelVersion}-di,sata-modules-${CurrentKernelVersion}-di,scsi-modules-${CurrentKernelVersion}-di,scsi-nic-modules-${CurrentKernelVersion}-di" || SelectLowmem=""
|
||||||
cat >/tmp/boot/preseed.cfg<<EOF
|
cat >/tmp/boot/preseed.cfg<<EOF
|
||||||
d-i debian-installer/locale string en_US.UTF-8
|
d-i debian-installer/locale string en_US.UTF-8
|
||||||
@@ -725,17 +729,17 @@ EOF
|
|||||||
|
|
||||||
[[ "$ddMode" == '1' ]] && {
|
[[ "$ddMode" == '1' ]] && {
|
||||||
WinNoDHCP(){
|
WinNoDHCP(){
|
||||||
echo -ne "for\0040\0057f\0040\0042tokens\00753\0052\0042\0040\0045\0045i\0040in\0040\0050\0047netsh\0040interface\0040show\0040interface\0040\0136\0174more\0040\00533\0040\0136\0174findstr\0040\0057I\0040\0057R\0040\0042本地\0056\0052\0040以太\0056\0052\0040Local\0056\0052\0040Ethernet\0042\0047\0051\0040do\0040\0050set\0040EthName\0075\0045\0045j\0051\r\nnetsh\0040\0055c\0040interface\0040ip\0040set\0040address\0040name\0075\0042\0045EthName\0045\0042\0040source\0075static\0040address\0075$IPv4\0040mask\0075$MASK\0040gateway\0075$GATE\r\nnetsh\0040\0055c\0040interface\0040ip\0040add\0040dnsservers\0040name\0075\0042\0045EthName\0045\0042\0040address\00758\00568\00568\00568\0040index\00751\0040validate\0075no\r\n\r\n" >>'/tmp/boot/net.tmp'
|
echo -ne "for\0040\0057f\0040\0042tokens\00753\0052\0042\0040\0045\0045i\0040in\0040\0050\0047netsh\0040interface\0040show\0040interface\0040\0136\0174more\0040\00533\0040\0136\0174findstr\0040\0057I\0040\0057R\0040\0042本地\0056\0052\0040以太\0056\0052\0040Local\0056\0052\0040Ethernet\0042\0047\0051\0040do\0040\0050set\0040EthName\0075\0045\0045j\0051\r\nnetsh\0040\0055c\0040interface\0040ip\0040set\0040address\0040name\0075\0042\0045EthName\0045\0042\0040source\0075static\0040address\0075$IPv4\0040mask\0075$MASK\0040gateway\0075$GATE\r\nnetsh\0040\0055c\0040interface\0040ip\0040add\0040dnsservers\0040name\0075\0042\0045EthName\0045\0042\0040address\00758\00568\00568\00568\0040index\00751\0040validate\0075no\r\n\r\n" >>'/tmp/boot/net.tmp';
|
||||||
}
|
}
|
||||||
WinRDP(){
|
WinRDP(){
|
||||||
echo -ne "netsh\0040firewall\0040set\0040portopening\0040protocol\0075ALL\0040port\0075$WinRemote\0040name\0075RDP\0040mode\0075ENABLE\0040scope\0075ALL\0040profile\0075ALL\r\nnetsh\0040firewall\0040set\0040portopening\0040protocol\0075ALL\0040port\0075$WinRemote\0040name\0075RDP\0040mode\0075ENABLE\0040scope\0075ALL\0040profile\0075CURRENT\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Network\0134NewNetworkWindowOff\0042\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0042\0040\0057v\0040fDenyTSConnections\0040\0057t\0040reg\0137dword\0040\0057d\00400\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134Wds\0134rdpwd\0134Tds\0134tcp\0042\0040\0057v\0040PortNumber\0040\0057t\0040reg\0137dword\0040\0057d\0040$WinRemote\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134WinStations\0134RDP\0055Tcp\0042\0040\0057v\0040PortNumber\0040\0057t\0040reg\0137dword\0040\0057d\0040$WinRemote\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134WinStations\0134RDP\0055Tcp\0042\0040\0057v\0040UserAuthentication\0040\0057t\0040reg\0137dword\0040\0057d\00400\0040\0057f\r\nFOR\0040\0057F\0040\0042tokens\00752\0040delims\0075\0072\0042\0040\0045\0045i\0040in\0040\0050\0047SC\0040QUERYEX\0040TermService\0040\0136\0174FINDSTR\0040\0057I\0040\0042PID\0042\0047\0051\0040do\0040TASKKILL\0040\0057F\0040\0057PID\0040\0045\0045i\r\nFOR\0040\0057F\0040\0042tokens\00752\0040delims\0075\0072\0042\0040\0045\0045i\0040in\0040\0050\0047SC\0040QUERYEX\0040UmRdpService\0040\0136\0174FINDSTR\0040\0057I\0040\0042PID\0042\0047\0051\0040do\0040TASKKILL\0040\0057F\0040\0057PID\0040\0045\0045i\r\nSC\0040START\0040TermService\r\n\r\n" >>'/tmp/boot/net.tmp'
|
echo -ne "netsh\0040firewall\0040set\0040portopening\0040protocol\0075ALL\0040port\0075$WinRemote\0040name\0075RDP\0040mode\0075ENABLE\0040scope\0075ALL\0040profile\0075ALL\r\nnetsh\0040firewall\0040set\0040portopening\0040protocol\0075ALL\0040port\0075$WinRemote\0040name\0075RDP\0040mode\0075ENABLE\0040scope\0075ALL\0040profile\0075CURRENT\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Network\0134NewNetworkWindowOff\0042\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0042\0040\0057v\0040fDenyTSConnections\0040\0057t\0040reg\0137dword\0040\0057d\00400\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134Wds\0134rdpwd\0134Tds\0134tcp\0042\0040\0057v\0040PortNumber\0040\0057t\0040reg\0137dword\0040\0057d\0040$WinRemote\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134WinStations\0134RDP\0055Tcp\0042\0040\0057v\0040PortNumber\0040\0057t\0040reg\0137dword\0040\0057d\0040$WinRemote\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134WinStations\0134RDP\0055Tcp\0042\0040\0057v\0040UserAuthentication\0040\0057t\0040reg\0137dword\0040\0057d\00400\0040\0057f\r\nFOR\0040\0057F\0040\0042tokens\00752\0040delims\0075\0072\0042\0040\0045\0045i\0040in\0040\0050\0047SC\0040QUERYEX\0040TermService\0040\0136\0174FINDSTR\0040\0057I\0040\0042PID\0042\0047\0051\0040do\0040TASKKILL\0040\0057F\0040\0057PID\0040\0045\0045i\r\nFOR\0040\0057F\0040\0042tokens\00752\0040delims\0075\0072\0042\0040\0045\0045i\0040in\0040\0050\0047SC\0040QUERYEX\0040UmRdpService\0040\0136\0174FINDSTR\0040\0057I\0040\0042PID\0042\0047\0051\0040do\0040TASKKILL\0040\0057F\0040\0057PID\0040\0045\0045i\r\nSC\0040START\0040TermService\r\n\r\n" >>'/tmp/boot/net.tmp';
|
||||||
}
|
}
|
||||||
echo -ne "\0100ECHO\0040OFF\r\n\r\ncd\0056\0076\0045WINDIR\0045\0134GetAdmin\r\nif\0040exist\0040\0045WINDIR\0045\0134GetAdmin\0040\0050del\0040\0057f\0040\0057q\0040\0042\0045WINDIR\0045\0134GetAdmin\0042\0051\0040else\0040\0050\r\necho\0040CreateObject\0136\0050\0042Shell\0056Application\0042\0136\0051\0056ShellExecute\0040\0042\0045\0176s0\0042\0054\0040\0042\0045\0052\0042\0054\0040\0042\0042\0054\0040\0042runas\0042\0054\00401\0040\0076\0076\0040\0042\0045temp\0045\0134Admin\0056vbs\0042\r\n\0042\0045temp\0045\0134Admin\0056vbs\0042\r\ndel\0040\0057f\0040\0057q\0040\0042\0045temp\0045\0134Admin\0056vbs\0042\r\nexit\0040\0057b\00402\0051\r\n\r\n" >'/tmp/boot/net.tmp'
|
echo -ne "\0100ECHO\0040OFF\r\n\r\ncd\0056\0076\0045WINDIR\0045\0134GetAdmin\r\nif\0040exist\0040\0045WINDIR\0045\0134GetAdmin\0040\0050del\0040\0057f\0040\0057q\0040\0042\0045WINDIR\0045\0134GetAdmin\0042\0051\0040else\0040\0050\r\necho\0040CreateObject\0136\0050\0042Shell\0056Application\0042\0136\0051\0056ShellExecute\0040\0042\0045\0176s0\0042\0054\0040\0042\0045\0052\0042\0054\0040\0042\0042\0054\0040\0042runas\0042\0054\00401\0040\0076\0076\0040\0042\0045temp\0045\0134Admin\0056vbs\0042\r\n\0042\0045temp\0045\0134Admin\0056vbs\0042\r\ndel\0040\0057f\0040\0057q\0040\0042\0045temp\0045\0134Admin\0056vbs\0042\r\nexit\0040\0057b\00402\0051\r\n\r\n" >'/tmp/boot/net.tmp';
|
||||||
[[ "$setNet" == '1' ]] && WinNoDHCP
|
[[ "$setNet" == '1' ]] && WinNoDHCP;
|
||||||
[[ "$setNet" == '0' ]] && [[ "$AutoNet" == '0' ]] && WinNoDHCP
|
[[ "$setNet" == '0' ]] && [[ "$AutoNet" == '0' ]] && WinNoDHCP;
|
||||||
[[ "$setRDP" == '1' ]] && [[ -n "$WinRemote" ]] && WinRDP
|
[[ "$setRDP" == '1' ]] && [[ -n "$WinRemote" ]] && WinRDP
|
||||||
echo -ne "ECHO\0040SELECT\0040VOLUME\0075\0045\0045SystemDrive\0045\0045\0040\0076\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nECHO\0040EXTEND\0040\0076\0076\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nSTART\0040/WAIT\0040DISKPART\0040\0057S\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nDEL\0040\0057f\0040\0057q\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\n\r\n" >>'/tmp/boot/net.tmp'
|
echo -ne "ECHO\0040SELECT\0040VOLUME\0075\0045\0045SystemDrive\0045\0045\0040\0076\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nECHO\0040EXTEND\0040\0076\0076\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nSTART\0040/WAIT\0040DISKPART\0040\0057S\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nDEL\0040\0057f\0040\0057q\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\n\r\n" >>'/tmp/boot/net.tmp';
|
||||||
echo -ne "cd\0040\0057d\0040\0042\0045ProgramData\0045\0057Microsoft\0057Windows\0057Start\0040Menu\0057Programs\0057Startup\0042\r\ndel\0040\0057f\0040\0057q\0040net\0056bat\r\n\r\n\r\n" >>'/tmp/boot/net.tmp'
|
echo -ne "cd\0040\0057d\0040\0042\0045ProgramData\0045\0057Microsoft\0057Windows\0057Start\0040Menu\0057Programs\0057Startup\0042\r\ndel\0040\0057f\0040\0057q\0040net\0056bat\r\n\r\n\r\n" >>'/tmp/boot/net.tmp';
|
||||||
iconv -f 'UTF-8' -t 'GBK' '/tmp/boot/net.tmp' -o '/tmp/boot/net.bat'
|
iconv -f 'UTF-8' -t 'GBK' '/tmp/boot/net.tmp' -o '/tmp/boot/net.bat'
|
||||||
rm -rf '/tmp/boot/net.tmp'
|
rm -rf '/tmp/boot/net.tmp'
|
||||||
}
|
}
|
||||||
@@ -782,11 +786,12 @@ rm -rf /root/install.*log
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
[[ "$UNKNOWHW" == '1' ]] && sed -i 's/^unsupported_hardware/#unsupported_hardware/g' /tmp/boot/ks.cfg
|
[[ "$UNKNOWHW" == '1' ]] && sed -i 's/^unsupported_hardware/#unsupported_hardware/g' /tmp/boot/ks.cfg
|
||||||
[[ "$(echo "$DIST" |grep -o '^[0-9]\{1\}')" == '5' ]] && sed -i '0,/^%end/s//#%end/' /tmp/boot/ks.cfg
|
[[ "$(echo "$DIST" |grep -o '^[0-9]\{1\}')" == '5' ]] && sed -i '0,/^%end/s//#%end/' /tmp/boot/ks.cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find . | cpio -H newc --create --verbose | gzip -9 >/tmp/initrd.img
|
find . | cpio -H newc --create --verbose | gzip -9 > /tmp/initrd.img;
|
||||||
cp -f /tmp/initrd.img /boot/initrd.img || sudo cp -f /tmp/initrd.img /boot/initrd.img
|
cp -f /tmp/initrd.img /boot/initrd.img || sudo cp -f /tmp/initrd.img /boot/initrd.img
|
||||||
cp -f /tmp/vmlinuz /boot/vmlinuz || sudo cp -f /tmp/vmlinuz /boot/vmlinuz
|
cp -f /tmp/vmlinuz /boot/vmlinuz || sudo cp -f /tmp/vmlinuz /boot/vmlinuz
|
||||||
|
|
||||||
|
205
bench.sh
205
bench.sh
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Description: A Bench Script by Teddysun
|
# Description: A Bench Script by Teddysun
|
||||||
#
|
#
|
||||||
# Copyright (C) 2015 - 2025 Teddysun <i@teddysun.com>
|
# Copyright (C) 2015 - 2023 Teddysun <i@teddysun.com>
|
||||||
# Thanks: LookBack <admin@dwhd.org>
|
# Thanks: LookBack <admin@dwhd.org>
|
||||||
# URL: https://teddysun.com/444.html
|
# URL: https://teddysun.com/444.html
|
||||||
# https://github.com/teddysun/across/blob/master/bench.sh
|
# https://github.com/teddysun/across/blob/master/bench.sh
|
||||||
@@ -57,16 +57,12 @@ next() {
|
|||||||
|
|
||||||
speed_test() {
|
speed_test() {
|
||||||
local nodeName="$2"
|
local nodeName="$2"
|
||||||
if [ -z "$1" ];then
|
[ -z "$1" ] && ./speedtest-cli/speedtest --progress=no --accept-license --accept-gdpr > ./speedtest-cli/speedtest.log 2>&1 || \
|
||||||
./speedtest-cli/speedtest --progress=no --accept-license --accept-gdpr >./speedtest-cli/speedtest.log 2>&1
|
./speedtest-cli/speedtest --progress=no --server-id=$1 --accept-license --accept-gdpr > ./speedtest-cli/speedtest.log 2>&1
|
||||||
else
|
|
||||||
./speedtest-cli/speedtest --progress=no --server-id="$1" --accept-license --accept-gdpr >./speedtest-cli/speedtest.log 2>&1
|
|
||||||
fi
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
local dl_speed up_speed latency
|
local dl_speed=$(awk '/Download/{print $3" "$4}' ./speedtest-cli/speedtest.log)
|
||||||
dl_speed=$(awk '/Download/{print $3" "$4}' ./speedtest-cli/speedtest.log)
|
local up_speed=$(awk '/Upload/{print $3" "$4}' ./speedtest-cli/speedtest.log)
|
||||||
up_speed=$(awk '/Upload/{print $3" "$4}' ./speedtest-cli/speedtest.log)
|
local latency=$(awk '/Latency/{print $2" "$3}' ./speedtest-cli/speedtest.log)
|
||||||
latency=$(awk '/Latency/{print $3" "$4}' ./speedtest-cli/speedtest.log)
|
|
||||||
if [[ -n "${dl_speed}" && -n "${up_speed}" && -n "${latency}" ]]; then
|
if [[ -n "${dl_speed}" && -n "${up_speed}" && -n "${latency}" ]]; then
|
||||||
printf "\033[0;33m%-18s\033[0;32m%-18s\033[0;31m%-20s\033[0;36m%-12s\033[0m\n" " ${nodeName}" "${up_speed}" "${dl_speed}" "${latency}"
|
printf "\033[0;33m%-18s\033[0;32m%-18s\033[0;31m%-20s\033[0;36m%-12s\033[0m\n" " ${nodeName}" "${up_speed}" "${dl_speed}" "${latency}"
|
||||||
fi
|
fi
|
||||||
@@ -75,21 +71,31 @@ speed_test() {
|
|||||||
|
|
||||||
speed() {
|
speed() {
|
||||||
speed_test '' 'Speedtest.net'
|
speed_test '' 'Speedtest.net'
|
||||||
|
speed_test '29071' 'Chengdu, CN'
|
||||||
|
speed_test '17584' 'Chongqing, CN'
|
||||||
|
speed_test '29105' 'Xi an, CN'
|
||||||
|
speed_test '28225' 'Changsha, CN'
|
||||||
|
speed_test '29353' 'Wuhan, CN'
|
||||||
|
speed_test '16145' 'Lanzhou, CN'
|
||||||
|
speed_test '3973' 'Lanzhou, CN'
|
||||||
|
speed_test '41910' 'Zhengzhou, CN'
|
||||||
|
speed_test '36996' 'Guiyang, CN'
|
||||||
|
speed_test '24447' 'Shanghai, CN'
|
||||||
|
speed_test '26352' 'Nanjing, CN'
|
||||||
|
speed_test '27594' 'Guangzhou, CN'
|
||||||
|
speed_test '32155' 'Hongkong, CN'
|
||||||
speed_test '21541' 'Los Angeles, US'
|
speed_test '21541' 'Los Angeles, US'
|
||||||
speed_test '43860' 'Dallas, US'
|
speed_test '43860' 'Dallas, US'
|
||||||
speed_test '40879' 'Montreal, CA'
|
speed_test '40879' 'Montreal, CA'
|
||||||
speed_test '61933' 'Paris, FR'
|
speed_test '24215' 'Paris, FR'
|
||||||
speed_test '28922' 'Amsterdam, NL'
|
speed_test '28922' 'Amsterdam, NL'
|
||||||
speed_test '25858' 'Beijing, CN'
|
speed_test '6527' 'Seoul, KR'
|
||||||
speed_test '24447' 'Shanghai, CN'
|
speed_test '7311' 'Singapore, SG'
|
||||||
speed_test '60572' 'Guangzhou, CN'
|
speed_test '21569' 'Tokyo, JP'
|
||||||
speed_test '32155' 'Hong Kong, CN'
|
|
||||||
speed_test '13623' 'Singapore, SG'
|
|
||||||
speed_test '48463' 'Tokyo, JP'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
io_test() {
|
io_test() {
|
||||||
(LANG=C dd if=/dev/zero of=benchtest_$$ bs=512k count="$1" conv=fdatasync && rm -f benchtest_$$) 2>&1 | awk -F '[,,]' '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
(LANG=C dd if=/dev/zero of=benchtest_$$ bs=512k count=$1 conv=fdatasync && rm -f benchtest_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
||||||
}
|
}
|
||||||
|
|
||||||
calc_size() {
|
calc_size() {
|
||||||
@@ -114,27 +120,10 @@ calc_size() {
|
|||||||
echo "${total_size}"
|
echo "${total_size}"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
total_size=$(awk 'BEGIN{printf "%.1f", '"$raw"' / '$num'}')
|
total_size=$( awk 'BEGIN{printf "%.1f", '$raw' / '$num'}' )
|
||||||
echo "${total_size} ${unit}"
|
echo "${total_size} ${unit}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# since calc_size converts kilobyte to MB, GB and TB
|
|
||||||
# to_kibyte converts zfs size from bytes to kilobyte
|
|
||||||
to_kibyte() {
|
|
||||||
local raw=$1
|
|
||||||
awk 'BEGIN{printf "%.0f", '"$raw"' / 1024}'
|
|
||||||
}
|
|
||||||
|
|
||||||
calc_sum() {
|
|
||||||
local arr=("$@")
|
|
||||||
local s
|
|
||||||
s=0
|
|
||||||
for i in "${arr[@]}"; do
|
|
||||||
s=$((s + i))
|
|
||||||
done
|
|
||||||
echo ${s}
|
|
||||||
}
|
|
||||||
|
|
||||||
check_virt(){
|
check_virt(){
|
||||||
_exists "dmesg" && virtualx="$(dmesg 2>/dev/null)"
|
_exists "dmesg" && virtualx="$(dmesg 2>/dev/null)"
|
||||||
if _exists "dmidecode"; then
|
if _exists "dmidecode"; then
|
||||||
@@ -158,8 +147,6 @@ check_virt() {
|
|||||||
virt="KVM"
|
virt="KVM"
|
||||||
elif [[ "${sys_product}" == *KVM* ]]; then
|
elif [[ "${sys_product}" == *KVM* ]]; then
|
||||||
virt="KVM"
|
virt="KVM"
|
||||||
elif [[ "${sys_manu}" == *QEMU* ]]; then
|
|
||||||
virt="KVM"
|
|
||||||
elif [[ "${cname}" == *KVM* ]]; then
|
elif [[ "${cname}" == *KVM* ]]; then
|
||||||
virt="KVM"
|
virt="KVM"
|
||||||
elif [[ "${cname}" == *QEMU* ]]; then
|
elif [[ "${cname}" == *QEMU* ]]; then
|
||||||
@@ -194,21 +181,20 @@ check_virt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ipv4_info() {
|
ipv4_info() {
|
||||||
local org city country region
|
local org="$(wget -q -T10 -O- ipinfo.io/org)"
|
||||||
org="$(wget -q -T10 -O- http://ipinfo.io/org)"
|
local city="$(wget -q -T10 -O- ipinfo.io/city)"
|
||||||
city="$(wget -q -T10 -O- http://ipinfo.io/city)"
|
local country="$(wget -q -T10 -O- ipinfo.io/country)"
|
||||||
country="$(wget -q -T10 -O- http://ipinfo.io/country)"
|
local region="$(wget -q -T10 -O- ipinfo.io/region)"
|
||||||
region="$(wget -q -T10 -O- http://ipinfo.io/region)"
|
if [[ -n "$org" ]]; then
|
||||||
if [[ -n "${org}" ]]; then
|
echo " Organization : $(_blue "$org")"
|
||||||
echo " Organization : $(_blue "${org}")"
|
|
||||||
fi
|
fi
|
||||||
if [[ -n "${city}" && -n "${country}" ]]; then
|
if [[ -n "$city" && -n "country" ]]; then
|
||||||
echo " Location : $(_blue "${city} / ${country}")"
|
echo " Location : $(_blue "$city / $country")"
|
||||||
fi
|
fi
|
||||||
if [[ -n "${region}" ]]; then
|
if [[ -n "$region" ]]; then
|
||||||
echo " Region : $(_yellow "${region}")"
|
echo " Region : $(_yellow "$region")"
|
||||||
fi
|
fi
|
||||||
if [[ -z "${org}" ]]; then
|
if [[ -z "$org" ]]; then
|
||||||
echo " Region : $(_red "No ISP detected")"
|
echo " Region : $(_red "No ISP detected")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -216,10 +202,9 @@ ipv4_info() {
|
|||||||
install_speedtest() {
|
install_speedtest() {
|
||||||
if [ ! -e "./speedtest-cli/speedtest" ]; then
|
if [ ! -e "./speedtest-cli/speedtest" ]; then
|
||||||
sys_bit=""
|
sys_bit=""
|
||||||
local sysarch
|
local sysarch="$(uname -m)"
|
||||||
sysarch="$(uname -m)"
|
|
||||||
if [ "${sysarch}" = "unknown" ] || [ "${sysarch}" = "" ]; then
|
if [ "${sysarch}" = "unknown" ] || [ "${sysarch}" = "" ]; then
|
||||||
sysarch="$(arch)"
|
local sysarch="$(arch)"
|
||||||
fi
|
fi
|
||||||
if [ "${sysarch}" = "x86_64" ]; then
|
if [ "${sysarch}" = "x86_64" ]; then
|
||||||
sys_bit="x86_64"
|
sys_bit="x86_64"
|
||||||
@@ -237,12 +222,12 @@ install_speedtest() {
|
|||||||
sys_bit="armel"
|
sys_bit="armel"
|
||||||
fi
|
fi
|
||||||
[ -z "${sys_bit}" ] && _red "Error: Unsupported system architecture (${sysarch}).\n" && exit 1
|
[ -z "${sys_bit}" ] && _red "Error: Unsupported system architecture (${sysarch}).\n" && exit 1
|
||||||
url1="https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-${sys_bit}.tgz"
|
url1="https://install.speedtest.net/app/cli/ookla-speedtest-1.1.1-linux-${sys_bit}.tgz"
|
||||||
url2="https://dl.lamp.sh/files/ookla-speedtest-1.2.0-linux-${sys_bit}.tgz"
|
url2="https://dl.lamp.sh/files/ookla-speedtest-1.1.1-linux-${sys_bit}.tgz"
|
||||||
if ! wget --no-check-certificate -q -T10 -O speedtest.tgz ${url1}; then
|
wget --no-check-certificate -q -T10 -O speedtest.tgz ${url1}
|
||||||
if ! wget --no-check-certificate -q -T10 -O speedtest.tgz ${url2}; then
|
if [ $? -ne 0 ]; then
|
||||||
_red "Error: Failed to download speedtest-cli.\n" && exit 1
|
wget --no-check-certificate -q -T10 -O speedtest.tgz ${url2}
|
||||||
fi
|
[ $? -ne 0 ] && _red "Error: Failed to download speedtest-cli.\n" && exit 1
|
||||||
fi
|
fi
|
||||||
mkdir -p speedtest-cli && tar zxf speedtest.tgz -C ./speedtest-cli && chmod +x ./speedtest-cli/speedtest
|
mkdir -p speedtest-cli && tar zxf speedtest.tgz -C ./speedtest-cli && chmod +x ./speedtest-cli/speedtest
|
||||||
rm -f speedtest.tgz
|
rm -f speedtest.tgz
|
||||||
@@ -252,72 +237,44 @@ install_speedtest() {
|
|||||||
|
|
||||||
print_intro() {
|
print_intro() {
|
||||||
echo "-------------------- A Bench.sh Script By Teddysun -------------------"
|
echo "-------------------- A Bench.sh Script By Teddysun -------------------"
|
||||||
echo " Version : $(_green v2025-05-08)"
|
echo " Version : $(_green v2023-06-10)"
|
||||||
echo " Usage : $(_red "wget -qO- bench.sh | bash")"
|
echo " Usage : $(_red "wget -qO- bench.sh | bash")"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get System information
|
# Get System information
|
||||||
get_system_info() {
|
get_system_info() {
|
||||||
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
||||||
cores=$(awk -F: '/^processor/ {core++} END {print core}' /proc/cpuinfo)
|
cores=$( awk -F: '/processor/ {core++} END {print core}' /proc/cpuinfo )
|
||||||
freq=$( awk -F'[ :]' '/cpu MHz/ {print $4;exit}' /proc/cpuinfo )
|
freq=$( awk -F'[ :]' '/cpu MHz/ {print $4;exit}' /proc/cpuinfo )
|
||||||
ccache=$( awk -F: '/cache size/ {cache=$2} END {print cache}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
ccache=$( awk -F: '/cache size/ {cache=$2} END {print cache}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
||||||
cpu_aes=$( grep -i 'aes' /proc/cpuinfo )
|
cpu_aes=$( grep -i 'aes' /proc/cpuinfo )
|
||||||
cpu_virt=$( grep -Ei 'vmx|svm' /proc/cpuinfo )
|
cpu_virt=$( grep -Ei 'vmx|svm' /proc/cpuinfo )
|
||||||
tram=$(
|
tram=$( LANG=C; free | awk '/Mem/ {print $2}' )
|
||||||
LANG=C
|
tram=$( calc_size $tram )
|
||||||
free | awk '/Mem/ {print $2}'
|
uram=$( LANG=C; free | awk '/Mem/ {print $3}' )
|
||||||
)
|
uram=$( calc_size $uram )
|
||||||
tram=$(calc_size "$tram")
|
swap=$( LANG=C; free | awk '/Swap/ {print $2}' )
|
||||||
uram=$(
|
swap=$( calc_size $swap )
|
||||||
LANG=C
|
uswap=$( LANG=C; free | awk '/Swap/ {print $3}' )
|
||||||
free | awk '/Mem/ {print $3}'
|
uswap=$( calc_size $uswap )
|
||||||
)
|
|
||||||
uram=$(calc_size "$uram")
|
|
||||||
swap=$(
|
|
||||||
LANG=C
|
|
||||||
free | awk '/Swap/ {print $2}'
|
|
||||||
)
|
|
||||||
swap=$(calc_size "$swap")
|
|
||||||
uswap=$(
|
|
||||||
LANG=C
|
|
||||||
free | awk '/Swap/ {print $3}'
|
|
||||||
)
|
|
||||||
uswap=$(calc_size "$uswap")
|
|
||||||
up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d days, %d hour %d min\n",a,b,c)}' /proc/uptime )
|
up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d days, %d hour %d min\n",a,b,c)}' /proc/uptime )
|
||||||
if _exists "w"; then
|
if _exists "w"; then
|
||||||
load=$(
|
load=$( LANG=C; w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
||||||
LANG=C
|
|
||||||
w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
|
||||||
)
|
|
||||||
elif _exists "uptime"; then
|
elif _exists "uptime"; then
|
||||||
load=$(
|
load=$( LANG=C; uptime | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
||||||
LANG=C
|
|
||||||
uptime | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
|
||||||
)
|
|
||||||
fi
|
fi
|
||||||
opsy=$( get_opsy )
|
opsy=$( get_opsy )
|
||||||
arch=$( uname -m )
|
arch=$( uname -m )
|
||||||
if _exists "getconf"; then
|
if _exists "getconf"; then
|
||||||
lbit=$( getconf LONG_BIT )
|
lbit=$( getconf LONG_BIT )
|
||||||
else
|
else
|
||||||
echo "${arch}" | grep -q "64" && lbit="64" || lbit="32"
|
echo ${arch} | grep -q "64" && lbit="64" || lbit="32"
|
||||||
fi
|
fi
|
||||||
kern=$( uname -r )
|
kern=$( uname -r )
|
||||||
in_kernel_no_swap_total_size=$(
|
disk_total_size=$( LANG=C; df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total 2>/dev/null | grep total | awk '{ print $2 }' )
|
||||||
LANG=C
|
disk_total_size=$( calc_size $disk_total_size )
|
||||||
df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs --total 2>/dev/null | grep total | awk '{ print $2 }'
|
disk_used_size=$( LANG=C; df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total 2>/dev/null | grep total | awk '{ print $3 }' )
|
||||||
)
|
disk_used_size=$( calc_size $disk_used_size )
|
||||||
swap_total_size=$(free -k | grep Swap | awk '{print $2}')
|
|
||||||
zfs_total_size=$(to_kibyte "$(calc_sum "$(zpool list -o size -Hp 2> /dev/null)")")
|
|
||||||
disk_total_size=$(calc_size $((swap_total_size + in_kernel_no_swap_total_size + zfs_total_size)))
|
|
||||||
in_kernel_no_swap_used_size=$(
|
|
||||||
LANG=C
|
|
||||||
df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs --total 2>/dev/null | grep total | awk '{ print $3 }'
|
|
||||||
)
|
|
||||||
swap_used_size=$(free -k | grep Swap | awk '{print $3}')
|
|
||||||
zfs_used_size=$(to_kibyte "$(calc_sum "$(zpool list -o allocated -Hp 2> /dev/null)")")
|
|
||||||
disk_used_size=$(calc_size $((swap_used_size + in_kernel_no_swap_used_size + zfs_used_size)))
|
|
||||||
tcpctrl=$( sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}' )
|
tcpctrl=$( sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}' )
|
||||||
}
|
}
|
||||||
# Print System information
|
# Print System information
|
||||||
@@ -336,14 +293,14 @@ print_system_info() {
|
|||||||
echo " CPU Cache : $(_blue "$ccache")"
|
echo " CPU Cache : $(_blue "$ccache")"
|
||||||
fi
|
fi
|
||||||
if [ -n "$cpu_aes" ]; then
|
if [ -n "$cpu_aes" ]; then
|
||||||
echo " AES-NI : $(_green "\xe2\x9c\x93 Enabled")"
|
echo " AES-NI : $(_green "Enabled")"
|
||||||
else
|
else
|
||||||
echo " AES-NI : $(_red "\xe2\x9c\x97 Disabled")"
|
echo " AES-NI : $(_red "Disabled")"
|
||||||
fi
|
fi
|
||||||
if [ -n "$cpu_virt" ]; then
|
if [ -n "$cpu_virt" ]; then
|
||||||
echo " VM-x/AMD-V : $(_green "\xe2\x9c\x93 Enabled")"
|
echo " VM-x/AMD-V : $(_green "Enabled")"
|
||||||
else
|
else
|
||||||
echo " VM-x/AMD-V : $(_red "\xe2\x9c\x97 Disabled")"
|
echo " VM-x/AMD-V : $(_red "Disabled")"
|
||||||
fi
|
fi
|
||||||
echo " Total Disk : $(_yellow "$disk_total_size") $(_blue "($disk_used_size Used)")"
|
echo " Total Disk : $(_yellow "$disk_total_size") $(_blue "($disk_used_size Used)")"
|
||||||
echo " Total Mem : $(_yellow "$tram") $(_blue "($uram Used)")"
|
echo " Total Mem : $(_yellow "$tram") $(_blue "($uram Used)")"
|
||||||
@@ -365,7 +322,7 @@ print_io_test() {
|
|||||||
if [ -z "${freespace}" ]; then
|
if [ -z "${freespace}" ]; then
|
||||||
freespace=$( df -m . | awk 'NR==3 {print $3}' )
|
freespace=$( df -m . | awk 'NR==3 {print $3}' )
|
||||||
fi
|
fi
|
||||||
if [ "${freespace}" -gt 1024 ]; then
|
if [ ${freespace} -gt 1024 ]; then
|
||||||
writemb=2048
|
writemb=2048
|
||||||
io1=$( io_test ${writemb} )
|
io1=$( io_test ${writemb} )
|
||||||
echo " I/O Speed(1st run) : $(_yellow "$io1")"
|
echo " I/O Speed(1st run) : $(_yellow "$io1")"
|
||||||
@@ -373,14 +330,14 @@ print_io_test() {
|
|||||||
echo " I/O Speed(2nd run) : $(_yellow "$io2")"
|
echo " I/O Speed(2nd run) : $(_yellow "$io2")"
|
||||||
io3=$( io_test ${writemb} )
|
io3=$( io_test ${writemb} )
|
||||||
echo " I/O Speed(3rd run) : $(_yellow "$io3")"
|
echo " I/O Speed(3rd run) : $(_yellow "$io3")"
|
||||||
ioraw1=$(echo "$io1" | awk 'NR==1 {print $1}')
|
ioraw1=$( echo $io1 | awk 'NR==1 {print $1}' )
|
||||||
[[ "$(echo "$io1" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw1=$(awk 'BEGIN{print '"$ioraw1"' * 1024}')
|
[ "`echo $io1 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw1=$( awk 'BEGIN{print '$ioraw1' * 1024}' )
|
||||||
ioraw2=$(echo "$io2" | awk 'NR==1 {print $1}')
|
ioraw2=$( echo $io2 | awk 'NR==1 {print $1}' )
|
||||||
[[ "$(echo "$io2" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw2=$(awk 'BEGIN{print '"$ioraw2"' * 1024}')
|
[ "`echo $io2 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw2=$( awk 'BEGIN{print '$ioraw2' * 1024}' )
|
||||||
ioraw3=$(echo "$io3" | awk 'NR==1 {print $1}')
|
ioraw3=$( echo $io3 | awk 'NR==1 {print $1}' )
|
||||||
[[ "$(echo "$io3" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw3=$(awk 'BEGIN{print '"$ioraw3"' * 1024}')
|
[ "`echo $io3 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw3=$( awk 'BEGIN{print '$ioraw3' * 1024}' )
|
||||||
ioall=$(awk 'BEGIN{print '"$ioraw1"' + '"$ioraw2"' + '"$ioraw3"'}')
|
ioall=$( awk 'BEGIN{print '$ioraw1' + '$ioraw2' + '$ioraw3'}' )
|
||||||
ioavg=$(awk 'BEGIN{printf "%.1f", '"$ioall"' / 3}')
|
ioavg=$( awk 'BEGIN{printf "%.1f", '$ioall' / 3}' )
|
||||||
echo " I/O Speed(average) : $(_yellow "$ioavg MB/s")"
|
echo " I/O Speed(average) : $(_yellow "$ioavg MB/s")"
|
||||||
else
|
else
|
||||||
echo " $(_red "Not enough space for I/O Speed test!")"
|
echo " $(_red "Not enough space for I/O Speed test!")"
|
||||||
@@ -389,10 +346,10 @@ print_io_test() {
|
|||||||
|
|
||||||
print_end_time() {
|
print_end_time() {
|
||||||
end_time=$(date +%s)
|
end_time=$(date +%s)
|
||||||
time=$((end_time - start_time))
|
time=$(( ${end_time} - ${start_time} ))
|
||||||
if [ ${time} -gt 60 ]; then
|
if [ ${time} -gt 60 ]; then
|
||||||
min=$((time / 60))
|
min=$(expr $time / 60)
|
||||||
sec=$((time % 60))
|
sec=$(expr $time % 60)
|
||||||
echo " Finished in : ${min} min ${sec} sec"
|
echo " Finished in : ${min} min ${sec} sec"
|
||||||
else
|
else
|
||||||
echo " Finished in : ${time} sec"
|
echo " Finished in : ${time} sec"
|
||||||
@@ -404,16 +361,16 @@ print_end_time() {
|
|||||||
! _exists "wget" && _red "Error: wget command not found.\n" && exit 1
|
! _exists "wget" && _red "Error: wget command not found.\n" && exit 1
|
||||||
! _exists "free" && _red "Error: free command not found.\n" && exit 1
|
! _exists "free" && _red "Error: free command not found.\n" && exit 1
|
||||||
# check for curl/wget
|
# check for curl/wget
|
||||||
_exists "curl" && local_curl=true
|
command -v curl >/dev/null 2>&1 && local_curl=true || unset local_curl
|
||||||
# test if the host has IPv4/IPv6 connectivity
|
# test if the host has IPv4/IPv6 connectivity
|
||||||
[[ -n ${local_curl} ]] && ip_check_cmd="curl -s -m 4" || ip_check_cmd="wget -qO- -T 4"
|
[[ ! -z ${local_curl} ]] && ip_check_cmd="curl -s -m 4" || ip_check_cmd="wget -qO- -T 4"
|
||||||
ipv4_check=$((ping -4 -c 1 -W 4 ipv4.google.com >/dev/null 2>&1 && echo true) || ${ip_check_cmd} -4 icanhazip.com 2> /dev/null)
|
ipv4_check=$((ping -4 -c 1 -W 4 ipv4.google.com >/dev/null 2>&1 && echo true) || ${ip_check_cmd} -4 icanhazip.com 2> /dev/null)
|
||||||
ipv6_check=$((ping -6 -c 1 -W 4 ipv6.google.com >/dev/null 2>&1 && echo true) || ${ip_check_cmd} -6 icanhazip.com 2> /dev/null)
|
ipv6_check=$((ping -6 -c 1 -W 4 ipv6.google.com >/dev/null 2>&1 && echo true) || ${ip_check_cmd} -6 icanhazip.com 2> /dev/null)
|
||||||
if [[ -z "$ipv4_check" && -z "$ipv6_check" ]]; then
|
if [[ -z "$ipv4_check" && -z "$ipv6_check" ]]; then
|
||||||
_yellow "Warning: Both IPv4 and IPv6 connectivity were not detected.\n"
|
_yellow "Warning: Both IPv4 and IPv6 connectivity were not detected.\n"
|
||||||
fi
|
fi
|
||||||
[[ -z "$ipv4_check" ]] && online="$(_red "\xe2\x9c\x97 Offline")" || online="$(_green "\xe2\x9c\x93 Online")"
|
[[ -z "$ipv4_check" ]] && online="$(_red "Offline")" || online="$(_green "Online")"
|
||||||
[[ -z "$ipv6_check" ]] && online+=" / $(_red "\xe2\x9c\x97 Offline")" || online+=" / $(_green "\xe2\x9c\x93 Online")"
|
[[ -z "$ipv6_check" ]] && online+=" / $(_red "Offline")" || online+=" / $(_green "Online")"
|
||||||
start_time=$(date +%s)
|
start_time=$(date +%s)
|
||||||
get_system_info
|
get_system_info
|
||||||
check_virt
|
check_virt
|
||||||
|
@@ -1,99 +0,0 @@
|
|||||||
ARCH=$(shell uname -m)
|
|
||||||
VERSION?=1.8.15
|
|
||||||
GO_VERSION:=1.22.5
|
|
||||||
SHELL:=/bin/bash
|
|
||||||
GO_BASE_IMAGE=golang
|
|
||||||
GO_IMAGE?=$(GO_BASE_IMAGE):$(GO_VERSION)-bookworm
|
|
||||||
EPOCH?=
|
|
||||||
REPO?=https://github.com/teddysun/xray-plugin.git
|
|
||||||
REF?=v1.8.15
|
|
||||||
CHOWN:=docker run --rm -v $(CURDIR):/v -w /v alpine chown
|
|
||||||
|
|
||||||
ifdef BUILD_IMAGE
|
|
||||||
BUILD_IMAGE_FLAG=--build-arg $(BUILD_IMAGE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
COMMON_FILES=common
|
|
||||||
BUILD?=DOCKER_BUILDKIT=1 \
|
|
||||||
docker build \
|
|
||||||
$(BUILD_IMAGE_FLAG) \
|
|
||||||
--build-arg GO_IMAGE=$(GO_IMAGE) \
|
|
||||||
--build-arg COMMON_FILES=$(COMMON_FILES) \
|
|
||||||
-t debbuild-$@/$(ARCH) \
|
|
||||||
-f $@/Dockerfile \
|
|
||||||
.
|
|
||||||
|
|
||||||
# Additional flags may be necessary at some point
|
|
||||||
RUN_FLAGS=
|
|
||||||
RUN?=docker run --rm -h buildbot \
|
|
||||||
-e PLATFORM \
|
|
||||||
-e EPOCH='$(EPOCH)' \
|
|
||||||
-e DEB_VERSION=$(VERSION) \
|
|
||||||
-e VERSION=$(VERSION) \
|
|
||||||
-v $(CURDIR)/debbuild/$@:/build \
|
|
||||||
$(RUN_FLAGS) \
|
|
||||||
debbuild-$@/$(ARCH)
|
|
||||||
|
|
||||||
DEBIAN_VERSIONS ?= debian-buster debian-bullseye debian-bookworm
|
|
||||||
UBUNTU_VERSIONS ?= ubuntu-focal ubuntu-jammy ubuntu-noble
|
|
||||||
DISTROS := $(DEBIAN_VERSIONS) $(UBUNTU_VERSIONS)
|
|
||||||
|
|
||||||
# Taken from: https://www.cmcrossroads.com/article/printing-value-makefile-variable
|
|
||||||
print-% : ; @echo $($*)
|
|
||||||
|
|
||||||
.PHONY: help
|
|
||||||
help: ## show make targets
|
|
||||||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
|
||||||
|
|
||||||
.PHONY: checkout-src
|
|
||||||
checkout-src: src/github.com/teddysun/xray-plugin
|
|
||||||
./checkout.sh src/github.com/teddysun/xray-plugin "$(REF)"
|
|
||||||
|
|
||||||
src/github.com/teddysun/xray-plugin:
|
|
||||||
git init $@
|
|
||||||
git -C $@ remote add origin "$(REPO)"
|
|
||||||
|
|
||||||
.PHONY: checkout
|
|
||||||
checkout: checkout-src ## checkout source at the given reference(s)
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean: ## remove build artifacts
|
|
||||||
[ ! -d debbuild ] || $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild
|
|
||||||
$(RM) -r debbuild
|
|
||||||
[ ! -d sources ] || $(CHOWN) -R $(shell id -u):$(shell id -g) sources
|
|
||||||
$(RM) -r sources
|
|
||||||
-docker builder prune -f --filter until=24h
|
|
||||||
|
|
||||||
.PHONY: deb
|
|
||||||
deb: ubuntu debian ## build all deb packages
|
|
||||||
|
|
||||||
.PHONY: ubuntu
|
|
||||||
ubuntu: $(UBUNTU_VERSIONS) ## build all ubuntu deb packages
|
|
||||||
|
|
||||||
.PHONY: debian
|
|
||||||
debian: $(DEBIAN_VERSIONS) ## build all debian deb packages
|
|
||||||
|
|
||||||
.PHONY: $(DISTROS)
|
|
||||||
$(DISTROS): sources
|
|
||||||
@echo "== Building packages for $@ =="
|
|
||||||
mkdir -p "debbuild/$@"
|
|
||||||
$(BUILD)
|
|
||||||
$(RUN)
|
|
||||||
$(CHOWN) -R $(shell id -u):$(shell id -g) "debbuild/$@"
|
|
||||||
|
|
||||||
.PHONY: sources
|
|
||||||
sources: sources/xray-plugin.tgz
|
|
||||||
|
|
||||||
sources/xray-plugin.tgz:
|
|
||||||
mkdir -p $(@D)
|
|
||||||
docker run --rm -w /v \
|
|
||||||
-v $(realpath $(CURDIR)/src/github.com/teddysun/xray-plugin):/xray-plugin \
|
|
||||||
-v $(CURDIR)/$(@D):/v \
|
|
||||||
alpine \
|
|
||||||
tar -C / -c -z -f /v/xray-plugin.tgz --exclude .git xray-plugin
|
|
||||||
|
|
||||||
# See ARCHES in common.mk. Could not figure out how to match both distro and arch.
|
|
||||||
BUNDLES:=$(addsuffix .tar.gz,$(addprefix debbuild/bundles-%-,$(ARCHES)))
|
|
||||||
|
|
||||||
$(BUNDLES): %
|
|
||||||
tar czf $@ --transform="s|^debbuild/\(.*\)|bundles/$(VERSION)/build-deb/\1|" debbuild/$*
|
|
@@ -1,74 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -x
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# untar sources
|
|
||||||
mkdir -p /root/build-deb/xray-plugin
|
|
||||||
tar -C /root/build-deb -xzf /sources/xray-plugin.tgz
|
|
||||||
|
|
||||||
# link them to their canonical path
|
|
||||||
mkdir -p /go/src/github.com/teddysun
|
|
||||||
ln -snf /root/build-deb/xray-plugin /go/src/github.com/teddysun/xray-plugin
|
|
||||||
|
|
||||||
EPOCH="${EPOCH:-}"
|
|
||||||
EPOCH_SEP=""
|
|
||||||
if [[ -n "$EPOCH" ]]; then
|
|
||||||
EPOCH_SEP=":"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${DEB_VERSION}" ]]; then
|
|
||||||
echo "DEB_VERSION is required to build deb packages"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo VERSION AAA ${VERSION}
|
|
||||||
|
|
||||||
VERSION=${VERSION:-$(cat VERSION)}
|
|
||||||
|
|
||||||
debSource="$(awk -F ': ' '$1 == "Source" { print $2; exit }' debian/control)"
|
|
||||||
debMaintainer="$(awk -F ': ' '$1 == "Maintainer" { print $2; exit }' debian/control)"
|
|
||||||
debDate="$(date --rfc-2822)"
|
|
||||||
|
|
||||||
# Include an extra `1` in the version, in case we ever would have to re-build an
|
|
||||||
# already published release with a packaging-only change.
|
|
||||||
pkgRevision=1
|
|
||||||
|
|
||||||
# Generate changelog. The version/name of the generated packages are based on this.
|
|
||||||
#
|
|
||||||
# Resulting packages are formatted as;
|
|
||||||
#
|
|
||||||
# - name of the package (e.g., "docker-ce")
|
|
||||||
# - version (e.g., "23.0.0~beta.0")
|
|
||||||
# - pkgRevision (usually "-0", see above), which allows updating packages with
|
|
||||||
# packaging-only changes (without a corresponding release of the software
|
|
||||||
# that's packaged).
|
|
||||||
# - distro (e.g., "ubuntu")
|
|
||||||
# - VERSION_ID (e.g. "22.04" or "11") this must be "sortable" to make sure that
|
|
||||||
# packages are upgraded when upgrading to a newer distro version ("codename"
|
|
||||||
# cannot be used for this, as they're not sorted)
|
|
||||||
# - SUITE ("codename"), e.g. "jammy" or "bullseye". This is mostly for convenience,
|
|
||||||
# because some places refer to distro versions by codename, others by version.
|
|
||||||
# we prefix the codename with a tilde (~), which effectively excludes it from
|
|
||||||
# version comparison.
|
|
||||||
#
|
|
||||||
# Note that while the `${EPOCH}${EPOCH_SEP}` is part of the version, it is not
|
|
||||||
# included in the package's *filename*. (And if you're wondering: we needed the
|
|
||||||
# EPOCH because of our use of CalVer, which made version comparing not work in
|
|
||||||
# some cases).
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
#
|
|
||||||
# docker-ce_23.0.0~beta.0-1~debian.11~bullseye_amd64.deb
|
|
||||||
# docker-ce_23.0.0~beta.0-1~ubuntu.22.04~jammy_amd64.deb
|
|
||||||
cat > "debian/changelog" <<-EOF
|
|
||||||
$debSource (${EPOCH}${EPOCH_SEP}${DEB_VERSION}-${pkgRevision}~${DISTRO}.${VERSION_ID}~${SUITE}) $SUITE; urgency=low
|
|
||||||
* Version: ${VERSION}
|
|
||||||
-- $debMaintainer $debDate
|
|
||||||
EOF
|
|
||||||
# The space above at the start of the line for the debMaintainer is very important
|
|
||||||
|
|
||||||
echo VERSION BBB ${VERSION}
|
|
||||||
dpkg-buildpackage -uc -us -I.git
|
|
||||||
destination="/build"
|
|
||||||
mkdir -p "$destination"
|
|
||||||
mv -v /root/xray-plugin* "$destination"
|
|
@@ -1,39 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
# Copyright 2018-2020 Docker Inc.
|
|
||||||
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
checkout() (
|
|
||||||
set -ex
|
|
||||||
SRC="$1"
|
|
||||||
REF="$2"
|
|
||||||
REF_FETCH="$REF"
|
|
||||||
# if ref is branch or tag, retrieve its canonical form
|
|
||||||
REF=$(git -C "$SRC" ls-remote --refs --heads --tags origin "$REF" | awk '{print $2}')
|
|
||||||
if [ -n "$REF" ]; then
|
|
||||||
# if branch or tag then create it locally too
|
|
||||||
REF_FETCH="$REF:$REF"
|
|
||||||
else
|
|
||||||
REF="FETCH_HEAD"
|
|
||||||
fi
|
|
||||||
git -C "$SRC" fetch --update-head-ok --depth 1 origin "$REF_FETCH"
|
|
||||||
git -C "$SRC" checkout -q "$REF"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Only execute checkout function above if this file is executed, not sourced from another script
|
|
||||||
prog=checkout.sh # needs to be in sync with this file's name
|
|
||||||
if [ "$(basename -- $0)" = "$prog" ]; then
|
|
||||||
checkout $*
|
|
||||||
fi
|
|
@@ -1,29 +0,0 @@
|
|||||||
Source: xray-plugin
|
|
||||||
Section: devel
|
|
||||||
Priority: optional
|
|
||||||
Maintainer: Teddysun <i@teddysun.com>
|
|
||||||
Build-Depends: bash,
|
|
||||||
cmake,
|
|
||||||
dh-apparmor,
|
|
||||||
debhelper-compat (= 12),
|
|
||||||
gcc,
|
|
||||||
git,
|
|
||||||
libc-dev,
|
|
||||||
libltdl-dev,
|
|
||||||
libseccomp-dev,
|
|
||||||
libseccomp2,
|
|
||||||
libsystemd-dev,
|
|
||||||
libtool,
|
|
||||||
make,
|
|
||||||
pkg-config
|
|
||||||
Standards-Version: 3.9.6
|
|
||||||
Homepage: https://github.com/teddysun/xray-plugin
|
|
||||||
Vcs-Browser: https://github.com/teddysun/xray-plugin
|
|
||||||
Vcs-Git: git://github.com/teddysun/xray-plugin.git
|
|
||||||
|
|
||||||
Package: xray-plugin
|
|
||||||
Architecture: linux-any
|
|
||||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
|
||||||
Description: Xray plugin for shadowsocks
|
|
||||||
Yet another SIP003 plugin for shadowsocks, based on xray-core.
|
|
||||||
It should be used with shadowsocks.
|
|
@@ -1 +0,0 @@
|
|||||||
xray-plugin/README.md
|
|
@@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/make -f
|
|
||||||
|
|
||||||
VERSION?=$(shell cat VERSION)
|
|
||||||
|
|
||||||
# force packages to be built with xz compression, as Ubuntu 21.10 and up use
|
|
||||||
# zstd compression, which is non-standard, and breaks 'dpkg-sig --verify'
|
|
||||||
override_dh_builddeb:
|
|
||||||
dh_builddeb -- -Zxz
|
|
||||||
|
|
||||||
override_dh_auto_build:
|
|
||||||
cd xray-plugin \
|
|
||||||
&& GO111MODULE=on \
|
|
||||||
env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VERSION=v$(VERSION) -s -w -buildid=" -o "xray-plugin"
|
|
||||||
|
|
||||||
# http://manpages.debian.org/dh_dwz
|
|
||||||
override_dh_dwz:
|
|
||||||
# dh_dwz in debhelper versions less than 13 has issues with files that are missing debug symbols (once we update to debhelper-compat 13+ this can be removed)
|
|
||||||
@# https://packages.debian.org/debhelper
|
|
||||||
@# https://packages.ubuntu.com/debhelper
|
|
||||||
|
|
||||||
override_dh_auto_install:
|
|
||||||
install -D -m 0755 xray-plugin/xray-plugin debian/xray-plugin/usr/bin/xray-plugin
|
|
||||||
|
|
||||||
override_dh_shlibdeps:
|
|
||||||
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
|
|
||||||
|
|
||||||
%:
|
|
||||||
dh $@
|
|
@@ -1 +0,0 @@
|
|||||||
1.0
|
|
@@ -1,40 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=debian
|
|
||||||
ARG SUITE=bookworm
|
|
||||||
ARG VERSION_ID=12
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,40 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=debian
|
|
||||||
ARG SUITE=bullseye
|
|
||||||
ARG VERSION_ID=11
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,40 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=debian
|
|
||||||
ARG SUITE=buster
|
|
||||||
ARG VERSION_ID=10
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,46 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=ubuntu
|
|
||||||
ARG SUITE=focal
|
|
||||||
ARG VERSION_ID=20.04
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
# Remove diverted man binary to prevent man-pages being replaced with "minimized" message. See docker/for-linux#639
|
|
||||||
RUN if [ "$(dpkg-divert --truename /usr/bin/man)" = "/usr/bin/man.REAL" ]; then \
|
|
||||||
rm -f /usr/bin/man; \
|
|
||||||
dpkg-divert --quiet --remove --rename /usr/bin/man; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,46 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=ubuntu
|
|
||||||
ARG SUITE=jammy
|
|
||||||
ARG VERSION_ID=22.04
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
# Remove diverted man binary to prevent man-pages being replaced with "minimized" message. See docker/for-linux#639
|
|
||||||
RUN if [ "$(dpkg-divert --truename /usr/bin/man)" = "/usr/bin/man.REAL" ]; then \
|
|
||||||
rm -f /usr/bin/man; \
|
|
||||||
dpkg-divert --quiet --remove --rename /usr/bin/man; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,46 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=ubuntu
|
|
||||||
ARG SUITE=noble
|
|
||||||
ARG VERSION_ID=24.04
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
# Remove diverted man binary to prevent man-pages being replaced with "minimized" message. See docker/for-linux#639
|
|
||||||
RUN if [ "$(dpkg-divert --truename /usr/bin/man)" = "/usr/bin/man.REAL" ]; then \
|
|
||||||
rm -f /usr/bin/man; \
|
|
||||||
dpkg-divert --quiet --remove --rename /usr/bin/man; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,101 +0,0 @@
|
|||||||
ARCH=$(shell uname -m)
|
|
||||||
VERSION?=24.11.30
|
|
||||||
GO_VERSION:=1.23.3
|
|
||||||
SHELL:=/bin/bash
|
|
||||||
GO_BASE_IMAGE=golang
|
|
||||||
GO_IMAGE?=$(GO_BASE_IMAGE):$(GO_VERSION)-bookworm
|
|
||||||
EPOCH?=
|
|
||||||
REPO?=https://github.com/xtls/xray-core.git
|
|
||||||
REF?=v24.11.30
|
|
||||||
CHOWN:=docker run --rm -v $(CURDIR):/v -w /v alpine chown
|
|
||||||
|
|
||||||
ifdef BUILD_IMAGE
|
|
||||||
BUILD_IMAGE_FLAG=--build-arg $(BUILD_IMAGE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
COMMON_FILES=common
|
|
||||||
BUILD?=DOCKER_BUILDKIT=1 \
|
|
||||||
docker build \
|
|
||||||
$(BUILD_IMAGE_FLAG) \
|
|
||||||
--build-arg GO_IMAGE=$(GO_IMAGE) \
|
|
||||||
--build-arg COMMON_FILES=$(COMMON_FILES) \
|
|
||||||
-t debbuild-$@/$(ARCH) \
|
|
||||||
-f $@/Dockerfile \
|
|
||||||
.
|
|
||||||
|
|
||||||
# Additional flags may be necessary at some point
|
|
||||||
RUN_FLAGS=
|
|
||||||
RUN?=docker run --rm -h buildbot \
|
|
||||||
-e PLATFORM \
|
|
||||||
-e EPOCH='$(EPOCH)' \
|
|
||||||
-e DEB_VERSION=$(VERSION) \
|
|
||||||
-e VERSION=$(VERSION) \
|
|
||||||
-v $(CURDIR)/debbuild/$@:/build \
|
|
||||||
$(RUN_FLAGS) \
|
|
||||||
debbuild-$@/$(ARCH)
|
|
||||||
|
|
||||||
DEBIAN_VERSIONS ?= debian-buster debian-bullseye debian-bookworm
|
|
||||||
UBUNTU_VERSIONS ?= ubuntu-focal ubuntu-jammy ubuntu-noble
|
|
||||||
DISTROS := $(DEBIAN_VERSIONS) $(UBUNTU_VERSIONS)
|
|
||||||
|
|
||||||
# Taken from: https://www.cmcrossroads.com/article/printing-value-makefile-variable
|
|
||||||
print-% : ; @echo $($*)
|
|
||||||
|
|
||||||
.PHONY: help
|
|
||||||
help: ## show make targets
|
|
||||||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
|
||||||
|
|
||||||
.PHONY: checkout-src
|
|
||||||
checkout-src: src/github.com/xtls/xray
|
|
||||||
../checkout.sh src/github.com/xtls/xray "$(REF)"
|
|
||||||
@curl -sSLo src/github.com/xtls/xray/geoip.dat https://github.com/v2fly/geoip/releases/latest/download/geoip.dat
|
|
||||||
@curl -sSLo src/github.com/xtls/xray/geosite.dat https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat
|
|
||||||
|
|
||||||
src/github.com/xtls/xray:
|
|
||||||
git init $@
|
|
||||||
git -C $@ remote add origin "$(REPO)"
|
|
||||||
|
|
||||||
.PHONY: checkout
|
|
||||||
checkout: checkout-src ## checkout source at the given reference(s)
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean: ## remove build artifacts
|
|
||||||
[ ! -d debbuild ] || $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild
|
|
||||||
$(RM) -r debbuild
|
|
||||||
[ ! -d sources ] || $(CHOWN) -R $(shell id -u):$(shell id -g) sources
|
|
||||||
$(RM) -r sources
|
|
||||||
-docker builder prune -f --filter until=24h
|
|
||||||
|
|
||||||
.PHONY: deb
|
|
||||||
deb: ubuntu debian ## build all deb packages
|
|
||||||
|
|
||||||
.PHONY: ubuntu
|
|
||||||
ubuntu: $(UBUNTU_VERSIONS) ## build all ubuntu deb packages
|
|
||||||
|
|
||||||
.PHONY: debian
|
|
||||||
debian: $(DEBIAN_VERSIONS) ## build all debian deb packages
|
|
||||||
|
|
||||||
.PHONY: $(DISTROS)
|
|
||||||
$(DISTROS): sources
|
|
||||||
@echo "== Building packages for $@ =="
|
|
||||||
mkdir -p "debbuild/$@"
|
|
||||||
$(BUILD)
|
|
||||||
$(RUN)
|
|
||||||
$(CHOWN) -R $(shell id -u):$(shell id -g) "debbuild/$@"
|
|
||||||
|
|
||||||
.PHONY: sources
|
|
||||||
sources: sources/xray.tgz
|
|
||||||
|
|
||||||
sources/xray.tgz:
|
|
||||||
mkdir -p $(@D)
|
|
||||||
docker run --rm -w /v \
|
|
||||||
-v $(realpath $(CURDIR)/src/github.com/xtls/xray):/xray \
|
|
||||||
-v $(CURDIR)/$(@D):/v \
|
|
||||||
alpine \
|
|
||||||
tar -C / -c -z -f /v/xray.tgz --exclude .git xray
|
|
||||||
|
|
||||||
# See ARCHES in common.mk. Could not figure out how to match both distro and arch.
|
|
||||||
BUNDLES:=$(addsuffix .tar.gz,$(addprefix debbuild/bundles-%-,$(ARCHES)))
|
|
||||||
|
|
||||||
$(BUNDLES): %
|
|
||||||
tar czf $@ --transform="s|^debbuild/\(.*\)|bundles/$(VERSION)/build-deb/\1|" debbuild/$*
|
|
@@ -1,74 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -x
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# untar sources
|
|
||||||
mkdir -p /root/build-deb/xray
|
|
||||||
tar -C /root/build-deb -xzf /sources/xray.tgz
|
|
||||||
|
|
||||||
# link them to their canonical path
|
|
||||||
mkdir -p /go/src/github.com/xtls
|
|
||||||
ln -snf /root/build-deb/xray /go/src/github.com/xtls/xray-core
|
|
||||||
|
|
||||||
EPOCH="${EPOCH:-}"
|
|
||||||
EPOCH_SEP=""
|
|
||||||
if [[ -n "$EPOCH" ]]; then
|
|
||||||
EPOCH_SEP=":"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${DEB_VERSION}" ]]; then
|
|
||||||
echo "DEB_VERSION is required to build deb packages"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo VERSION AAA ${VERSION}
|
|
||||||
|
|
||||||
VERSION=${VERSION:-$(cat VERSION)}
|
|
||||||
|
|
||||||
debSource="$(awk -F ': ' '$1 == "Source" { print $2; exit }' debian/control)"
|
|
||||||
debMaintainer="$(awk -F ': ' '$1 == "Maintainer" { print $2; exit }' debian/control)"
|
|
||||||
debDate="$(date --rfc-2822)"
|
|
||||||
|
|
||||||
# Include an extra `1` in the version, in case we ever would have to re-build an
|
|
||||||
# already published release with a packaging-only change.
|
|
||||||
pkgRevision=1
|
|
||||||
|
|
||||||
# Generate changelog. The version/name of the generated packages are based on this.
|
|
||||||
#
|
|
||||||
# Resulting packages are formatted as;
|
|
||||||
#
|
|
||||||
# - name of the package (e.g., "docker-ce")
|
|
||||||
# - version (e.g., "23.0.0~beta.0")
|
|
||||||
# - pkgRevision (usually "-0", see above), which allows updating packages with
|
|
||||||
# packaging-only changes (without a corresponding release of the software
|
|
||||||
# that's packaged).
|
|
||||||
# - distro (e.g., "ubuntu")
|
|
||||||
# - VERSION_ID (e.g. "22.04" or "11") this must be "sortable" to make sure that
|
|
||||||
# packages are upgraded when upgrading to a newer distro version ("codename"
|
|
||||||
# cannot be used for this, as they're not sorted)
|
|
||||||
# - SUITE ("codename"), e.g. "jammy" or "bullseye". This is mostly for convenience,
|
|
||||||
# because some places refer to distro versions by codename, others by version.
|
|
||||||
# we prefix the codename with a tilde (~), which effectively excludes it from
|
|
||||||
# version comparison.
|
|
||||||
#
|
|
||||||
# Note that while the `${EPOCH}${EPOCH_SEP}` is part of the version, it is not
|
|
||||||
# included in the package's *filename*. (And if you're wondering: we needed the
|
|
||||||
# EPOCH because of our use of CalVer, which made version comparing not work in
|
|
||||||
# some cases).
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
#
|
|
||||||
# docker-ce_23.0.0~beta.0-1~debian.11~bullseye_amd64.deb
|
|
||||||
# docker-ce_23.0.0~beta.0-1~ubuntu.22.04~jammy_amd64.deb
|
|
||||||
cat > "debian/changelog" <<-EOF
|
|
||||||
$debSource (${EPOCH}${EPOCH_SEP}${DEB_VERSION}-${pkgRevision}~${DISTRO}.${VERSION_ID}~${SUITE}) $SUITE; urgency=low
|
|
||||||
* Version: ${VERSION}
|
|
||||||
-- $debMaintainer $debDate
|
|
||||||
EOF
|
|
||||||
# The space above at the start of the line for the debMaintainer is very important
|
|
||||||
|
|
||||||
echo VERSION BBB ${VERSION}
|
|
||||||
dpkg-buildpackage -uc -us -I.git
|
|
||||||
destination="/build"
|
|
||||||
mkdir -p "$destination"
|
|
||||||
mv -v /root/xray* "$destination"
|
|
@@ -1,39 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
# Copyright 2018-2020 Docker Inc.
|
|
||||||
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
checkout() (
|
|
||||||
set -ex
|
|
||||||
SRC="$1"
|
|
||||||
REF="$2"
|
|
||||||
REF_FETCH="$REF"
|
|
||||||
# if ref is branch or tag, retrieve its canonical form
|
|
||||||
REF=$(git -C "$SRC" ls-remote --refs --heads --tags origin "$REF" | awk '{print $2}')
|
|
||||||
if [ -n "$REF" ]; then
|
|
||||||
# if branch or tag then create it locally too
|
|
||||||
REF_FETCH="$REF:$REF"
|
|
||||||
else
|
|
||||||
REF="FETCH_HEAD"
|
|
||||||
fi
|
|
||||||
git -C "$SRC" fetch --update-head-ok --depth 1 origin "$REF_FETCH"
|
|
||||||
git -C "$SRC" checkout -q "$REF"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Only execute checkout function above if this file is executed, not sourced from another script
|
|
||||||
prog=checkout.sh # needs to be in sync with this file's name
|
|
||||||
if [ "$(basename -- $0)" = "$prog" ]; then
|
|
||||||
checkout $*
|
|
||||||
fi
|
|
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"inbounds": [{
|
|
||||||
"port": 9000,
|
|
||||||
"protocol": "vmess",
|
|
||||||
"settings": {
|
|
||||||
"clients": [
|
|
||||||
{
|
|
||||||
"id": "1eb6e917-774b-4a84-aff6-b058577c60a5",
|
|
||||||
"level": 1,
|
|
||||||
"alterId": 64
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
"outbounds": [{
|
|
||||||
"protocol": "freedom",
|
|
||||||
"settings": {}
|
|
||||||
}]
|
|
||||||
}
|
|
@@ -1,29 +0,0 @@
|
|||||||
Source: xray
|
|
||||||
Section: net
|
|
||||||
Priority: optional
|
|
||||||
Maintainer: Teddysun <i@teddysun.com>
|
|
||||||
Build-Depends: bash,
|
|
||||||
cmake,
|
|
||||||
dh-apparmor,
|
|
||||||
debhelper-compat (= 12),
|
|
||||||
gcc,
|
|
||||||
git,
|
|
||||||
libc-dev,
|
|
||||||
libltdl-dev,
|
|
||||||
libseccomp-dev,
|
|
||||||
libseccomp2,
|
|
||||||
libsystemd-dev,
|
|
||||||
libtool,
|
|
||||||
make,
|
|
||||||
pkg-config
|
|
||||||
Standards-Version: 3.9.6
|
|
||||||
Homepage: https://github.com/xtls/xray-core
|
|
||||||
Rules-Requires-Root: no
|
|
||||||
Vcs-Browser: https://github.com/xtls/xray-core
|
|
||||||
Vcs-Git: git://github.com/xtls/xray-core.git
|
|
||||||
|
|
||||||
Package: xray
|
|
||||||
Architecture: linux-any
|
|
||||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
|
||||||
Description: Xray, Penetrates Everything.
|
|
||||||
Also the best v2ray-core, with XTLS support. Fully compatible configuration.
|
|
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/make -f
|
|
||||||
|
|
||||||
# force packages to be built with xz compression, as Ubuntu 21.10 and up use
|
|
||||||
# zstd compression, which is non-standard, and breaks 'dpkg-sig --verify'
|
|
||||||
override_dh_builddeb:
|
|
||||||
dh_builddeb -- -Zxz
|
|
||||||
|
|
||||||
override_dh_auto_build:
|
|
||||||
cd xray \
|
|
||||||
&& GO111MODULE=on \
|
|
||||||
env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w -buildid=" -o "xray" ./main
|
|
||||||
|
|
||||||
# http://manpages.debian.org/dh_dwz
|
|
||||||
override_dh_dwz:
|
|
||||||
# dh_dwz in debhelper versions less than 13 has issues with files that are missing debug symbols (once we update to debhelper-compat 13+ this can be removed)
|
|
||||||
@# https://packages.debian.org/debhelper
|
|
||||||
@# https://packages.ubuntu.com/debhelper
|
|
||||||
|
|
||||||
override_dh_auto_install:
|
|
||||||
install -D -m 0644 debian/config.json debian/xray/etc/xray/config.json
|
|
||||||
install -D -m 0755 xray/xray debian/xray/usr/bin/xray
|
|
||||||
install -D -m 0644 xray/geoip.dat debian/xray/usr/share/xray/geoip.dat
|
|
||||||
install -D -m 0644 xray/geosite.dat debian/xray/usr/share/xray/geosite.dat
|
|
||||||
|
|
||||||
override_dh_installsystemd:
|
|
||||||
dh_installsystemd --no-enable --no-start
|
|
||||||
|
|
||||||
override_dh_shlibdeps:
|
|
||||||
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
|
|
||||||
|
|
||||||
%:
|
|
||||||
dh $@
|
|
@@ -1 +0,0 @@
|
|||||||
1.0
|
|
@@ -1 +0,0 @@
|
|||||||
xray/README.md
|
|
@@ -1,17 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Xray Service
|
|
||||||
Documentation=https://github.com/xtls
|
|
||||||
After=network.target nss-lookup.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
|
||||||
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
|
||||||
NoNewPrivileges=true
|
|
||||||
ExecStart=/usr/bin/xray run -config /etc/xray/config.json
|
|
||||||
Restart=on-failure
|
|
||||||
RestartPreventExitStatus=23
|
|
||||||
LimitNPROC=10000
|
|
||||||
LimitNOFILE=1000000
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@@ -1,17 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Xray Service
|
|
||||||
Documentation=https://github.com/xtls
|
|
||||||
After=network.target nss-lookup.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
|
||||||
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
|
||||||
NoNewPrivileges=true
|
|
||||||
ExecStart=/usr/bin/xray run -config /etc/xray/%i.json
|
|
||||||
Restart=on-failure
|
|
||||||
RestartPreventExitStatus=23
|
|
||||||
LimitNPROC=10000
|
|
||||||
LimitNOFILE=1000000
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@@ -1,40 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=debian
|
|
||||||
ARG SUITE=bookworm
|
|
||||||
ARG VERSION_ID=12
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,40 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=debian
|
|
||||||
ARG SUITE=bullseye
|
|
||||||
ARG VERSION_ID=11
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,40 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=debian
|
|
||||||
ARG SUITE=buster
|
|
||||||
ARG VERSION_ID=10
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,46 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=ubuntu
|
|
||||||
ARG SUITE=focal
|
|
||||||
ARG VERSION_ID=20.04
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
# Remove diverted man binary to prevent man-pages being replaced with "minimized" message. See docker/for-linux#639
|
|
||||||
RUN if [ "$(dpkg-divert --truename /usr/bin/man)" = "/usr/bin/man.REAL" ]; then \
|
|
||||||
rm -f /usr/bin/man; \
|
|
||||||
dpkg-divert --quiet --remove --rename /usr/bin/man; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,46 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=ubuntu
|
|
||||||
ARG SUITE=jammy
|
|
||||||
ARG VERSION_ID=22.04
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
# Remove diverted man binary to prevent man-pages being replaced with "minimized" message. See docker/for-linux#639
|
|
||||||
RUN if [ "$(dpkg-divert --truename /usr/bin/man)" = "/usr/bin/man.REAL" ]; then \
|
|
||||||
rm -f /usr/bin/man; \
|
|
||||||
dpkg-divert --quiet --remove --rename /usr/bin/man; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,46 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
ARG GO_IMAGE
|
|
||||||
ARG DISTRO=ubuntu
|
|
||||||
ARG SUITE=noble
|
|
||||||
ARG VERSION_ID=24.04
|
|
||||||
ARG BUILD_IMAGE=${DISTRO}:${SUITE}
|
|
||||||
|
|
||||||
FROM ${GO_IMAGE} AS golang
|
|
||||||
|
|
||||||
FROM ${BUILD_IMAGE}
|
|
||||||
|
|
||||||
# Remove diverted man binary to prevent man-pages being replaced with "minimized" message. See docker/for-linux#639
|
|
||||||
RUN if [ "$(dpkg-divert --truename /usr/bin/man)" = "/usr/bin/man.REAL" ]; then \
|
|
||||||
rm -f /usr/bin/man; \
|
|
||||||
dpkg-divert --quiet --remove --rename /usr/bin/man; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
RUN apt-get update && apt-get install -y curl devscripts equivs git
|
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.org|direct
|
|
||||||
ENV GO111MODULE=off
|
|
||||||
ENV GOPATH=/go
|
|
||||||
ENV GOTOOLCHAIN=local
|
|
||||||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
|
|
||||||
ARG COMMON_FILES
|
|
||||||
COPY --link ${COMMON_FILES} /root/build-deb/debian
|
|
||||||
RUN apt-get update \
|
|
||||||
&& mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control
|
|
||||||
|
|
||||||
COPY --link sources/ /sources
|
|
||||||
ARG DISTRO
|
|
||||||
ARG SUITE
|
|
||||||
ARG VERSION_ID
|
|
||||||
ENV DISTRO=${DISTRO}
|
|
||||||
ENV SUITE=${SUITE}
|
|
||||||
ENV VERSION_ID=${VERSION_ID}
|
|
||||||
|
|
||||||
COPY --link --from=golang /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
WORKDIR /root/build-deb
|
|
||||||
COPY build-deb /root/build-deb/build-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/build-deb/build-deb"]
|
|
@@ -1,5 +1,5 @@
|
|||||||
# Dockerfile for Brook based alpine
|
# Dockerfile for Brook based alpine
|
||||||
# Copyright (C) 2019 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/txthinking/brook
|
# https://github.com/txthinking/brook
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
# Dockerfile for Brook based alpine
|
# Dockerfile for Brook based alpine
|
||||||
# Copyright (C) 2019 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/txthinking/brook
|
# https://github.com/txthinking/brook
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM --platform=${TARGETPLATFORM} alpine:latest
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# Dockerfile for caddy v1.0.5 based alpine
|
# Dockerfile for caddy v1.0.5 based alpine
|
||||||
# Copyright (C) 2021 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2021 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/caddyserver/caddy
|
# https://github.com/caddyserver/caddy
|
||||||
# https://github.com/caddyserver/forwardproxy
|
# https://github.com/caddyserver/forwardproxy
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
# Dockerfile for caddy v1.0.5 based alpine
|
# Dockerfile for caddy v1.0.5 based alpine
|
||||||
# Copyright (C) 2021 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2021 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/caddyserver/caddy
|
# https://github.com/caddyserver/caddy
|
||||||
# https://github.com/caddyserver/forwardproxy
|
# https://github.com/caddyserver/forwardproxy
|
||||||
|
|
||||||
FROM alpine:3.14
|
FROM --platform=${TARGETPLATFORM} alpine:3.14
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
# Dockerfile for hysteria based alpine
|
# Dockerfile for hysteria based alpine
|
||||||
# Copyright (C) 2023 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2022 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/HyNetwork/hysteria
|
# https://github.com/HyNetwork/hysteria
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM --platform=${TARGETPLATFORM} alpine:latest
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
COPY hysteria.sh /root/hysteria.sh
|
COPY hysteria.sh /root/hysteria.sh
|
||||||
COPY server.yaml /etc/hysteria/server.yaml
|
COPY server.json /etc/hysteria/server.json
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
&& apk add --no-cache bash tzdata ca-certificates \
|
&& apk add --no-cache bash tzdata ca-certificates \
|
||||||
&& chmod +x /root/hysteria.sh \
|
&& chmod +x /root/hysteria.sh \
|
||||||
@@ -18,4 +18,4 @@ RUN set -ex \
|
|||||||
|
|
||||||
VOLUME /etc/hysteria
|
VOLUME /etc/hysteria
|
||||||
ENV TZ=Asia/Shanghai
|
ENV TZ=Asia/Shanghai
|
||||||
CMD [ "/usr/bin/hysteria", "server", "-c", "/etc/hysteria/server.yaml" ]
|
CMD [ "/usr/bin/hysteria", "server", "--config", "/etc/hysteria/server.json" ]
|
||||||
|
@@ -22,30 +22,21 @@ It can be found at [Docker Hub][4].
|
|||||||
|
|
||||||
## Start a container
|
## Start a container
|
||||||
|
|
||||||
You **must create a configuration file** `/etc/hysteria/server.yaml` in host at first:
|
You **must create a configuration file** `/etc/hysteria/server.json` in host at first:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ mkdir -p /etc/hysteria
|
$ mkdir -p /etc/hysteria
|
||||||
```
|
```
|
||||||
|
|
||||||
A sample in yaml like below:
|
A sample in JSON like below:
|
||||||
|
|
||||||
```
|
```
|
||||||
listen: :8998
|
{
|
||||||
|
"listen": ":8998",
|
||||||
tls:
|
"cert": "/etc/hysteria/cert.crt",
|
||||||
cert: /etc/hysteria/cert.crt
|
"key": "/etc/hysteria/private.key",
|
||||||
key: /etc/hysteria/private.key
|
"obfs": "dGVkZHlzdW4uY29tCg=="
|
||||||
|
}
|
||||||
auth:
|
|
||||||
type: password
|
|
||||||
password: your_password
|
|
||||||
|
|
||||||
resolver:
|
|
||||||
type: https
|
|
||||||
https:
|
|
||||||
addr: 8.8.8.8:443
|
|
||||||
timeout: 10s
|
|
||||||
```
|
```
|
||||||
|
|
||||||
And put the `cert.crt`, `private.key` to the `/etc/hysteria/`.
|
And put the `cert.crt`, `private.key` to the `/etc/hysteria/`.
|
||||||
@@ -58,7 +49,7 @@ $ docker run -d -p 8998:8998 --name hysteria --restart=always -v /etc/hysteria:/
|
|||||||
|
|
||||||
**Warning**: The port number must be same as configuration and opened in firewall.
|
**Warning**: The port number must be same as configuration and opened in firewall.
|
||||||
|
|
||||||
[1]: https://github.com/apernet/hysteria
|
[1]: https://github.com/HyNetwork/hysteria
|
||||||
[2]: https://docs.docker.com/
|
[2]: https://docs.docker.com/
|
||||||
[3]: https://docs.docker.com/install/
|
[3]: https://docs.docker.com/install/
|
||||||
[4]: https://hub.docker.com/r/teddysun/hysteria/
|
[4]: https://hub.docker.com/r/teddysun/hysteria/
|
13
docker/hysteria/client.json
Normal file
13
docker/hysteria/client.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"server": "IP:8998",
|
||||||
|
"obfs": "dGVkZHlzdW4uY29tCg==",
|
||||||
|
"up_mbps": 200,
|
||||||
|
"down_mbps": 1000,
|
||||||
|
"insecure": true,
|
||||||
|
"socks5": {
|
||||||
|
"listen": "127.0.0.1:1080"
|
||||||
|
},
|
||||||
|
"http": {
|
||||||
|
"listen": "127.0.0.1:1081"
|
||||||
|
}
|
||||||
|
}
|
@@ -1,9 +0,0 @@
|
|||||||
server: "IP:8998"
|
|
||||||
|
|
||||||
auth: your_password
|
|
||||||
|
|
||||||
tls:
|
|
||||||
sni: www.example.com
|
|
||||||
|
|
||||||
socks5:
|
|
||||||
listen: 127.0.0.1:1080
|
|
6
docker/hysteria/server.json
Normal file
6
docker/hysteria/server.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"listen": ":8998",
|
||||||
|
"cert": "/etc/hysteria/cert.crt",
|
||||||
|
"key": "/etc/hysteria/private.key",
|
||||||
|
"obfs": "dGVkZHlzdW4uY29tCg=="
|
||||||
|
}
|
@@ -1,15 +0,0 @@
|
|||||||
listen: :8998
|
|
||||||
|
|
||||||
tls:
|
|
||||||
cert: /etc/hysteria/cert.crt
|
|
||||||
key: /etc/hysteria/private.key
|
|
||||||
|
|
||||||
auth:
|
|
||||||
type: password
|
|
||||||
password: your_password
|
|
||||||
|
|
||||||
resolver:
|
|
||||||
type: https
|
|
||||||
https:
|
|
||||||
addr: 8.8.8.8:443
|
|
||||||
timeout: 10s
|
|
@@ -1,5 +1,5 @@
|
|||||||
# Dockerfile for KMS Server
|
# Dockerfile for KMS Server
|
||||||
# Copyright (C) 2018 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2018 - 2020 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/Wind4/vlmcsd
|
# https://github.com/Wind4/vlmcsd
|
||||||
|
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/Wind4/vlmcsd
|
# https://github.com/Wind4/vlmcsd
|
||||||
|
|
||||||
FROM alpine:latest AS builder
|
FROM --platform=$TARGETPLATFORM alpine:latest AS builder
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
RUN apk add --no-cache git make build-base && \
|
RUN apk add --no-cache git make build-base && \
|
||||||
git clone --branch master --single-branch https://github.com/Wind4/vlmcsd.git && \
|
git clone --branch master --single-branch https://github.com/Wind4/vlmcsd.git && \
|
||||||
cd vlmcsd/ && \
|
cd vlmcsd/ && \
|
||||||
make
|
make
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM --platform=$TARGETPLATFORM alpine:latest
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
COPY --from=builder /root/vlmcsd/bin/vlmcsd /usr/bin/vlmcsd
|
COPY --from=builder /root/vlmcsd/bin/vlmcsd /usr/bin/vlmcsd
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
# Dockerfile for build RPM packages.
|
# Dockerfile for build RPM packages.
|
||||||
# Copyright (C) 2023 Teddysun <i@teddysun.com>
|
# Copyright (C) 2023 Teddysun <i@teddysun.com>
|
||||||
|
|
||||||
FROM fedora:37
|
FROM --platform=${TARGETPLATFORM} fedora:37
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
RUN dnf install -y yum-utils && \
|
RUN dnf install -y yum-utils && \
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
# Dockerfile for build RPM packages.
|
# Dockerfile for build RPM packages.
|
||||||
# Copyright (C) 2023 Teddysun <i@teddysun.com>
|
# Copyright (C) 2023 Teddysun <i@teddysun.com>
|
||||||
|
|
||||||
FROM fedora:38
|
FROM --platform=${TARGETPLATFORM} fedora:38
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
RUN dnf install -y yum-utils && \
|
RUN dnf install -y yum-utils && \
|
||||||
|
@@ -1,37 +0,0 @@
|
|||||||
# Dockerfile for build RPM packages.
|
|
||||||
# Copyright (C) 2023 Teddysun <i@teddysun.com>
|
|
||||||
|
|
||||||
FROM fedora:39
|
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
|
||||||
|
|
||||||
RUN dnf install -y yum-utils && \
|
|
||||||
dnf install -y tar wget git tree gcc gcc-c++ vim automake \
|
|
||||||
sudo net-tools make cmake zstd libzstd chkconfig libtool \
|
|
||||||
bash coreutils diffutils patch ca-certificates pcre-devel \
|
|
||||||
rpm-build rpm-devel rpmlint rpmdevtools ncurses which procps \
|
|
||||||
asciidoc audit-libs-devel binutils-devel flex jq gettext mbedtls-devel \
|
|
||||||
libcap-devel newt-devel pciutils-devel perl-generators c-ares-devel libev-devel \
|
|
||||||
python3 python3-devel python3-docutils rsync xmlto bc bison libsodium-devel \
|
|
||||||
java-devel ncurses-devel numactl-devel openssl-devel perl-devel \
|
|
||||||
bpftool dwarves gcc-plugin-devel glibc-static hmaccalc kernel-rpm-macros \
|
|
||||||
libbabeltrace-devel libbpf-devel libcap-ng-devel libnl3-devel libtraceevent-devel \
|
|
||||||
elfutils-devel xz-devel perl-ExtUtils-Embed && \
|
|
||||||
dnf clean all && rm -rf /var/cache/dnf /var/lib/rpm/__db*
|
|
||||||
|
|
||||||
RUN useradd builder -u 1000 -m -G users,wheel && \
|
|
||||||
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
|
||||||
echo "# macros" > /home/builder/.rpmmacros && \
|
|
||||||
echo "%_topdir /home/builder/rpmbuild" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_sourcedir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_builddir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_specdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_rpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_srcrpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "set enable-bracketed-paste off" >> /etc/inputrc && \
|
|
||||||
mkdir -p /home/builder/rpmbuild && \
|
|
||||||
chown -R builder /home/builder
|
|
||||||
|
|
||||||
USER builder
|
|
||||||
VOLUME /home/builder
|
|
||||||
WORKDIR /home/builder/rpmbuild
|
|
||||||
CMD ["/bin/bash"]
|
|
@@ -1,37 +0,0 @@
|
|||||||
# Dockerfile for build RPM packages.
|
|
||||||
# Copyright (C) 2024 Teddysun <i@teddysun.com>
|
|
||||||
|
|
||||||
FROM fedora:40
|
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
|
||||||
|
|
||||||
RUN dnf install -y yum-utils && \
|
|
||||||
dnf install -y tar wget git tree gcc gcc-c++ vim automake \
|
|
||||||
sudo net-tools make cmake zstd libzstd chkconfig libtool \
|
|
||||||
bash coreutils diffutils patch ca-certificates pcre-devel \
|
|
||||||
rpm-build rpm-devel rpmlint rpmdevtools ncurses which procps \
|
|
||||||
asciidoc audit-libs-devel binutils-devel flex jq gettext mbedtls-devel \
|
|
||||||
libcap-devel newt-devel pciutils-devel perl-generators c-ares-devel libev-devel \
|
|
||||||
python3 python3-devel python3-docutils rsync xmlto bc bison libsodium-devel \
|
|
||||||
java-devel ncurses-devel numactl-devel openssl-devel perl-devel \
|
|
||||||
bpftool dwarves gcc-plugin-devel glibc-static hmaccalc kernel-rpm-macros \
|
|
||||||
libbabeltrace-devel libbpf-devel libcap-ng-devel libnl3-devel libtraceevent-devel \
|
|
||||||
elfutils-devel xz-devel perl-ExtUtils-Embed && \
|
|
||||||
dnf clean all && rm -rf /var/cache/dnf /var/lib/rpm/__db*
|
|
||||||
|
|
||||||
RUN useradd builder -u 1000 -m -G users,wheel && \
|
|
||||||
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
|
||||||
echo "# macros" > /home/builder/.rpmmacros && \
|
|
||||||
echo "%_topdir /home/builder/rpmbuild" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_sourcedir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_builddir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_specdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_rpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_srcrpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "set enable-bracketed-paste off" >> /etc/inputrc && \
|
|
||||||
mkdir -p /home/builder/rpmbuild && \
|
|
||||||
chown -R builder /home/builder
|
|
||||||
|
|
||||||
USER builder
|
|
||||||
VOLUME /home/builder
|
|
||||||
WORKDIR /home/builder/rpmbuild
|
|
||||||
CMD ["/bin/bash"]
|
|
@@ -1,37 +0,0 @@
|
|||||||
# Dockerfile for build RPM packages.
|
|
||||||
# Copyright (C) 2024 Teddysun <i@teddysun.com>
|
|
||||||
|
|
||||||
FROM fedora:41
|
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
|
||||||
|
|
||||||
RUN dnf install -y yum-utils && \
|
|
||||||
dnf install -y tar wget git tree gcc gcc-c++ vim automake \
|
|
||||||
sudo net-tools make cmake zstd libzstd chkconfig libtool \
|
|
||||||
bash coreutils diffutils patch ca-certificates pcre-devel \
|
|
||||||
rpm-build rpm-devel rpmlint rpmdevtools ncurses which procps \
|
|
||||||
asciidoc audit-libs-devel binutils-devel flex jq gettext mbedtls-devel \
|
|
||||||
libcap-devel newt-devel pciutils-devel perl-generators c-ares-devel libev-devel \
|
|
||||||
python3 python3-devel python3-docutils rsync xmlto bc bison libsodium-devel \
|
|
||||||
java-devel ncurses-devel numactl-devel openssl-devel perl-devel \
|
|
||||||
bpftool dwarves gcc-plugin-devel glibc-static hmaccalc kernel-rpm-macros \
|
|
||||||
libbabeltrace-devel libbpf-devel libcap-ng-devel libnl3-devel libtraceevent-devel \
|
|
||||||
elfutils-devel xz-devel perl-ExtUtils-Embed && \
|
|
||||||
dnf clean all && rm -rf /var/cache/dnf /var/lib/rpm/__db*
|
|
||||||
|
|
||||||
RUN useradd builder -u 1000 -m -G users,wheel && \
|
|
||||||
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
|
||||||
echo "# macros" > /home/builder/.rpmmacros && \
|
|
||||||
echo "%_topdir /home/builder/rpmbuild" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_sourcedir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_builddir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_specdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_rpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_srcrpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "set enable-bracketed-paste off" >> /etc/inputrc && \
|
|
||||||
mkdir -p /home/builder/rpmbuild && \
|
|
||||||
chown -R builder /home/builder
|
|
||||||
|
|
||||||
USER builder
|
|
||||||
VOLUME /home/builder
|
|
||||||
WORKDIR /home/builder/rpmbuild
|
|
||||||
CMD ["/bin/bash"]
|
|
@@ -1,37 +0,0 @@
|
|||||||
# Dockerfile for build RPM packages.
|
|
||||||
# Copyright (C) 2025 Teddysun <i@teddysun.com>
|
|
||||||
|
|
||||||
FROM fedora:42
|
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
|
||||||
|
|
||||||
RUN dnf install -y yum-utils && \
|
|
||||||
dnf install -y tar wget git tree gcc gcc-c++ vim automake \
|
|
||||||
sudo net-tools make cmake zstd libzstd chkconfig libtool \
|
|
||||||
bash coreutils diffutils patch ca-certificates pcre-devel \
|
|
||||||
rpm-build rpm-devel rpmlint rpmdevtools ncurses which procps \
|
|
||||||
asciidoc audit-libs-devel binutils-devel flex jq gettext mbedtls-devel \
|
|
||||||
libcap-devel newt-devel pciutils-devel perl-generators c-ares-devel libev-devel \
|
|
||||||
python3 python3-devel python3-docutils rsync xmlto bc bison libsodium-devel \
|
|
||||||
java-devel ncurses-devel numactl-devel openssl-devel perl-devel \
|
|
||||||
bpftool dwarves gcc-plugin-devel glibc-static hmaccalc kernel-rpm-macros \
|
|
||||||
libbabeltrace-devel libbpf-devel libcap-ng-devel libnl3-devel libtraceevent-devel \
|
|
||||||
elfutils-devel xz-devel perl-ExtUtils-Embed && \
|
|
||||||
dnf clean all && rm -rf /var/cache/dnf /var/lib/rpm/__db*
|
|
||||||
|
|
||||||
RUN useradd builder -u 1000 -m -G users,wheel && \
|
|
||||||
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
|
||||||
echo "# macros" > /home/builder/.rpmmacros && \
|
|
||||||
echo "%_topdir /home/builder/rpmbuild" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_sourcedir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_builddir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_specdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_rpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_srcrpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "set enable-bracketed-paste off" >> /etc/inputrc && \
|
|
||||||
mkdir -p /home/builder/rpmbuild && \
|
|
||||||
chown -R builder /home/builder
|
|
||||||
|
|
||||||
USER builder
|
|
||||||
VOLUME /home/builder
|
|
||||||
WORKDIR /home/builder/rpmbuild
|
|
||||||
CMD ["/bin/bash"]
|
|
@@ -1,39 +0,0 @@
|
|||||||
# Dockerfile for build RPM packages.
|
|
||||||
# Copyright (C) 2025 Teddysun <i@teddysun.com>
|
|
||||||
|
|
||||||
FROM almalinux:10
|
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
|
||||||
|
|
||||||
RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm && \
|
|
||||||
dnf config-manager --enable epel && \
|
|
||||||
dnf config-manager --enable crb && \
|
|
||||||
rpm -e --nodeps coreutils-single && \
|
|
||||||
dnf install -y tar wget tree git gcc gcc-c++ coreutils bash diffutils patch ca-certificates \
|
|
||||||
sudo net-tools make cmake zstd libzstd chkconfig pcre2-devel \
|
|
||||||
rpm-build rpm-devel rpmlint rpmdevtools ncurses which procps \
|
|
||||||
asciidoc audit-libs-devel binutils-devel flex jq gettext \
|
|
||||||
libcap-devel newt-devel pciutils-devel perl-generators \
|
|
||||||
python3 python3-devel python3-docutils rsync xmlto bc bison \
|
|
||||||
java-devel ncurses-devel numactl-devel openssl-devel perl-devel \
|
|
||||||
bpftool dwarves gcc-plugin-devel glibc-static hmaccalc kernel-rpm-macros \
|
|
||||||
libbabeltrace-devel libbpf-devel libcap-ng-devel libnl3-devel libtraceevent-devel \
|
|
||||||
elfutils-devel xz-devel perl-ExtUtils-Embed && \
|
|
||||||
dnf clean all && rm -rf /var/cache/dnf /var/lib/rpm/__db*
|
|
||||||
|
|
||||||
RUN useradd builder -u 1000 -m -G users,wheel && \
|
|
||||||
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
|
||||||
echo "# macros" > /home/builder/.rpmmacros && \
|
|
||||||
echo "%_topdir /home/builder/rpmbuild" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_sourcedir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_builddir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_specdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_rpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "%_srcrpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
|
|
||||||
echo "set enable-bracketed-paste off" >> /etc/inputrc && \
|
|
||||||
mkdir -p /home/builder/rpmbuild && \
|
|
||||||
chown -R builder /home/builder
|
|
||||||
|
|
||||||
USER builder
|
|
||||||
VOLUME /home/builder
|
|
||||||
WORKDIR /home/builder/rpmbuild
|
|
||||||
CMD ["/bin/bash"]
|
|
@@ -1,7 +1,7 @@
|
|||||||
# Dockerfile for build RPM packages.
|
# Dockerfile for build RPM packages.
|
||||||
# Copyright (C) 2021 - 2022 Teddysun <i@teddysun.com>
|
# Copyright (C) 2021 - 2022 Teddysun <i@teddysun.com>
|
||||||
|
|
||||||
FROM centos:7
|
FROM --platform=${TARGETPLATFORM} centos:7
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
RUN yum install -y yum-utils epel-release centos-release-scl-rh && \
|
RUN yum install -y yum-utils epel-release centos-release-scl-rh && \
|
||||||
|
@@ -1,24 +1,23 @@
|
|||||||
# Dockerfile for build RPM packages.
|
# Dockerfile for build RPM packages.
|
||||||
# Copyright (C) 2021 - 2025 Teddysun <i@teddysun.com>
|
# Copyright (C) 2021 - 2022 Teddysun <i@teddysun.com>
|
||||||
|
|
||||||
FROM rockylinux:8
|
FROM --platform=${TARGETPLATFORM} rockylinux:8
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
RUN dnf install -y yum-utils epel-release && \
|
RUN yum install -y yum-utils epel-release && \
|
||||||
dnf config-manager --enable epel && \
|
yum-config-manager --enable epel && \
|
||||||
dnf config-manager --enable powertools && \
|
yum-config-manager --enable powertools && \
|
||||||
dnf install -y https://dl.lamp.sh/linux/rhel/el8/x86_64/teddysun-release-1.0-1.el8.noarch.rpm && \
|
|
||||||
rpm -e --nodeps coreutils-single && \
|
rpm -e --nodeps coreutils-single && \
|
||||||
dnf install -y tar wget wget2 git tree gcc gcc-c++ \
|
yum install -y tar wget git tree gcc gcc-c++ \
|
||||||
sudo net-tools make cmake zstd libzstd chkconfig pcre-devel pcre2-devel \
|
sudo net-tools make cmake zstd libzstd chkconfig \
|
||||||
bash coreutils diffutils patch ca-certificates \
|
bash coreutils diffutils patch ca-certificates \
|
||||||
rpm-build rpm-devel rpmlint rpmdevtools which procps \
|
rpm-build rpm-devel rpmlint rpmdevtools which procps \
|
||||||
asciidoc audit-libs-devel binutils-devel flex \
|
asciidoc audit-libs-devel binutils-devel flex \
|
||||||
libcap-devel newt-devel pciutils-devel perl-generators \
|
libcap-devel newt-devel pciutils-devel perl-generators \
|
||||||
python3 python3-devel python3-docutils rsync xmlto bc bison libnl3-devel \
|
python3 python3-devel python3-docutils rsync xmlto bc bison libnl3-devel \
|
||||||
java-devel ncurses-devel numactl-devel openssl-devel openssl3-devel perl-devel dwarves \
|
java-devel ncurses-devel numactl-devel openssl-devel perl-devel dwarves \
|
||||||
elfutils-devel xz-devel perl-ExtUtils-Embed gettext kmod libkcapi-hmaccalc && \
|
elfutils-devel xz-devel perl-ExtUtils-Embed gettext kmod libkcapi-hmaccalc && \
|
||||||
dnf clean all && rm -rf /var/cache/dnf /var/lib/rpm/__db*
|
yum clean all && rm -rf /var/cache/dnf /var/lib/rpm/__db*
|
||||||
|
|
||||||
RUN useradd builder -u 1000 -m -G users,wheel && \
|
RUN useradd builder -u 1000 -m -G users,wheel && \
|
||||||
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
||||||
|
@@ -1,16 +1,15 @@
|
|||||||
# Dockerfile for build RPM packages.
|
# Dockerfile for build RPM packages.
|
||||||
# Copyright (C) 2022 - 2025 Teddysun <i@teddysun.com>
|
# Copyright (C) 2022 Teddysun <i@teddysun.com>
|
||||||
|
|
||||||
FROM rockylinux:9
|
FROM --platform=${TARGETPLATFORM} rockylinux:9
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
RUN dnf install -y yum-utils epel-release && \
|
RUN yum install -y yum-utils epel-release && \
|
||||||
dnf config-manager --enable epel && \
|
yum-config-manager --enable epel && \
|
||||||
dnf config-manager --enable crb && \
|
yum-config-manager --enable crb && \
|
||||||
dnf install -y https://dl.lamp.sh/linux/rhel/el9/x86_64/teddysun-release-1.0-1.el9.noarch.rpm && \
|
|
||||||
rpm -e --nodeps coreutils-single && \
|
rpm -e --nodeps coreutils-single && \
|
||||||
dnf install -y tar wget wget2 git tree gcc gcc-c++ \
|
yum install -y tar wget git tree gcc gcc-c++ \
|
||||||
sudo net-tools make cmake zstd libzstd chkconfig pcre-devel pcre2-devel \
|
sudo net-tools make cmake zstd libzstd chkconfig \
|
||||||
bash coreutils diffutils patch ca-certificates \
|
bash coreutils diffutils patch ca-certificates \
|
||||||
rpm-build rpm-devel rpmlint rpmdevtools ncurses which procps \
|
rpm-build rpm-devel rpmlint rpmdevtools ncurses which procps \
|
||||||
asciidoc audit-libs-devel binutils-devel flex jq gettext \
|
asciidoc audit-libs-devel binutils-devel flex jq gettext \
|
||||||
@@ -20,7 +19,7 @@ RUN dnf install -y yum-utils epel-release && \
|
|||||||
bpftool dwarves gcc-plugin-devel glibc-static hmaccalc kernel-rpm-macros \
|
bpftool dwarves gcc-plugin-devel glibc-static hmaccalc kernel-rpm-macros \
|
||||||
libbabeltrace-devel libbpf-devel libcap-ng-devel libnl3-devel libtraceevent-devel \
|
libbabeltrace-devel libbpf-devel libcap-ng-devel libnl3-devel libtraceevent-devel \
|
||||||
elfutils-devel xz-devel perl-ExtUtils-Embed && \
|
elfutils-devel xz-devel perl-ExtUtils-Embed && \
|
||||||
dnf clean all && rm -rf /var/cache/dnf /var/lib/rpm/__db*
|
yum clean all && rm -rf /var/cache/dnf /var/lib/rpm/__db*
|
||||||
|
|
||||||
RUN useradd builder -u 1000 -m -G users,wheel && \
|
RUN useradd builder -u 1000 -m -G users,wheel && \
|
||||||
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
## RHEL RPM package building environment by Teddysun
|
## CentOS RPM package building environment by Teddysun
|
||||||
|
|
||||||
This docker image can be used to build RPM packages.
|
This docker image can be used to build RPM packages.
|
||||||
|
|
||||||
@@ -6,14 +6,13 @@ For more information on docker and containerization technologies, refer to [offi
|
|||||||
|
|
||||||
## Supported tags and respective `Dockerfile` links
|
## Supported tags and respective `Dockerfile` links
|
||||||
|
|
||||||
- `latest`, `10` [*(Dockerfile)*][8]
|
- `latest`, `9` [*(Dockerfile)*][7]
|
||||||
- `9` [*(Dockerfile)*][7]
|
|
||||||
- `8` [*(Dockerfile)*][2]
|
- `8` [*(Dockerfile)*][2]
|
||||||
- `7` [*(Dockerfile)*][3]
|
- `7` [*(Dockerfile)*][3]
|
||||||
|
|
||||||
### Reference
|
### Reference
|
||||||
|
|
||||||
- Supported architectures ([*more info*][4]): `amd64`, `arm64`
|
- Supported architectures ([*more info*][4]): `amd64`
|
||||||
|
|
||||||
## Integration
|
## Integration
|
||||||
|
|
||||||
@@ -47,12 +46,6 @@ For CentOS 9 Stream / Rockylinux 9 / Almalinux 9
|
|||||||
$ docker pull teddysun/rpmbuild:9
|
$ docker pull teddysun/rpmbuild:9
|
||||||
```
|
```
|
||||||
|
|
||||||
For CentOS 10 Stream / Rockylinux 10 / Almalinux 10
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ docker pull teddysun/rpmbuild:10
|
|
||||||
```
|
|
||||||
|
|
||||||
It can be found at [Docker Hub][6].
|
It can be found at [Docker Hub][6].
|
||||||
|
|
||||||
## Start a container
|
## Start a container
|
||||||
@@ -78,12 +71,6 @@ $ mkdir -m 777 -p /opt/builder9
|
|||||||
$ docker run -it --rm -h buildbot --name rpmbuild9 -v /opt/builder9:/home/builder/rpmbuild teddysun/rpmbuild:9
|
$ docker run -it --rm -h buildbot --name rpmbuild9 -v /opt/builder9:/home/builder/rpmbuild teddysun/rpmbuild:9
|
||||||
```
|
```
|
||||||
|
|
||||||
There is an example to start a container for CentOS 10 Stream / Rockylinux 10 / Almalinux 10 like below:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ mkdir -m 777 -p /opt/builder10
|
|
||||||
$ docker run -it --rm -h buildbot --name rpmbuild10 -v /opt/builder10:/home/builder/rpmbuild teddysun/rpmbuild:10
|
|
||||||
```
|
|
||||||
|
|
||||||
[1]: https://docs.docker.com/
|
[1]: https://docs.docker.com/
|
||||||
[2]: https://github.com/teddysun/across/blob/master/docker/rpmbuild/Dockerfile.rpmbuild8
|
[2]: https://github.com/teddysun/across/blob/master/docker/rpmbuild/Dockerfile.rpmbuild8
|
||||||
@@ -92,4 +79,3 @@ $ docker run -it --rm -h buildbot --name rpmbuild10 -v /opt/builder10:/home/buil
|
|||||||
[5]: https://docs.docker.com/install/
|
[5]: https://docs.docker.com/install/
|
||||||
[6]: https://hub.docker.com/r/teddysun/rpmbuild/
|
[6]: https://hub.docker.com/r/teddysun/rpmbuild/
|
||||||
[7]: https://github.com/teddysun/across/blob/master/docker/rpmbuild/Dockerfile.rpmbuild9
|
[7]: https://github.com/teddysun/across/blob/master/docker/rpmbuild/Dockerfile.rpmbuild9
|
||||||
[8]: https://github.com/teddysun/across/blob/master/docker/rpmbuild/Dockerfile.rpmbuild10
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# Dockerfile for trojan-go based alpine
|
# Dockerfile for trojan-go based alpine
|
||||||
# Copyright (C) 2019 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/p4gefau1t/trojan-go
|
# https://github.com/p4gefau1t/trojan-go
|
||||||
# https://github.com/v2fly/v2ray-core
|
# https://github.com/v2fly/v2ray-core
|
||||||
|
@@ -1,13 +1,12 @@
|
|||||||
# Dockerfile for trojan-go based alpine
|
# Dockerfile for trojan-go based alpine
|
||||||
# Copyright (C) 2019 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/p4gefau1t/trojan-go
|
# https://github.com/p4gefau1t/trojan-go
|
||||||
# https://github.com/v2fly/v2ray-core
|
# https://github.com/v2fly/v2ray-core
|
||||||
# https://github.com/v2fly/geoip
|
# https://github.com/v2fly/geoip
|
||||||
# https://github.com/v2fly/domain-list-community
|
# https://github.com/v2fly/domain-list-community
|
||||||
# https://github.com/Potterli20/trojan-go-fork
|
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM --platform=${TARGETPLATFORM} alpine:latest
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
@@ -40,20 +40,13 @@ A sample in JSON like below:
|
|||||||
"remote_addr": "127.0.0.1",
|
"remote_addr": "127.0.0.1",
|
||||||
"remote_port": 80,
|
"remote_port": 80,
|
||||||
"password": [
|
"password": [
|
||||||
"your_password"
|
"your_awesome_password"
|
||||||
],
|
],
|
||||||
"ssl": {
|
"ssl": {
|
||||||
"cert": "your_cert.crt",
|
"cert": "server.crt",
|
||||||
"key": "your_key.key",
|
"key": "server.key",
|
||||||
"sni": "your-domain-name.com"
|
"sni": "your-domain-name.com",
|
||||||
},
|
"fallback_port": 1234
|
||||||
"router": {
|
|
||||||
"enabled": true,
|
|
||||||
"block": [
|
|
||||||
"geoip:private"
|
|
||||||
],
|
|
||||||
"geoip": "/usr/share/trojan-go/geoip.dat",
|
|
||||||
"geosite": "/usr/share/trojan-go/geosite.dat"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -1,55 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# This is a Shell script for build multi-architectures trojan-go binary file
|
|
||||||
#
|
|
||||||
# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
|
|
||||||
#
|
|
||||||
# Copyright (C) 2020 - 2023 Teddysun <i@teddysun.com>
|
|
||||||
#
|
|
||||||
# Reference URL:
|
|
||||||
# https://github.com/p4gefau1t/trojan-go
|
|
||||||
# https://github.com/Potterli20/trojan-go-fork
|
|
||||||
|
|
||||||
cur_dir="$(pwd)"
|
|
||||||
|
|
||||||
COMMANDS=( git go )
|
|
||||||
for CMD in "${COMMANDS[@]}"; do
|
|
||||||
if [ ! "$(command -v "${CMD}")" ]; then
|
|
||||||
echo "${CMD} is not installed, please install it and try again" && exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
cd ${cur_dir}
|
|
||||||
#version=$(wget --no-check-certificate -qO- https://api.github.com/repos/p4gefau1t/trojan-go/tags | grep 'name' | cut -d\" -f4 | head -1)
|
|
||||||
#echo "git clone -b ${version} https://github.com/p4gefau1t/trojan-go.git"
|
|
||||||
echo "git clone https://github.com/Potterli20/trojan-go-fork.git"
|
|
||||||
#git clone -b ${version} https://github.com/p4gefau1t/trojan-go.git
|
|
||||||
git clone https://github.com/Potterli20/trojan-go-fork.git
|
|
||||||
cd trojan-go-fork || exit 2
|
|
||||||
|
|
||||||
PACKAGE_NAME="github.com/Potterli20/trojan-go-fork"
|
|
||||||
VERSION="$(git describe --tags)"
|
|
||||||
# VERSION="v2023.11.15"
|
|
||||||
COMMIT="$(git rev-parse HEAD)"
|
|
||||||
|
|
||||||
VAR_SETTING="-X ${PACKAGE_NAME}/constant.Version=${VERSION} -X ${PACKAGE_NAME}/constant.Commit=${COMMIT}"
|
|
||||||
|
|
||||||
LDFLAGS="-s -w ${VAR_SETTING} -buildid="
|
|
||||||
ARCHS=( 386 amd64 arm arm64 ppc64le s390x )
|
|
||||||
ARMS=( 6 7 )
|
|
||||||
|
|
||||||
for ARCH in ${ARCHS[@]}; do
|
|
||||||
if [ "${ARCH}" = "arm" ]; then
|
|
||||||
for V in ${ARMS[@]}; do
|
|
||||||
echo "Building trojan-go_linux_${ARCH}${V}"
|
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -tags "full" -ldflags "${LDFLAGS}" -o ${cur_dir}/trojan-go_linux_${ARCH}${V}
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "Building trojan-go_linux_${ARCH}"
|
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -tags "full" -ldflags "${LDFLAGS}" -o ${cur_dir}/trojan-go_linux_${ARCH}
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
chmod +x ${cur_dir}/trojan-go_linux_*
|
|
||||||
# clean up
|
|
||||||
cd ${cur_dir} && rm -fr trojan-go-fork
|
|
@@ -16,8 +16,6 @@
|
|||||||
"enabled": true,
|
"enabled": true,
|
||||||
"block": [
|
"block": [
|
||||||
"geoip:private"
|
"geoip:private"
|
||||||
],
|
]
|
||||||
"geoip": "/usr/share/trojan-go/geoip.dat",
|
|
||||||
"geosite": "/usr/share/trojan-go/geosite.dat"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
# Dockerfile for trojan based alpine
|
# Dockerfile for trojan based alpine
|
||||||
# Copyright (C) 2020 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2020 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/trojan-gfw/trojan
|
# https://github.com/trojan-gfw/trojan
|
||||||
# https://trojan-gfw.github.io/trojan/
|
# https://trojan-gfw.github.io/trojan/
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
# Dockerfile for trojan based alpine
|
# Dockerfile for trojan based alpine
|
||||||
# Copyright (C) 2020 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2020 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/trojan-gfw/trojan
|
# https://github.com/trojan-gfw/trojan
|
||||||
# https://trojan-gfw.github.io/trojan/
|
# https://trojan-gfw.github.io/trojan/
|
||||||
|
|
||||||
FROM alpine:latest AS builder
|
FROM --platform=${TARGETPLATFORM} alpine:latest AS builder
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
&& VERSION="$(wget --no-check-certificate -qO- https://api.github.com/repos/trojan-gfw/trojan/tags | grep 'name' | cut -d\" -f4 | head -1)" \
|
&& VERSION="$(wget --no-check-certificate -qO- https://api.github.com/repos/trojan-gfw/trojan/tags | grep 'name' | cut -d\" -f4 | head -1)" \
|
||||||
@@ -15,7 +15,7 @@ RUN set -ex \
|
|||||||
&& make \
|
&& make \
|
||||||
&& strip -s trojan
|
&& strip -s trojan
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM --platform=${TARGETPLATFORM} alpine:latest
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# Dockerfile for v2ray based alpine
|
# Dockerfile for v2ray based alpine
|
||||||
# Copyright (C) 2019 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/v2fly/v2ray-core
|
# https://github.com/v2fly/v2ray-core
|
||||||
# https://github.com/v2fly/geoip
|
# https://github.com/v2fly/geoip
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
# Dockerfile for v2ray based alpine
|
# Dockerfile for v2ray based alpine
|
||||||
# Copyright (C) 2019 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/v2fly/v2ray-core
|
# https://github.com/v2fly/v2ray-core
|
||||||
# https://github.com/v2fly/geoip
|
# https://github.com/v2fly/geoip
|
||||||
# https://github.com/v2fly/domain-list-community
|
# https://github.com/v2fly/domain-list-community
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM --platform=${TARGETPLATFORM} alpine:latest
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# Dockerfile for xray based alpine
|
# Dockerfile for xray based alpine
|
||||||
# Copyright (C) 2019 - 2025 Teddysun <i@teddysun.com>
|
# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/XTLS/Xray-core
|
# https://github.com/XTLS/Xray-core
|
||||||
# https://github.com/v2fly/v2ray-core
|
# https://github.com/v2fly/v2ray-core
|
||||||
@@ -13,13 +13,13 @@ WORKDIR /root
|
|||||||
COPY xray.sh /root/xray.sh
|
COPY xray.sh /root/xray.sh
|
||||||
COPY config.json /etc/xray/config.json
|
COPY config.json /etc/xray/config.json
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
&& apk add --no-cache bash tzdata ca-certificates openssl \
|
&& apk add --no-cache tzdata ca-certificates \
|
||||||
&& mkdir -p /var/log/xray /usr/share/xray \
|
&& mkdir -p /var/log/xray /usr/share/xray \
|
||||||
&& chmod +x /root/xray.sh \
|
&& chmod +x /root/xray.sh \
|
||||||
&& /root/xray.sh \
|
&& /root/xray.sh \
|
||||||
&& rm -fv /root/xray.sh \
|
&& rm -fv /root/xray.sh \
|
||||||
&& wget -O /usr/share/xray/geosite.dat https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/geosite.dat \
|
&& wget -O /usr/share/xray/geosite.dat https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat \
|
||||||
&& wget -O /usr/share/xray/geoip.dat https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/geoip.dat
|
&& wget -O /usr/share/xray/geoip.dat https://github.com/v2fly/geoip/releases/latest/download/geoip.dat
|
||||||
|
|
||||||
VOLUME /etc/xray
|
VOLUME /etc/xray
|
||||||
ENV TZ=Asia/Shanghai
|
ENV TZ=Asia/Shanghai
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
# Dockerfile for xray based alpine
|
# Dockerfile for xray based alpine
|
||||||
# Copyright (C) 2019 - 2025 Teddysun <i@teddysun.com>
|
# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/XTLS/Xray-core
|
# https://github.com/XTLS/Xray-core
|
||||||
# https://github.com/v2fly/v2ray-core
|
# https://github.com/v2fly/v2ray-core
|
||||||
# https://github.com/v2fly/geoip
|
# https://github.com/v2fly/geoip
|
||||||
# https://github.com/v2fly/domain-list-community
|
# https://github.com/v2fly/domain-list-community
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM --platform=${TARGETPLATFORM} alpine:latest
|
||||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
@@ -14,16 +14,14 @@ WORKDIR /root
|
|||||||
COPY xray.sh /root/xray.sh
|
COPY xray.sh /root/xray.sh
|
||||||
COPY config.json /etc/xray/config.json
|
COPY config.json /etc/xray/config.json
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
&& apk add --no-cache bash tzdata ca-certificates openssl \
|
&& apk add --no-cache tzdata ca-certificates \
|
||||||
&& mkdir -p /var/log/xray /usr/share/xray \
|
&& mkdir -p /var/log/xray /usr/share/xray \
|
||||||
&& chmod +x /root/xray.sh \
|
&& chmod +x /root/xray.sh \
|
||||||
&& /root/xray.sh "${TARGETPLATFORM}" \
|
&& /root/xray.sh "${TARGETPLATFORM}" \
|
||||||
&& rm -fv /root/xray.sh \
|
&& rm -fv /root/xray.sh \
|
||||||
&& wget -O /usr/share/xray/geosite.dat https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/geosite.dat \
|
&& wget -O /usr/share/xray/geosite.dat https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat \
|
||||||
&& wget -O /usr/share/xray/geoip.dat https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/geoip.dat
|
&& wget -O /usr/share/xray/geoip.dat https://github.com/v2fly/geoip/releases/latest/download/geoip.dat
|
||||||
|
|
||||||
VOLUME /etc/xray
|
VOLUME /etc/xray
|
||||||
VOLUME /var/log/xray
|
|
||||||
|
|
||||||
ENV TZ=Asia/Shanghai
|
ENV TZ=Asia/Shanghai
|
||||||
CMD [ "/usr/bin/xray", "-config", "/etc/xray/config.json" ]
|
CMD [ "/usr/bin/xray", "-config", "/etc/xray/config.json" ]
|
||||||
|
@@ -40,7 +40,9 @@ A sample in JSON like below:
|
|||||||
"settings": {
|
"settings": {
|
||||||
"clients": [
|
"clients": [
|
||||||
{
|
{
|
||||||
"id": "1eb6e917-774b-4a84-aff6-b058577c60a5"
|
"id": "1eb6e917-774b-4a84-aff6-b058577c60a5",
|
||||||
|
"level": 1,
|
||||||
|
"alterId": 64
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -52,7 +54,7 @@ A sample in JSON like below:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Or some examples of uses for Xray-core [https://github.com/XTLS/Xray-examples](https://github.com/XTLS/Xray-examples)
|
Or generate a configuration file online by [https://tools.sprov.xyz/v2ray/](https://tools.sprov.xyz/v2ray/)
|
||||||
|
|
||||||
There is an example to start a container that listen on port `9000`, run as a Xray server like below:
|
There is an example to start a container that listen on port `9000`, run as a Xray server like below:
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
|
# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
|
||||||
#
|
#
|
||||||
# Copyright (C) 2020 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2020 Teddysun <i@teddysun.com>
|
||||||
#
|
#
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://github.com/XTLS/Xray-core
|
# https://github.com/XTLS/Xray-core
|
||||||
@@ -22,7 +22,7 @@ cd ${cur_dir}
|
|||||||
git clone https://github.com/XTLS/Xray-core.git
|
git clone https://github.com/XTLS/Xray-core.git
|
||||||
cd Xray-core || exit 2
|
cd Xray-core || exit 2
|
||||||
|
|
||||||
LDFLAGS="-s -w -buildid="
|
LDFLAGS="-s -w"
|
||||||
ARCHS=( 386 amd64 arm arm64 ppc64le s390x )
|
ARCHS=( 386 amd64 arm arm64 ppc64le s390x )
|
||||||
ARMS=( 6 7 )
|
ARMS=( 6 7 )
|
||||||
|
|
||||||
|
@@ -1,36 +0,0 @@
|
|||||||
#
|
|
||||||
# spec file for package xray-plugin
|
|
||||||
#
|
|
||||||
Name: xray-plugin
|
|
||||||
Version: 1.8.15
|
|
||||||
Release: 1%{?dist}
|
|
||||||
Summary: A SIP003 plugin for shadowsocks
|
|
||||||
License: MIT
|
|
||||||
Group: Productivity/Networking/Security
|
|
||||||
URL: https://github.com/teddysun/xray-plugin
|
|
||||||
Source0: %{name}-%{version}.tar.gz
|
|
||||||
BuildRequires: bash
|
|
||||||
|
|
||||||
%global debug_package %{nil}
|
|
||||||
%global _missing_build_ids_terminate_build 0
|
|
||||||
|
|
||||||
%description
|
|
||||||
Yet another SIP003 plugin for shadowsocks, based on xray-core
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%setup -q
|
|
||||||
|
|
||||||
%build
|
|
||||||
|
|
||||||
export CGO_ENABLED=0
|
|
||||||
go build -v -trimpath -ldflags "-X main.VERSION=v%{version} -s -w -buildid=" -o xray-plugin
|
|
||||||
|
|
||||||
%install
|
|
||||||
# install binary
|
|
||||||
install -D -p -m 0755 xray-plugin %{buildroot}%{_bindir}/xray-plugin
|
|
||||||
|
|
||||||
%files
|
|
||||||
%defattr(-,root,root)
|
|
||||||
%doc README.md
|
|
||||||
%{_bindir}/xray-plugin
|
|
||||||
%license LICENSE
|
|
@@ -1,190 +0,0 @@
|
|||||||
%global debug_package %{nil}
|
|
||||||
|
|
||||||
Name: xray
|
|
||||||
Version: 24.11.30
|
|
||||||
Release: 1%{?dist}
|
|
||||||
Summary: Xray, Penetrates Everything.
|
|
||||||
License: MPL-2.0
|
|
||||||
URL: https://github.com/XTLS/Xray-core
|
|
||||||
Packager: Teddysun <i@teddysun.com>
|
|
||||||
|
|
||||||
Source0: https://github.com/XTLS/Xray-core/archive/refs/tags/v%{version}.tar.gz#/Xray-core-%{version}.tar.gz
|
|
||||||
Source1: https://github.com/teddysun/across/raw/master/rpm/xray/config.json
|
|
||||||
Source2: https://github.com/v2fly/geoip/releases/latest/download/geoip.dat
|
|
||||||
Source3: https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat
|
|
||||||
|
|
||||||
#BuildRequires: golang >= 1.20
|
|
||||||
%if 0%{?rhel} && 0%{?rhel} < 8
|
|
||||||
BuildRequires: systemd
|
|
||||||
%else
|
|
||||||
BuildRequires: systemd-rpm-macros
|
|
||||||
%endif
|
|
||||||
%{?systemd_requires}
|
|
||||||
Provides: Productivity/Networking/Web/Proxy
|
|
||||||
|
|
||||||
%description
|
|
||||||
Xray, Penetrates Everything.
|
|
||||||
Also the best v2ray-core, with XTLS support. Fully compatible configuration.
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%setup -q -n Xray-core-%{version}
|
|
||||||
|
|
||||||
%build
|
|
||||||
# https://pagure.io/go-rpm-macros/c/1cc7f5d9026175bb6cb1b8c889355d0c4fc0e40a
|
|
||||||
%undefine _auto_set_build_flags
|
|
||||||
|
|
||||||
LDFLAGS='-s -w -buildid='
|
|
||||||
env CGO_ENABLED=0 go build -v -trimpath -ldflags "$LDFLAGS" -o %{name} ./main
|
|
||||||
|
|
||||||
%install
|
|
||||||
%{__install} -d %{buildroot}%{_bindir}
|
|
||||||
%{__install} -p -m 755 %{name} %{buildroot}%{_bindir}
|
|
||||||
|
|
||||||
%{__install} -d %{buildroot}%{_sysconfdir}/%{name}
|
|
||||||
%{__install} -p -m 644 %{S:1} %{buildroot}%{_sysconfdir}/%{name}/config.json
|
|
||||||
|
|
||||||
%{__install} -d %{buildroot}%{_datadir}/%{name}
|
|
||||||
%{__install} -p -m 0644 %{S:2} %{buildroot}%{_datadir}/%{name}/geoip.dat
|
|
||||||
%{__install} -p -m 0644 %{S:3} %{buildroot}%{_datadir}/%{name}/geosite.dat
|
|
||||||
|
|
||||||
%{__install} -d %{buildroot}%{_unitdir}
|
|
||||||
cat > %{buildroot}%{_unitdir}/%{name}.service <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=Xray Service
|
|
||||||
Documentation=https://github.com/xtls
|
|
||||||
After=network.target nss-lookup.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
|
||||||
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
|
||||||
NoNewPrivileges=true
|
|
||||||
ExecStart=/usr/bin/xray run -config /etc/xray/config.json
|
|
||||||
Restart=on-failure
|
|
||||||
RestartPreventExitStatus=23
|
|
||||||
LimitNPROC=10000
|
|
||||||
LimitNOFILE=1000000
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
cat > %{buildroot}%{_unitdir}/%{name}@.service <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=Xray Service
|
|
||||||
Documentation=https://github.com/xtls
|
|
||||||
After=network.target nss-lookup.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
|
||||||
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
|
||||||
NoNewPrivileges=true
|
|
||||||
ExecStart=/usr/bin/xray run -config /etc/xray/%i.json
|
|
||||||
Restart=on-failure
|
|
||||||
RestartPreventExitStatus=23
|
|
||||||
LimitNPROC=10000
|
|
||||||
LimitNOFILE=1000000
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
|
|
||||||
|
|
||||||
%post
|
|
||||||
%systemd_post %{name}.service
|
|
||||||
|
|
||||||
%preun
|
|
||||||
%systemd_preun %{name}.service
|
|
||||||
|
|
||||||
%postun
|
|
||||||
%systemd_postun_with_restart %{name}.service
|
|
||||||
|
|
||||||
%files
|
|
||||||
%{_bindir}/%{name}
|
|
||||||
%{_unitdir}/%{name}.service
|
|
||||||
%{_unitdir}/%{name}@.service
|
|
||||||
%dir %{_sysconfdir}/%{name}
|
|
||||||
%config(noreplace) %{_sysconfdir}/%{name}/config.json
|
|
||||||
%{_datadir}/%{name}/*.dat
|
|
||||||
%license LICENSE
|
|
||||||
%doc README.md
|
|
||||||
|
|
||||||
%changelog
|
|
||||||
* Sat Nov 30 2024 Teddysun <i@teddysun.com> - 24.11.30-1
|
|
||||||
- Update version to 24.11.30
|
|
||||||
|
|
||||||
* Thu Nov 21 2024 Teddysun <i@teddysun.com> - 24.11.21-1
|
|
||||||
- Update version to 24.11.21
|
|
||||||
|
|
||||||
* Mon Nov 11 2024 Teddysun <i@teddysun.com> - 24.11.11-1
|
|
||||||
- Update version to 24.11.11
|
|
||||||
|
|
||||||
* Tue Nov 05 2024 Teddysun <i@teddysun.com> - 24.11.5-1
|
|
||||||
- Update version to 24.11.5
|
|
||||||
|
|
||||||
* Thu Oct 31 2024 Teddysun <i@teddysun.com> - 24.10.31-1
|
|
||||||
- Update version to 24.10.31
|
|
||||||
|
|
||||||
* Wed Oct 16 2024 Teddysun <i@teddysun.com> - 24.10.16-1
|
|
||||||
- Update version to 24.10.16
|
|
||||||
|
|
||||||
* Mon Sep 30 2024 Teddysun <i@teddysun.com> - 24.9.30-1
|
|
||||||
- Update version to 24.9.30
|
|
||||||
|
|
||||||
* Thu Sep 19 2024 Teddysun <i@teddysun.com> - 24.9.19-1
|
|
||||||
- Update version to 24.9.19
|
|
||||||
|
|
||||||
* Mon Sep 16 2024 Teddysun <i@teddysun.com> - 24.9.16-1
|
|
||||||
- Update version to 24.9.16
|
|
||||||
|
|
||||||
* Sat Sep 07 2024 Teddysun <i@teddysun.com> - 24.9.7-1
|
|
||||||
- Update version to 24.9.7 (New version naming rule, based release date)
|
|
||||||
|
|
||||||
* Fri Aug 30 2024 Teddysun <i@teddysun.com> - 1.8.24-1
|
|
||||||
- Update version to 1.8.24
|
|
||||||
|
|
||||||
* Sun Aug 04 2024 Teddysun <i@teddysun.com> - 1.8.23-1
|
|
||||||
- Update to version 1.8.23
|
|
||||||
|
|
||||||
* Wed Jul 17 2024 Teddysun <i@teddysun.com> - 1.8.19-1
|
|
||||||
- Update to version 1.8.19
|
|
||||||
|
|
||||||
* Mon Jul 15 2024 Teddysun <i@teddysun.com> - 1.8.18-1
|
|
||||||
- Update to version 1.8.18
|
|
||||||
|
|
||||||
* Fri Jul 12 2024 Teddysun <i@teddysun.com> - 1.8.17-1
|
|
||||||
- Update to version 1.8.17
|
|
||||||
|
|
||||||
* Fri Jun 21 2024 Teddysun <i@teddysun.com> - 1.8.16-1
|
|
||||||
- Update to version 1.8.16
|
|
||||||
|
|
||||||
* Tue Jun 18 2024 Teddysun <i@teddysun.com> - 1.8.15-1
|
|
||||||
- Update to version 1.8.15
|
|
||||||
|
|
||||||
* Thu May 23 2024 Teddysun <i@teddysun.com> - 1.8.13-1
|
|
||||||
- Update to version 1.8.13
|
|
||||||
|
|
||||||
* Wed May 22 2024 Teddysun <i@teddysun.com> - 1.8.12-1
|
|
||||||
- Update to version 1.8.12
|
|
||||||
|
|
||||||
* Fri Apr 26 2024 Teddysun <i@teddysun.com> - 1.8.11-1
|
|
||||||
- Update to version 1.8.11
|
|
||||||
|
|
||||||
* Sat Mar 30 2024 Teddysun <i@teddysun.com> - 1.8.10-1
|
|
||||||
- Update to version 1.8.10
|
|
||||||
|
|
||||||
* Mon Mar 11 2024 Teddysun <i@teddysun.com> - 1.8.9-1
|
|
||||||
- Update to version 1.8.9
|
|
||||||
|
|
||||||
* Mon Feb 26 2024 Teddysun <i@teddysun.com> - 1.8.8-1
|
|
||||||
- Update to version 1.8.8
|
|
||||||
|
|
||||||
* Mon Jan 08 2024 Teddysun <i@teddysun.com> - 1.8.7-1
|
|
||||||
- Update to version 1.8.7
|
|
||||||
|
|
||||||
* Sat Nov 18 2023 Teddysun <i@teddysun.com> - 1.8.6-1
|
|
||||||
- Update to version 1.8.6
|
|
||||||
|
|
||||||
* Tue Nov 14 2023 Teddysun <i@teddysun.com> - 1.8.5-1
|
|
||||||
- Update to version 1.8.5
|
|
||||||
|
|
||||||
* Wed Oct 18 2023 Teddysun <i@teddysun.com> - 1.8.4-1
|
|
||||||
- Update to version 1.8.4
|
|
41
wireguard.sh
41
wireguard.sh
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# This is a Shell script for configure and start WireGuard VPN server.
|
# This is a Shell script for configure and start WireGuard VPN server.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2019 - 2024 Teddysun <i@teddysun.com>
|
# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>
|
||||||
#
|
#
|
||||||
# Reference URL:
|
# Reference URL:
|
||||||
# https://www.wireguard.com
|
# https://www.wireguard.com
|
||||||
@@ -71,16 +71,16 @@ _exists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ipv4() {
|
_ipv4() {
|
||||||
local ipv4="$( ip addr | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | \
|
local ipv4="$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | \
|
||||||
grep -E -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\.|^169\.254\." | head -n 1 )"
|
egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\.|^169\.254\." | head -n 1 )"
|
||||||
[ -z "${ipv4}" ] && ipv4="$( wget -qO- -t1 -T2 http://ipv4.icanhazip.com )"
|
[ -z "${ipv4}" ] && ipv4="$( wget -qO- -t1 -T2 ipv4.icanhazip.com )"
|
||||||
[ -z "${ipv4}" ] && ipv4="$( wget -qO- -t1 -T2 http://ipinfo.io/ip )"
|
[ -z "${ipv4}" ] && ipv4="$( wget -qO- -t1 -T2 ipinfo.io/ip )"
|
||||||
printf -- "%s" "${ipv4}"
|
printf -- "%s" "${ipv4}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_ipv6() {
|
_ipv6() {
|
||||||
local ipv6=""
|
local ipv6=""
|
||||||
ipv6="$(wget -qO- -t1 -T2 http://ipv6.icanhazip.com)"
|
ipv6="$(wget -qO- -t1 -T2 ipv6.icanhazip.com)"
|
||||||
printf -- "%s" "${ipv6}"
|
printf -- "%s" "${ipv6}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,9 +296,6 @@ install_wg_pkgs() {
|
|||||||
if [ -n "$(_os_ver)" -a "$(_os_ver)" -eq 8 ]; then
|
if [ -n "$(_os_ver)" -a "$(_os_ver)" -eq 8 ]; then
|
||||||
yum-config-manager --enable PowerTools > /dev/null 2>&1 || yum-config-manager --enable powertools > /dev/null 2>&1
|
yum-config-manager --enable PowerTools > /dev/null 2>&1 || yum-config-manager --enable powertools > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
if [ -n "$(_os_ver)" -a "$(_os_ver)" -eq 9 ]; then
|
|
||||||
yum-config-manager --enable crb > /dev/null 2>&1
|
|
||||||
fi
|
|
||||||
_error_detect "yum -y install libmnl-devel"
|
_error_detect "yum -y install libmnl-devel"
|
||||||
_error_detect "yum -y install elfutils-libelf-devel"
|
_error_detect "yum -y install elfutils-libelf-devel"
|
||||||
[ ! -d "/usr/src/kernels/$(uname -r)" ] && _error_detect "yum -y install kernel-headers" && _error_detect "yum -y install kernel-devel"
|
[ ! -d "/usr/src/kernels/$(uname -r)" ] && _error_detect "yum -y install kernel-headers" && _error_detect "yum -y install kernel-devel"
|
||||||
@@ -477,9 +474,9 @@ EOF
|
|||||||
|
|
||||||
# Create client interface
|
# Create client interface
|
||||||
create_client_if() {
|
create_client_if() {
|
||||||
_info "Create client interface: /etc/wireguard/${SERVER_WG_NIC}_client.conf"
|
_info "Create client interface: /etc/wireguard/${SERVER_WG_NIC}_client"
|
||||||
if [ -n "${SERVER_PUB_IPV6}" ]; then
|
if [ -n "${SERVER_PUB_IPV6}" ]; then
|
||||||
cat > /etc/wireguard/${SERVER_WG_NIC}_client.conf <<EOF
|
cat > /etc/wireguard/${SERVER_WG_NIC}_client <<EOF
|
||||||
[Interface]
|
[Interface]
|
||||||
PrivateKey = ${CLIENT_PRIVATE_KEY}
|
PrivateKey = ${CLIENT_PRIVATE_KEY}
|
||||||
Address = ${CLIENT_WG_IPV4}/24,${CLIENT_WG_IPV6}/64
|
Address = ${CLIENT_WG_IPV4}/24,${CLIENT_WG_IPV6}/64
|
||||||
@@ -492,7 +489,7 @@ AllowedIPs = 0.0.0.0/0,::/0
|
|||||||
Endpoint = ${SERVER_PUB_IPV4}:${SERVER_WG_PORT}
|
Endpoint = ${SERVER_PUB_IPV4}:${SERVER_WG_PORT}
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
cat > /etc/wireguard/${SERVER_WG_NIC}_client.conf <<EOF
|
cat > /etc/wireguard/${SERVER_WG_NIC}_client <<EOF
|
||||||
[Interface]
|
[Interface]
|
||||||
PrivateKey = ${CLIENT_PRIVATE_KEY}
|
PrivateKey = ${CLIENT_PRIVATE_KEY}
|
||||||
Address = ${CLIENT_WG_IPV4}/24
|
Address = ${CLIENT_WG_IPV4}/24
|
||||||
@@ -505,13 +502,13 @@ AllowedIPs = 0.0.0.0/0
|
|||||||
Endpoint = ${SERVER_PUB_IPV4}:${SERVER_WG_PORT}
|
Endpoint = ${SERVER_PUB_IPV4}:${SERVER_WG_PORT}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
chmod 600 /etc/wireguard/${SERVER_WG_NIC}_client.conf
|
chmod 600 /etc/wireguard/${SERVER_WG_NIC}_client
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate a QR Code picture with default client interface
|
# Generate a QR Code picture with default client interface
|
||||||
generate_qr() {
|
generate_qr() {
|
||||||
_info "Generate a QR Code picture with client interface"
|
_info "Generate a QR Code picture with client interface"
|
||||||
_error_detect "qrencode -s8 -o /etc/wireguard/${SERVER_WG_NIC}_client.png < /etc/wireguard/${SERVER_WG_NIC}_client.conf"
|
_error_detect "qrencode -s8 -o /etc/wireguard/${SERVER_WG_NIC}_client.png < /etc/wireguard/${SERVER_WG_NIC}_client"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Enable IP forwarding
|
# Enable IP forwarding
|
||||||
@@ -584,7 +581,7 @@ install_completed() {
|
|||||||
_info "WireGuard VPN Server installation completed"
|
_info "WireGuard VPN Server installation completed"
|
||||||
_info ""
|
_info ""
|
||||||
_info "WireGuard VPN default client file is below:"
|
_info "WireGuard VPN default client file is below:"
|
||||||
_info "$(_green "/etc/wireguard/${SERVER_WG_NIC}_client.conf")"
|
_info "$(_green "/etc/wireguard/${SERVER_WG_NIC}_client")"
|
||||||
_info ""
|
_info ""
|
||||||
_info "WireGuard VPN default client QR Code is below:"
|
_info "WireGuard VPN default client QR Code is below:"
|
||||||
_info "$(_green "/etc/wireguard/${SERVER_WG_NIC}_client.png")"
|
_info "$(_green "/etc/wireguard/${SERVER_WG_NIC}_client.png")"
|
||||||
@@ -599,7 +596,7 @@ add_client() {
|
|||||||
_red "WireGuard was not installed, please install it and try again\n" && exit 1
|
_red "WireGuard was not installed, please install it and try again\n" && exit 1
|
||||||
fi
|
fi
|
||||||
default_server_if="/etc/wireguard/${SERVER_WG_NIC}.conf"
|
default_server_if="/etc/wireguard/${SERVER_WG_NIC}.conf"
|
||||||
default_client_if="/etc/wireguard/${SERVER_WG_NIC}_client.conf"
|
default_client_if="/etc/wireguard/${SERVER_WG_NIC}_client"
|
||||||
[ ! -s "${default_server_if}" ] && echo "The default server interface ($(_red ${default_server_if})) does not exists" && exit 1
|
[ ! -s "${default_server_if}" ] && echo "The default server interface ($(_red ${default_server_if})) does not exists" && exit 1
|
||||||
[ ! -s "${default_client_if}" ] && echo "The default client interface ($(_red ${default_client_if})) does not exists" && exit 1
|
[ ! -s "${default_client_if}" ] && echo "The default client interface ($(_red ${default_client_if})) does not exists" && exit 1
|
||||||
while true; do
|
while true; do
|
||||||
@@ -607,7 +604,7 @@ add_client() {
|
|||||||
if [ -z "${client}" ]; then
|
if [ -z "${client}" ]; then
|
||||||
_red "Client name can not be empty\n"
|
_red "Client name can not be empty\n"
|
||||||
else
|
else
|
||||||
new_client_if="/etc/wireguard/${client}_client.conf"
|
new_client_if="/etc/wireguard/${client}_client"
|
||||||
if [ "${client}" = "${SERVER_WG_NIC}" ]; then
|
if [ "${client}" = "${SERVER_WG_NIC}" ]; then
|
||||||
echo "The default client ($(_yellow ${client})) already exists. Please re-enter it"
|
echo "The default client ($(_yellow ${client})) already exists. Please re-enter it"
|
||||||
elif [ -s "${new_client_if}" ]; then
|
elif [ -s "${new_client_if}" ]; then
|
||||||
@@ -618,7 +615,7 @@ add_client() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# Get information from default interface file
|
# Get information from default interface file
|
||||||
client_files=($(find /etc/wireguard/ -name "*_client*" | sort))
|
client_files=($(find /etc/wireguard/ -name "*_client" | sort))
|
||||||
client_ipv4=()
|
client_ipv4=()
|
||||||
client_ipv6=()
|
client_ipv6=()
|
||||||
for ((i=0; i<${#client_files[@]}; i++)); do
|
for ((i=0; i<${#client_files[@]}; i++)); do
|
||||||
@@ -691,11 +688,11 @@ EOF
|
|||||||
echo "Add a WireGuard client ($(_green ${client})) completed"
|
echo "Add a WireGuard client ($(_green ${client})) completed"
|
||||||
systemctl restart wg-quick@${SERVER_WG_NIC}
|
systemctl restart wg-quick@${SERVER_WG_NIC}
|
||||||
# Generate a new QR Code picture
|
# Generate a new QR Code picture
|
||||||
qrencode -s8 -o /etc/wireguard/${client}_client.png < ${new_client_if}
|
qrencode -s8 -o ${new_client_if}.png < ${new_client_if}
|
||||||
echo "Generate a QR Code picture with new client ($(_green ${client})) completed"
|
echo "Generate a QR Code picture with new client ($(_green ${client})) completed"
|
||||||
echo
|
echo
|
||||||
echo "WireGuard VPN new client ($(_green ${client})) file is below:"
|
echo "WireGuard VPN new client ($(_green ${client})) file is below:"
|
||||||
_green "/etc/wireguard/${client}_client.conf\n"
|
_green "/etc/wireguard/${client}_client\n"
|
||||||
echo
|
echo
|
||||||
echo "WireGuard VPN new client ($(_green ${client})) QR Code is below:"
|
echo "WireGuard VPN new client ($(_green ${client})) QR Code is below:"
|
||||||
_green "/etc/wireguard/${client}_client.png\n"
|
_green "/etc/wireguard/${client}_client.png\n"
|
||||||
@@ -720,7 +717,7 @@ remove_client() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
client_if="/etc/wireguard/${client}_client.conf"
|
client_if="/etc/wireguard/${client}_client"
|
||||||
[ ! -s "${client_if}" ] && echo "The client file ($(_red ${client_if})) does not exists" && exit 1
|
[ ! -s "${client_if}" ] && echo "The client file ($(_red ${client_if})) does not exists" && exit 1
|
||||||
tmp_tag="$(grep -w "Address" ${client_if} | awk '{print $3}' | cut -d\/ -f1 )"
|
tmp_tag="$(grep -w "Address" ${client_if} | awk '{print $3}' | cut -d\/ -f1 )"
|
||||||
[ -n "${tmp_tag}" ] && sed -i '/'"$tmp_tag"'/,+1d;:a;1,3!{P;$!N;D};N;ba' ${default_server_if}
|
[ -n "${tmp_tag}" ] && sed -i '/'"$tmp_tag"'/,+1d;:a;1,3!{P;$!N;D};N;ba' ${default_server_if}
|
||||||
@@ -740,7 +737,7 @@ list_clients() {
|
|||||||
local line="+-------------------------------------------------------------------------+\n"
|
local line="+-------------------------------------------------------------------------+\n"
|
||||||
local string=%-35s
|
local string=%-35s
|
||||||
printf "${line}|${string} |${string} |\n${line}" " Client Interface" " Client's IP"
|
printf "${line}|${string} |${string} |\n${line}" " Client Interface" " Client's IP"
|
||||||
client_files=($(find /etc/wireguard/ -name "*_client*" | sort))
|
client_files=($(find /etc/wireguard/ -name "*_client" | sort))
|
||||||
ips=($(grep -w "AllowedIPs" ${default_server_if} | awk '{print $3}'))
|
ips=($(grep -w "AllowedIPs" ${default_server_if} | awk '{print $3}'))
|
||||||
[ ${#client_files[@]} -ne ${#ips[@]} ] && echo "One or more client interface file is missing in /etc/wireguard" && exit 1
|
[ ${#client_files[@]} -ne ${#ips[@]} ] && echo "One or more client interface file is missing in /etc/wireguard" && exit 1
|
||||||
for ((i=0; i<${#ips[@]}; i++)); do
|
for ((i=0; i<${#ips[@]}; i++)); do
|
||||||
|
Reference in New Issue
Block a user