Sim, você pode alterar algumas linhas:
#!/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