gotbletu / serverscripts

automate setup server services
33 stars 12 forks source link

Transmission Support for Solus OS. #3

Open Abhinav1217 opened 4 years ago

Abhinav1217 commented 4 years ago

Hi, Like before, I am fixing the automate_transmission script to work on solus os. There are few confusion I need to clarify before I can send a PR with fixes.

1 - For the variable TSM_CONFIG Solus doesn't have config location /var/lib/transmission-daemon. As far as I could locate (using locate command) transmission GUI is taking settings from $HOME/.config/transmission/settings.json. So I have changed it to that. But there is also issue that this script runs as a sudo therefore $HOME translate to /root Currently I have hard-coded my home path to continue testing.

2 - I can not find any service for transmission or transmission-daemon in systemctl on solus. Should I create one? Do I need to create one. Currently, I tried to find what happens when I set transmission-daemon to autostart using gnome-tweak , turns out, it just add the desktop file to ~/.config/autostart. with exec set to transmission-daemon

3 - There is no group with name of transmission, so chgrp fails. Do I need one for this to work? Even without that, transmission daemon was working as expected ( with some manual firewall configuration"

How do you want me to proceed?

gotbletu commented 4 years ago

~/.config/autostart just means it only runs as the user logs in. If you want to run it at boot time you would need a systemd service file.

Usually each distro would create group/user/systemd_service_file/config_directory for transmission once you install it. Maybe tell the Solus transmission-daemon package maintainer to do that? So yea you would have to create those if it does not exist

  1. whichever one seem closes to Solus, make a directory path to save the settings e.g arch /var/lib/transmission/.config/transmission-daemon/settings.json or e.g ubuntu /etc/transmission-daemon/settings.json

  2. create group/user for transmission

    • without login access /usr/sbin/nologin
    • point home folder to /var/lib/transmission (e.g arch) or /etc/transmission-daemon (e.g ubuntu)
  3. create systemd, this is what i looks like on archbase system

[Unit]
Description=Transmission BitTorrent Daemon
After=network.target

[Service]
User=transmission
Type=notify
ExecStart=/usr/bin/transmission-daemon -f --log-error
ExecReload=/bin/kill -s HUP $MAINPID

[Install]
WantedBy=multi-user.target
Abhinav1217 commented 4 years ago

Thanks for info. Here is an update,

  1. I tried locate and find, only transmission-daemon/settings.json is located at .config at home directory. So now the problem is if I add $HOME or uname or anything in script, it will point to root user not the actual user, because script needs to be executed as sudo. And Solus doesn't actually open access to root user by default. Only reason I have one is because I am a developer and adept enough to work with it.

We didn't have any workaround on this back when I was maintainer of Fedy, So I need your help with this. How to execute a script as sudo and find path to user's home directory within script.

  1. I created the user group transmission with home folder currently hardcoded to /home/abhinav/transmission-daemon (I didn't knew it was possible) Works fine.

3 I manually created service file for transmission-daemon. Script is based on work we did in fedy so it should be reliable. It feels like Solus prefers to keep their service file in /usr/lib64/systemd/system and use symlinks or /etc/systemd/system/multi-user.target.wants/. So I have used same approch. Default paths for service file on fedora were different.

So in summery, I need help with problem number one and then, I can reliably test it and submit a PR.

gotbletu commented 4 years ago
  1. no dont try to use the current user or current home, we trying to avoid that since its going to run as its own user. You need to create a new user/group/home. e.g
    
    PACKAGE_HOME="/var/lib/transmission"
    USERNAME=transmission
    GROUPNAME=transmission
    groupadd "$GROUPNAME"
    useradd -d "$PACKAGE_HOME" -M -s /usr/sbin/nologin -g "$GROUPNAME" "$USERNAME"
    chown "$USERNAME":"$GROUPNAME" "$PACKAGE_HOME"
    chmod -R 775 "$PACKAGE_HOME"
Abhinav1217 commented 4 years ago

Ok.. I will get back to you by Tuesday.. It's Diwali week in India so office is hectic during day and evenings are busy with pooja.

I have already implemented user and group creation, And created systemd startup service. I will modify scripts as per your suggestion. I think I will also bootup a Solus VM for testing.