İşletim sistemi sürümü: Tüm seriler
İşletim sisteminin tedarik bağlantısı: repo.diyosoftware.com
DiyoVM Üzerinden "Şablon Yönetimi" sekmesi üzerinden "Script" kısmı için oluşturulmuş olan yapılandırma kodları aşağıdaki şekildedir.
- Kod Türü: Kurulum
- Kod Yüklenecek Konum: /home/setup.sh
- Çalıştırılıcak Program:/bin/bash
- Çalıştırılıcak Komut:-c 'cd /home;chmod 777 setup.sh;./setup.sh'
- Kod;
PHP Kod:
#!/bin/bash
details=$(cat /etc/os-release)
dist=$(echo "$details" | grep ^ID= | grep -Eo [a-z]+)
version=$(echo "$details" | grep ^VERSION= | grep -Eo [0-9]+ | head -n 1)
name=$(ls /sys/class/net | head -n 1)
ip="{ipaddress}";
iplist="{iplist}";
gateway="{gateway}";
netmask="{netmask}";
password="{password}";
hostname="{hostname}";
cat <<EOF > /etc/cidr.py
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('netmask')
args = parser.parse_args()
cidr = 0
for bits in args.netmask.split('.'):
bits = bin(int(bits)).count('1')
cidr = cidr + bits
print(cidr)
EOF
function ubuntuIP {
iplist=(${iplist//-/ });
for ipinfo in "${iplist[@]}"; do
ipdata=(${ipinfo//x/ })
iptext+="
iface $name inet static
address ${ipdata[0]}
netmask ${ipdata[2]}
gateway ${ipdata[1]}
dns-nameservers 8.8.8.8 1.1.1.1";
done
cat <<EOF > /etc/network/interfaces
auto lo
iface lo inet loopback
auto $name
$iptext
EOF
ifup $name
}
function ubuntuIPWithRoute {
cat <<EOF > /etc/network/interfaces
auto lo
iface lo inet loopback
auto $name
iface $name inet static
address $ip
netmask $netmask
broadcast @address
post-up route add $gateway dev $name
post-up route add default gw $gateway
pre-down route del $gateway dev $name
pre-down route del default gw $gateway
dns-nameservers 8.8.8.8 1.1.1.1
EOF
ifup $name
}
function debianIP {
iplist=(${iplist//-/ });
for ipinfo in "${iplist[@]}"; do
ipdata=(${ipinfo//x/ })
iptext+="
iface $name inet static
address ${ipdata[0]}
netmask ${ipdata[2]}
gateway ${ipdata[1]}
dns-nameservers 8.8.8.8 1.1.1.1";
done
cat <<EOF > /etc/network/interfaces
auto lo
iface lo inet loopback
auto $name
$iptext
EOF
ifup $name
}
function centosIP {
iplist=(${iplist//-/ });
counter=0
find /etc/sysconfig/network-scripts -type f -name "*ifcfg-$name*" -delete
for ipinfo in "${iplist[@]}"; do
ipdata=(${ipinfo//x/ })
if [ $counter == 0 ]; then
ipname="ifcfg-$name";
devicename=$name
else
ipname="ifcfg-$name:$counter";
devicename="$name:$counter";
fi
cat > /etc/sysconfig/network-scripts/$ipname << EOF
DEVICE=$devicename
IPADDR=${ipdata[0]}
GATEWAY=${ipdata[1]}
DNS1=8.8.8.8
DNS2=1.1.1.1
EOF
counter=$((counter+1))
done
ifup $name
}
function netplanIP {
iplist=(${iplist//-/ });
gateway="";
for ipinfo in "${iplist[@]}"; do
ipdata=(${ipinfo//x/ })
iptext+="${ipdata[0]}/24,";
gateway=${ipdata[1]}
done
length=${#iptext}
endindex=$(expr $length - 1)
cat <<EOF > /etc/netplan/config.yaml
network:
version: 2
renderer: networkd
ethernets:
$name:
addresses: [${iptext:0:$endindex}]
gateway4: $gateway
dhcp4: no
nameservers:
addresses: [1.1.1.1]
EOF
netplan apply
}
if [ -d /etc/netplan ]; then
netplanIP
else
if [ "$dist" == ubuntu ]; then
if [ $cidr == 32 ]; then
ubuntuIPWithRoute
else
ubuntuIP
fi
fi
if [ "$dist" == debian ]; then
debianIP
fi
if [ "$dist" == pardus ]; then
debianIP
fi
if [ "$dist" == centos ]; then
centosIP
fi
if [ "$dist" == almalinux ]; then
centosIP
fi
if [ "$dist" == rocky ]; then
centosIP
fi
fi
(echo d; echo ; echo n; echo p; echo ; echo ; echo ; echo w;) | fdisk /dev/sda
resize2fs /dev/sda1
(echo $password; echo $password) | passwd root
hostnamectl set-hostname $hostname
rm /root/.bash_history
rm /home/setup.sh
reboot
- Kod Türü: Şifre Değiştirme
- Kod Yüklenecek Konum:
- Çalıştırılıcak Program: /bin/bash
- Çalıştırılıcak Komut: -c '(echo {password}; echo {password}) | passwd root'
- Kod;
- Kod Türü: IP Adresi
- Kod Yüklenecek Konum: /home/network.sh
- Çalıştırılıcak Program:/bin/bash
- Çalıştırılıcak Komut:-c 'cd /home;chmod 777 network.sh;./network.sh'
- Kod;
PHP Kod:
#!/bin/bash
name=$(ls /sys/class/net | head -n 1)
iplist="{iplist}";
iplist=(${iplist//-/ });
counter=0
find /etc/sysconfig/network-scripts -type f -name "*ifcfg-$name*" -delete
for ipinfo in "${iplist[@]}"; do
ipdata=(${ipinfo//x/ })
if [ $counter == 0 ]; then
ipname="ifcfg-$name";
devicename=$name
else
ipname="ifcfg-$name:$counter";
devicename="$name:$counter";
fi
cat > /etc/sysconfig/network-scripts/$ipname << EOF
DEVICE=$devicename
IPADDR=${ipdata[0]}
GATEWAY=${ipdata[1]}
DNS1=8.8.8.8
DNS2=1.1.1.1
EOF
counter=$((counter+1))
done
ifup $name
service network restart
rm /home/network.sh
)

