echo
' '만 표시 되도록 이 스크립트를 "자동" 모드에서 실행할 수 있습니까 ? 다른 모든 출력은 로그 파일에 저장되어야 합니다.
#!/bin/sh
which docker && docker --version | grep "Docker version"
if [ $? -eq 0 ]
then
echo "already existing"
else
sudo apt-get update && sudo apt-get upgrade -y
apt-cache policy docker-engine
sudo apt-get install -y \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual \
docker-engine
sudo service docker start
which docker && docker --version | grep "Docker version"
if [ $? -eq 0 ]
then
echo "installed correctly"
else
echo "installation failed" >&2
fi
fi
답변1
예, 일부 줄을 변경하면 작동합니다.
#!/bin/sh
which docker && docker --version | grep -q "Docker version"
if [ $? -eq 0 ]
then
echo "already existing"
else
sudo apt-get update && sudo apt-get upgrade -y 2>&1 >something.log
apt-cache policy docker-engine 2>&1 >something.log
sudo apt-get install -y \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual \
docker-engine 2>&1 >something.log
sudo service docker start 2>&1 >something.log
which docker && docker --version | grep -q "Docker version"
if [ $? -eq 0 ]
then
echo "installed correctly"
else
echo "installation failed" >&2
fi
fi