Open h-sendai opened 2 years ago
#!/bin/sh
if [ -f /etc/os-release ]; then
:
else
echo "This script requires /etc/os-release file to find which OS you are using"
echo "Please install following pacakge:"
echo "RHEL 8: redhat-release"
echo "Scientific Linux 7: sl-release"
echo "CentOS Stream 8/9: centos-stream-release"
exit 1
fi
os_name=$(grep '^ID=' /etc/os-release | awk -F'=' '{print $2}' | sed -e 's/"//g')
os_major_version=$(grep '^VERSION_ID=' /etc/os-release | awk -F'=' '{print $2}' | sed -e 's/"//g' | sed -e 's/\..*//')
el_name="el$os_major_version"
echo os_name: $os_name
echo os_major_version: $os_major_version
echo el_name: $el_name
RHEL 8はVERSION_IDに8.5
のようにマイナーリリース番号も入っている。
上のスクリプトを走らせた結果
os_name: scientific
os_major_version: 7
el_name: el7
os_name: centos
os_major_version: 7
el_name: el7
os_name: centos
os_major_version: 8
el_name: el8
os_name: centos
os_major_version: 9
el_name: el9
os_name: rhel
os_major_version: 8
el_name: el8
シェルスクリプト daqmw-rpm でもlsb_releaseコマンドをつかっているので https://github.com/h-sendai/DAQ-Middleware/issues/21 と同様にCS 9以降で問題になりそうだ。