「インストール - Zsh」の版間の差分

ナビゲーションに移動 検索に移動
327行目: 327行目:
  }
  }
   
   
# Change Private IP Address
  # カレントディレクトリに存在するディレクトリとファイルの検索
function chip()
{
    if [ ${#} != 1 ]; then
      echo "The argument is wrong." >&2
      return 1
    fi
    sudo nmcli device disconnect eth0
    sudo systemctl stop NetworkManager
    sudo sed -i -e "s/^address1=.*/address1="${1}"\/24,192.168.1.1/g" /etc/NetworkManager/system-connections/Wired.nmconnection
    sudo systemctl start NetworkManager
    sudo nmcli device connect eth0
    return 0
}
# KVMの起動
function startkvm
{
    KVM_STATUS=$(sudo systemctl status libvirtd | grep "Active:" | grep -ie "dead")
    if [ -n "KVM_STATUS" ]; then
      sudo systemctl start libvirtd
    fi
    NETWORK_STATUS=$(sudo virsh net-info default | grep -ie "起動中" -ie "Active" | grep -ie "no")
    if [ -n "$NETWORK_STATUS" ]; then
      sudo virsh net-start default
    fi
    local FIREWALL_STATUS=$(sudo systemctl status firewalld | grep "Active:" | grep -ie "running")
    if [ -n "FIREWALL_STATUS" ]; then
      sudo systemctl stop firewalld
    fi
}
# KVMの停止
function stopkvm
{
    NETWORK_STATUS=$(sudo virsh net-info default | grep -ie "起動中" -ie "Active" | grep -ie "yes")
    if [ -n "$NETWORK_STATUS" ]; then
      sudo virsh net-destroy default
    fi
    KVM_STATUS=$(sudo systemctl status libvirtd | grep "Active:" | grep -ie "running")
    if [ -n "KVM_STATUS" ]; then
      sudo systemctl stop libvirtd libvirtd.socket libvirtd-admin.socket libvirtd-ro.socket
    fi
    local FIREWALL_STATUS=$(sudo systemctl status firewalld | grep "Active:" | grep -ie "dead")
    if [ -n "FIREWALL_STATUS" ]; then
      sudo systemctl restart firewalld
    fi
}
# カレントディレクトリに存在するディレクトリとファイルの検索
  function lgrep()
  function lgrep()
  {
  {
522行目: 465行目:
     echo 'Direct Rules:'
     echo 'Direct Rules:'
     sudo firewall-cmd --direct --get-all-rules
     sudo firewall-cmd --direct --get-all-rules
}
# Apache2とMySQLの起動
function startlamp()
{
    local APACHE2_STATUS=$(sudo systemctl status apache2 | grep -ie "Active:" | grep -ie "dead")
    if [ -n "APACHE2_STATUS" ]; then
      sudo systemctl start apache2
    fi
    local MYSQL8_STATUS=$(sudo systemctl status mysql | grep -ie "Active:" | grep -ie "dead")
    if [ -n "MYSQL8_STATUS" ]; then
      sudo systemctl start mysql
    fi
}
# Apache2とMySQLの停止
function stoplamp()
{
    local APACHE2_STATUS=$(sudo systemctl status apache2 | grep "Active:" | grep -ie "running")
    if [ -n "APACHE2_STATUS" ]; then
      sudo systemctl stop apache2
    fi
    local MYSQL8_STATUS=$(sudo systemctl status mysql | grep "Active:" | grep -ie "running")
    if [ -n "MYSQL8_STATUS" ]; then
      sudo systemctl stop mysql
    fi
  }
  }
   
   
627行目: 542行目:
      
      
     return 0
     return 0
}
# Change Private IP Address
function chip()
{
    if [ ${#} != 1 ]; then
      echo "The argument is wrong." >&2
      return 1
    fi
    sudo nmcli device disconnect <ネットワークインターフェイス名  例: eth0>
    sudo systemctl stop NetworkManager
    sudo sed -i -e "s/^address1=.*/address1="${1}"\/24,<ゲートウェイのIPアドレス>/g" /etc/NetworkManager/system-connections/<接続名  例: Wired>.nmconnection
    sudo systemctl start NetworkManager
    sudo nmcli device connect <ネットワークインターフェイス名  例: eth0>
    return 0
}
# KVMの起動
function startkvm
{
    KVM_STATUS=$(sudo systemctl status libvirtd | grep "Active:" | grep -ie "dead")
    if [ -n "KVM_STATUS" ]; then
      sudo systemctl start libvirtd
    fi
    NETWORK_STATUS=$(sudo virsh net-info default | grep -ie "起動中" -ie "Active" | grep -ie "no")
    if [ -n "$NETWORK_STATUS" ]; then
      sudo virsh net-start default
    fi
    local FIREWALL_STATUS=$(sudo systemctl status firewalld | grep "Active:" | grep -ie "running")
    if [ -n "FIREWALL_STATUS" ]; then
      sudo systemctl stop firewalld
    fi
}
# KVMの停止
function stopkvm
{
    NETWORK_STATUS=$(sudo virsh net-info default | grep -ie "起動中" -ie "Active" | grep -ie "yes")
    if [ -n "$NETWORK_STATUS" ]; then
      sudo virsh net-destroy default
    fi
    KVM_STATUS=$(sudo systemctl status libvirtd | grep "Active:" | grep -ie "running")
    if [ -n "KVM_STATUS" ]; then
      sudo systemctl stop libvirtd libvirtd.socket libvirtd-admin.socket libvirtd-ro.socket
    fi
    local FIREWALL_STATUS=$(sudo systemctl status firewalld | grep "Active:" | grep -ie "dead")
    if [ -n "FIREWALL_STATUS" ]; then
      sudo systemctl restart firewalld
    fi
}
# Apache2とMySQLの起動
function startlamp()
{
    local APACHE2_STATUS=$(sudo systemctl status apache2 | grep -ie "Active:" | grep -ie "dead")
    if [ -n "APACHE2_STATUS" ]; then
      sudo systemctl start apache2
    fi
    local MYSQL8_STATUS=$(sudo systemctl status mysql | grep -ie "Active:" | grep -ie "dead")
    if [ -n "MYSQL8_STATUS" ]; then
      sudo systemctl start mysql
    fi
}
# Apache2とMySQLの停止
function stoplamp()
{
    local APACHE2_STATUS=$(sudo systemctl status apache2 | grep "Active:" | grep -ie "running")
    if [ -n "APACHE2_STATUS" ]; then
      sudo systemctl stop apache2
    fi
    local MYSQL8_STATUS=$(sudo systemctl status mysql | grep "Active:" | grep -ie "running")
    if [ -n "MYSQL8_STATUS" ]; then
      sudo systemctl stop mysql
    fi
  }
  }
    
    

案内メニュー