115 lines
4.7 KiB
Bash
115 lines
4.7 KiB
Bash
#!/bin/bash
|
|
|
|
|
|
local_host_ip=20.4.16.200
|
|
# all_host_ip_list=(20.4.13.81 20.4.13.140 20.4.13.92 20.4.13.80)
|
|
all_host_ip_list=(20.4.13.80)
|
|
|
|
pass=V2ryStr@ngPss
|
|
|
|
|
|
copy_ssh_key_to_master(){
|
|
scp /root/.ssh/id_rsa root@20.4.13.81:/root/.ssh/id_rsa
|
|
scp /root/.ssh/id_rsa.pub root@20.4.13.81:/root/.ssh/id_rsa.pub
|
|
}
|
|
copy_ssh_key_to_master
|
|
|
|
|
|
install_nfs_server_suffix(){
|
|
ssh -i /root/.ssh/id_rsa root@20.4.13.81 "systemctl start rpcbind && systemctl enable rpcbind && systemctl start nfs-server && systemctl enable nfs-server"
|
|
|
|
ssh -i /root/.ssh/id_rsa root@20.4.13.81 "mkdir -p /var/lib/docker/nfs_data && chmod 777 /var/lib/docker/nfs_data"
|
|
ssh -i /root/.ssh/id_rsa root@20.4.13.81 "echo \"/var/lib/docker/nfs_data *(rw,no_root_squash,no_all_squash,sync)\" >> /etc/exports"
|
|
ssh -i /root/.ssh/id_rsa root@20.4.13.81 "systemctl restart rpcbind && systemctl restart nfs-server"
|
|
|
|
ssh -i /root/.ssh/id_rsa root@20.4.13.81 "rpcinfo -p localhost"
|
|
|
|
}
|
|
# install_nfs_server_suffix
|
|
|
|
install_all_demand_softwares(){
|
|
|
|
local host
|
|
local dep_file_list=(tar-1.32-4.oe2003sp4.x86_64.rpm common_tool-openEuler-20.03-LTS-SP4.tar.gz nfs_utils-openEuler-20.03-LTS-SP4.tar.gz nginx-openEuler-20.03-LTS-SP4.tar.gz ntp-openEuler-20.03-LTS-SP4.tar.gz)
|
|
for host in ${all_host_ip_list[@]}
|
|
do
|
|
echo "current host is ${host}"
|
|
ssh -i /root/.ssh/id_rsa root@${host} "echo yes"
|
|
ssh -i /root/.ssh/id_rsa root@${host} "systemctl start rpcbind && systemctl enable rpcbind && systemctl start ntpd && systemctl enable ntpd"
|
|
# ssh -i /root/.ssh/id_rsa root@${host} "mkdir -p /root/wdd/dep/"
|
|
# for dep in ${dep_file_list[@]}
|
|
# do
|
|
# echo "dep file is ${dep}"
|
|
#
|
|
# ssh -i /root/.ssh/id_rsa root@${host} "wget http://20.4.16.200:9000/octopus/euler/${dep} -O /root/wdd/dep/${dep}"
|
|
# ssh -i /root/.ssh/id_rsa root@${host} "rpm -ivh /root/wdd/dep/tar*.rpm"
|
|
# ssh -i /root/.ssh/id_rsa root@${host} "cd /root/wdd/dep/ && tar -zvxf common_tool-openEuler-20.03-LTS-SP4.tar.gz && cd ./common_tool && rpm -ivh --force ./*.rpm"
|
|
# ssh -i /root/.ssh/id_rsa root@${host} "cd /root/wdd/dep/ && tar -zvxf nfs_utils-openEuler-20.03-LTS-SP4.tar.gz && cd ./nfs_utils && rpm -ivh --force ./*.rpm"
|
|
# ssh -i /root/.ssh/id_rsa root@${host} "cd /root/wdd/dep/ && tar -zvxf ntp-openEuler-20.03-LTS-SP4.tar.gz && cd ./ntp && rpm -ivh --force ./*.rpm"
|
|
#
|
|
# done
|
|
echo ""
|
|
done
|
|
}
|
|
# install_all_demand_softwares
|
|
|
|
test_base_command_exits() {
|
|
local base_command_list=(ifconfig mtr vgdisplay nslookup vim htop tar unzip iftop curl wget netstat git zsh)
|
|
local command
|
|
for command in "${base_command_list[@]}"; do
|
|
if command -v "$command" &>/dev/null; then
|
|
echo "$command exists"
|
|
else
|
|
echo "ERROR $command does not exist!"
|
|
fi
|
|
echo ""
|
|
done
|
|
}
|
|
|
|
test_service_exists(){
|
|
local base_service_list=(ntpd chronyd nginx nfs-server rpcbind docker)
|
|
local service
|
|
for service in "${base_service_list[@]}"; do
|
|
if ! systemctl list-unit-files | grep "$service.service"; then
|
|
echo "ERROR $service.service does not exist!"
|
|
fi
|
|
echo ""
|
|
done
|
|
}
|
|
# test_base_command_exits
|
|
# test_service_exists
|
|
|
|
change_host_name(){
|
|
hostnamectl set-hostname master-node
|
|
}
|
|
|
|
install_ssh_key(){
|
|
echo "" >> /root/.ssh/authorized_keys
|
|
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDL9S6CSAjTFe2fy4bAIfqu90ft6E+GBRvS59kno6LDeAbqUQNYf9hEnIg07Ee/x5DlnYE0S3Ykv3WCHuVyBH2zANnC0P87SqphDGmoqdqF3r6uDaCr4lBsUqEai9X2q6dyjZj6ym+r4zQhMApNDzbhcyfKQ54tKFylGIdx6siyktuU/VbOzWc6G8r+BfFsQpMCA1ihmCY1jGjsKPqFlZGLeTrlBb1Zk0OV+GtDhlf/t0cd0kRPJoydm2juTXrZO+tFmf9turfKZsBnRYKtQBLJG5mF1hsjIqo8DHr+PUL2wRrSxEhGTZiJL4rNJo/kHhKXXsomc5RM/AnfgAfxrLlH zeasl@DESKTOP-K2F9GG3 ">> /root/.ssh/authorized_keys
|
|
echo "" >> /root/.ssh/authorized_keys
|
|
}
|
|
|
|
install_octopus_server_offline(){
|
|
bash <(curl -sL http://20.4.16.200:9000/octopus/init-script-wdd.sh) --url http://20.4.16.200:9000/octopus --agent-install --offline
|
|
|
|
bash <(curl -sL http://20.4.16.200:9000/octopus/init-script-wdd.sh) --url http://20.4.16.200:9000/octopus --agent-remove --offline
|
|
|
|
cp /etc/ssh/sshd_config /etc/ssh/sshd_config_back
|
|
sed -i "s/StrictModes yes/StrictModes no/g" /etc/ssh/sshd_config
|
|
sed -i "s/AllowTcpForwarding no/AllowTcpForwarding yes/g" /etc/ssh/sshd_config
|
|
sed -i "s/AllowAgentForwarding no/AllowAgentForwarding yes/g" /etc/ssh/sshd_config
|
|
sed -i "s/PermitTunnel no/PermitTunnel yes/g" /etc/ssh/sshd_config
|
|
systemctl restart sshd
|
|
|
|
}
|
|
|
|
machinId(){
|
|
20.4.13.81 Chongqing-amd64-01 354d6db5354d6db5354d6db5354d6db5
|
|
20.4.13.140 Chongqing-amd64-02 2a216db5354d6db5354d6db5354d6db5
|
|
20.4.13.92 Chongqing-amd64-03 3ca26db5354d6db5354d6db5354d6db5
|
|
20.4.13.80 Chongqing-amd64-04 4ea1d6db5354d6db5354d6db5354d6db
|
|
}
|
|
|
|
|
|
|