Use an environment variable file

This commit is contained in:
Marcin Jachymiak 2020-02-26 11:45:50 -05:00
parent c9d1bbddc8
commit bbdb363660
5 changed files with 18 additions and 8 deletions

View File

@ -49,6 +49,13 @@ The setup script creates a systemd user service that will run `siad` in the
background and automatically restart upon failure. The `siad.service` file must background and automatically restart upon failure. The `siad.service` file must
be placed in `~/.config/systemd/user/` be placed in `~/.config/systemd/user/`
To use the `siad.service`, first fill out `~/.sia/sia.env` environment variables with the
correct values. You will need to initialize your wallet if you have not already
done so.
To enable the service: `systemctl --user enable siad.service`
### Useful Commands
To start the service: `systemctl --user start siad` To start the service: `systemctl --user start siad`
To stop it: `systemctl --user stop siad` To stop it: `systemctl --user stop siad`
To check the status of it: `systemctl --user status siad` To check the status of it: `systemctl --user status siad`

View File

@ -113,5 +113,6 @@ if ! shopt -oq posix; then
fi fi
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/home/user/go/bin export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/home/user/go/bin
export SIA_DATA_DIR=/home/user/siad set -o allexport
export SIA_API_PASSWORD=$(cat /home/user/.sia/apipassword) source ~/.sia/sia.env
set +o allexport

View File

@ -67,7 +67,8 @@ yarn build
# Enable the systemd service # Enable the systemd service
cd $cwd cd $cwd
mkdir -p $HOME/.config/systemd/user mkdir -p ~/.config/systemd/user
cp siad.service $HOME/.config/systemd/user/siad.service cp siad.service ~/.config/systemd/user/siad.service
systemctl --user enable siad.service mkdir -p ~/.sia
cp sia.env ~/.sia/

3
setup-scripts/sia.env Normal file
View File

@ -0,0 +1,3 @@
SIA_DATA_DIR=""
SIA_API_PASSWORD=""
SIA_WALLET_PASSWORD=""

View File

@ -4,9 +4,7 @@ Description=siad
[Service] [Service]
Type=simple Type=simple
WorkingDirectory=/home/user/siad WorkingDirectory=/home/user/siad
Environment="SIA_DATA_DIR=/home/user/siad" EnvironmentFile=/home/user/.sia/sia.env
Environment="SIA_API_PASSWORD=$(cat /home/user/.sia/apipassword)"
Environment="SIA_WALLET_PASSWORD=$(cat /home/user/.sia/walletpassword)"
ExecStart=/home/user/go/bin/siad ExecStart=/home/user/go/bin/siad
ExecStop=/home/user/go/bin/siac stop ExecStop=/home/user/go/bin/siac stop
Restart=on-failure Restart=on-failure