Repository navigation
Expand file tree
/
Copy pathuseradd.sh
More file actions
executable file
·83 lines (72 loc) · 2.38 KB
/
Copy pathuseradd.sh
File metadata and controls
executable file
·83 lines (72 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
############
#Ajout auto#
#Gaaa - LND#
#Mods by soyuka for ezssed2#
############
###############################################################################
###################### DECLARATION DES VARIABLES ########################
###############################################################################
USER=$1
PW=$2
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
USER_HOME=$(su - $USER -c 'cd ~/ && echo $HOME')
CONFIG_DIR="/usr/local/opt/ezseed"
###############################################################################
############################### SCRIPT ##################################
###############################################################################
# Vérification du root
if [ "$(id -u)" != "0" ]; then
echo "This bash script needs a root account" 1>&2
exit 1
fi
if [ ! -d "$CONFIG_DIR" ]; then
mkdir -p $CONFIG_DIR
fi
if [ ! -f "$CONFIG_DIR/rutorrent_passwd" ]; then
touch $CONFIG_DIR/rutorrent_passwd
fi
# Création de l'utilisateur
python $DIR/htpasswd.py -b $CONFIG_DIR/rutorrent_passwd $USER $PW
# Création des répertoires
# keep chroot rights by creating as root and chown'd them later
mkdir -p $USER_HOME/downloads $USER_HOME/uploads $USER_HOME/incomplete $USER_HOME/rtorrent $USER_HOME/rtorrent/session
# On met la conf rtorrent
if [ ! -f "$USER_HOME/.rtorrent.rc" ]; then
touch $USER_HOME/.rtorrent.rc
fi
cat > $USER_HOME/.rtorrent.rc<< EOF
execute = {sh,-c,rm -f $USER_HOME/rtorrent/session/rpc.socket}
scgi_local = $USER_HOME/rtorrent/session/rpc.socket
execute = {sh,-c,chmod 0666 $USER_HOME/rtorrent/session/rpc.socket}
encoding_list = UTF-8
system.umask.set = 022
port_range = 45000-65000
port_random = yes
check_hash = no
directory = $USER_HOME/incomplete
session = $USER_HOME/rtorrent/session
encryption = allow_incoming, try_outgoing, enable_retry
trackers.enable = 1
use_udp_trackers = yes
EOF
# On fait la conf rutorrent
mkdir -p /var/www/rutorrent/conf/users/$USER
cat > /var/www/rutorrent/conf/users/$USER/config.php<< EOF
<?php
\$scgi_port = 0;
\$scgi_host = "unix://$USER_HOME/rtorrent/session/rpc.socket";
\$XMLRPCMountPoint = "/RPC00001";
\$pathToExternals = array(
"php" => '',
"curl" => '/usr/bin/curl',
"gzip" => '',
"id" => '',
"stat" => '/usr/bin/stat',
);
\$topDirectory = "$USER_HOME";
?>
EOF
chown -R $USER:$USER $USER_HOME/*
##$DIR/daemon.sh start $USER
exit 0