I want to use shell scripts to set up my virtual machine. Example script.sh has
pip install wheel
pip install cookiecutter
pip install flask
pip install gunicorn
pip install uwsgi
Then I want it to create a service file on location /etc/systemd/system/website.service that contains the following:
[Unit]
Description=Gunicorn instance to serve website
After=network.target
[Service]
User=$1
Group=www-data
WorkingDirectory=/home/$1/website
Environment="PATH=/home/$1/website/venv/bin"
ExecStart=/home/$1/website/venv/bin/gunicorn --workers 3 --bind unix:website.sock -m 007 wsgi:app
[Install]
WantedBy=multi-user.target
Where $1 gets replaced by the user($USER) executing the shell script. Nicest solution is if I would put this in a separate file and then copy the file to the specified location while replacing the argument. Important is that this reguires sudo on the pasting due to location.
Something like:
pip install wheel
pip install cookiecutter
pip install flask
pip install gunicorn
pip install uwsgi
sudo echo file_containing_text.txt $USER > /etc/systemd/system/website.service
but for the love of me I can't get this to work.