Please review my 12 lines Ubuntu-Nginx environment script

Please review my 12 lines Ubuntu-Nginx environment script:

ufw --force enable && ufw allow 22,25,80,443,9000/tcp
apt-get update -y && add-apt-repository ppa:certbot/certbot -y && apt-get update -y
apt-get upgrade zip unzip tree unattended-upgrades sshguard nginx python-certbot-nginx mysql-server php-fpm php-mysql php-mbstring php-mcrypt -y
DEBIAN_FRONTEND=noninteractive apt-get upgrade postfix -y
sed -i "s/post_max_size = .M/post_max_size = 250M/ ; s/upload_max_filesize = .M/upload_max_filesize = 250M/" /etc/php/*/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/*/fpm/php.ini
wget -P ~/myAddons/{,,,,,}
curl > /usr/local/bin/wp
echo -e "0 0 * * * ~/myAddons/ \n0 0 * * 0 ~/myAddons/" | crontab
chmod +x ~/myAddons/* /usr/local/bin/wp && source ~/myAddons/ && rss
# sed -i "s/# gzip_/gzip_/g" /etc/nginx/nginx.conf

What can I shorten/automate here? It feels to me a bit heavy, even though it is quite short.

Comfortable Github link.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


The script looks alright. What I could suggest maybe is adding some error handling with some if the conditions to stop the script if any of the commands fail.

For example, you could add the following:

# exit when any command fails
set -e

That way the script would stop if any of the commands fail.

I usually use this site here to check my shell scripts for some issues and advises on best practices:

Regards, Bobby