IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Shell et commandes GNU Discussion :

Vos avis sur mon script [Débutant(e)]


Sujet :

Shell et commandes GNU

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Juillet 2013
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juillet 2013
    Messages : 38
    Points : 14
    Points
    14
    Par défaut Vos avis sur mon script
    Bonjour

    je voudrais vos avis sur mon script

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    #!/bin/bash
     
      clear
     
        if [ $(id -u) -ne 0 ]
        then
           echo
           echo "This script must be run as root." 1>&2
           echo
           exit 1
        fi
     
        # demander nom et mot de passe
        read -p "Adding user now, please type your user name: " user
        read -s -p "Enter password: " pwd
        echo
     
        # ajout utilisateur
        useradd -m  -s /bin/bash "$user"
     
        # creation du mot de passe pour cet utilisateur
        echo "${user}:${pwd}" | chpasswd
     
     # gestionnaire de paquet
    if [ "`dpkg --status aptitude | grep Status:`" == "Status: install ok installed" ]
    then
            packetg="aptitude"
    else
            packetg="apt-get"
    fi
     
    ip=$(ip addr | grep eth0 | grep inet | awk '{print $2}' | cut -d/ -f1)
     
    if [ -z $homedir ]
    then
            homedir="/home"
    fi
     
     
    if [ -z $wwwdir ]
    then
            wwwdir="/var/www"
    fi
     
    if [ -z $apachedir ]
    then
            apachedir="/etc/apache2"
    fi
     
    if [ -z $initd ]
    then
            initd="/etc/init.d"
    fi
     
    ##Log de l'instalation
    exec 2>/$homedir/$user/log
     
    # Ajoute des depots non-free
    echo "deb http://ftp.fr.debian.org/debian/ wheezy main contrib non-free
    deb-src http://ftp.fr.debian.org/debian/ wheezy main contrib non-free" >> /etc/apt/sources.list
     
    # Installation des paquets vitaux
    $packetg update
    $packetg install -y  apache2 apache2-utils autoconf build-essential ca-certificates comerr-dev libapache2-mod-php5 libcloog-ppl-dev libcppunit-dev libcurl3 libcurl4-openssl-dev libncurses5-dev ncurses-base ncurses-term libterm-readline-gnu-perl libsigc++-2.0-dev libssl-dev libtool libxml2-dev ntp openssl patch libperl-dev php5 php5-cli php5-dev php5-fpm php5-curl php5-geoip php5-mcrypt php5-xmlrpc pkg-config python-scgi dtach ssl-cert subversion unrar zlib1g-dev pkg-config unzip htop irssi curl cfv rar zip ffmpeg mediainfo git screen perl libapache2-mod-scgi
     
    ##  Installation XMLRPC Libtorrent Rtorrent Plowshare
     
        # XMLRPC
     
        svn checkout http://svn.code.sf.net/p/xmlrpc-c/code/stable xmlrpc-c
        cd xmlrpc-c
        ./configure --prefix=/usr --enable-libxml2-backend --disable-libwww-client --disable-wininet-client --disable-abyss-server --disable-cgi-server
        make
        make install
        cd ..
        rm -rv xmlrpc-c
     
        # Libtorrent
     
        wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.2.tar.gz
        tar -zxvf libtorrent-0.13.2.tar.gz
        cd libtorrent-0.13.2
        ./autogen.sh
        ./configure
        make
        make install
        cd ..
        rm -rv libtorrent-0.13.2*
     
        # Rtorrent
     
        wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.9.2.tar.gz
        tar -zxvf rtorrent-0.9.2.tar.gz
        cd rtorrent-0.9.2
        ./autogen.sh
        ./configure --with-xmlrpc-c
        make
        make install
        ldconfig
        cd  ..
        rm -rv rtorrent-0.9.2*
     
    # Plowshare
    cd    /$homedir
        git clone https://code.google.com/p/plowshare/ plowshare4
        cd plowshare4
        make install
     
    #------------Instalation de Rutorrent--------
    #--------------------------------------------
     
    cd $wwwdir/
    svn checkout http://rutorrent.googlecode.com/svn/trunk/rutorrent
    svn checkout http://rutorrent.googlecode.com/svn/trunk/plugins
     
    find $wwwdir/rutorrent -depth -name plugins -type d -exec rm -rf '{}' \;
    mv plugins rutorrent/
     
    #-----Fichier Configuration Config.php--------
    #---------------------------------------------
    cat <<'EOF' > $wwwdir/rutorrent/conf/config.php
    <?php
    	// configuration parameters
     
    	// for snoopy client
    	@define('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0', true);
    	@define('HTTP_TIME_OUT', 30, true);	// in seconds
    	@define('HTTP_USE_GZIP', true, true);
    	$httpIP = null;				// IP string. Or null for any.
     
    	@define('RPC_TIME_OUT', 5, true);	// in seconds
     
    	@define('LOG_RPC_CALLS', false, true);
    	@define('LOG_RPC_FAULTS', true, true);
     
    	// for php
    	@define('PHP_USE_GZIP', false, true);
    	@define('PHP_GZIP_LEVEL', 2, true);
     
    	$do_diagnostic = true;
    	$log_file = '/tmp/rutorrent_errors.log';		// path to log file (comment or leave blank to disable logging)
     
    	$saveUploadedTorrents = true;		// Save uploaded torrents to profile/torrents directory or not
    	$overwriteUploadedTorrents = false;     // Overwrite existing uploaded torrents in profile/torrents directory or make unique name
     
    	$topDirectory = '/home/@user@/downloads';			// Upper available directory. Absolute path with trail slash.
    	$forbidUserSettings = false;
     
    	$scgi_port = 5000;
    	$scgi_host = "127.0.0.1";
     
    	// For web->rtorrent link through unix domain socket
    	// (scgi_local in rtorrent conf file), change variables
    	// above to something like this:
    	//
        //$scgi_port = 0;
    	//$scgi_host = "unix:///tmp/rtorrent.sock";
     
    	$XMLRPCMountPoint = "/RPC2";		// DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!!
     
    	$pathToExternals = array(
    		"php"  => '/usr/bin/php',			// Something like /usr/bin/php. If empty, will be found in PATH.
    		"curl" => '/usr/bin/curl',			// Something like /usr/bin/curl. If empty, will be found in PATH.
    		"gzip" => '/bin/gzip',			// Something like /usr/bin/gzip. If empty, will be found in PATH.
    		"id"   => '/usr/bin/id',			// Something like /usr/bin/id. If empty, will be found in PATH.
    		"stat" => '/usr/bin/stat',			// Something like /usr/bin/stat. If empty, will be found in PATH.
    	);
     
    	$localhosts = array( 			// list of local interfaces
    		"127.0.0.1",
    		"localhost",
    	);
     
    	$profilePath = '../share';		// Path to user profiles
    	$profileMask = 0777;			// Mask for files and directory creation in user profiles.
    						// Both Webserver and rtorrent users must have read-write access to it.
    						// For example, if Webserver and rtorrent users are in the same group then the value may be 0770.
     
    ?>
    EOF
    sed -i.bak "s/@user@/$user/g;" /$wwwdir/rutorrent/conf/config.php
     
    #----Fin du fichier configuration------------- 
    #---------------------------------------------
     
    #-----Fichier Configuration plugins.ini-------
    #---------------------------------------------
    cat <<'EOF' > /$wwwdir/rutorrent/conf/plugins.ini
    ;; Plugins' permissions.
    ;; If flag is not found in plugin section, corresponding flag from "default" section is used.
    ;; If flag is not found in "default" section, it is assumed to be "yes".
    ;;
    ;; For setting individual plugin permissions you must write something like that:
    ;;
    ;; [ratio]
    ;; enabled = yes			;; also may be "user-defined", in this case user can control plugin's state from UI
    ;; canChangeToolbar = yes
    ;; canChangeMenu = yes
    ;; canChangeOptions = no
    ;; canChangeTabs = yes
    ;; canChangeColumns = yes
    ;; canChangeStatusBar = yes
    ;; canChangeCategory = yes
    ;; canBeShutdowned = yes
     
    [default]
    enabled = user-defined
    canChangeToolbar = yes
    canChangeMenu = yes
    canChangeOptions = yes
    canChangeTabs = yes
    canChangeColumns = yes
    canChangeStatusBar = yes
    canChangeCategory = yes
    canBeShutdowned = yes
     
    ;; Default
     
    [_getdir]
    enabled = yes
    [cpuload]
    enabled = user-defined
    [create]
    enabled = user-defined
    [datadir]
    enabled = yes
    [diskspace]
    enabled = user-defined
    [erasedata]
    enabled = user-defined
    [show_peers_like_wtorrent]
    enabled = user-defined
    [theme]
    enabled = yes
    [tracklabels]
    enabled = user-defined
    [trafic]
    enabled = user-defined
     
    ;; Enabled
     
    [autotools]
    enabled = user-defined
    [cookies]
    enabled = user-defined
    [data]
    enabled = user-defined
    [edit]
    enabled = user-defined
    [extratio]
    enabled = user-defined
    [extsearch]
    enabled = user-defined
    [filedrop]
    enabled = user-defined
    [filemanager]
    enabled = user-defined
    [geoip]
    enabled = user-defined
    [httprpc]
    enabled = yes
    canBeShutdowned = no
    [pausewebui]
    enabled = yes
    [ratio]
    enabled = user-defined
    [ratiocolor]
    enabled = user-defined
    [rss]
    enabled = user-defined
    [_task]
    enabled = yes
    [throttle]
    enabled = user-defined
    [titlebar]
    enabled = user-defined
    [unpack]
    enabled = user-defined
     
    ;; Disabled
     
    [chat]
    enabled = no
    [chunks]
    enabled = no
    [feeds]
    enabled = no
    [fileshare]
    enabled = no
    [fileupload]
    enabled = no
    [history]
    enabled = no
    [instantsearch]
    enabled = no
    [ipad]
    enabled = no
    [logoff]
    enabled = no
    [loginmgr]
    enabled = no
    [mediainfo]
    enabled = no
    [mediastream]
    enabled = no
    [check_port]
    enabled = no
    [retrackers]
    enabled = no
    [rpc]
    enabled = no
    [rssurlrewrite]
    enabled = no
    [rutracker_check]
    enabled = no
    [scheduler]
    enabled = no
    [screenshots]
    enabled = no
    [seedingtime]
    enabled = no
    [source]
    enabled = no
    EOF
    #----Fin du fichier configuration-------------
    #---------------------------------------------
     
    #-----Fichier Configuration .rtorrent.rc------
    #---------------------------------------------
    cat <<'EOF' > /$homedir/$user/.rtorrent.rc
    # Fichier de configuration de rtorrent.
     
    download_rate = 0
    upload_rate = 0
     
    directory = /home/@user@/downloads/complete
    session = /home/@user@/downloads/.session
    schedule = watch_directory,5,5,load_start=/home/@user@/downloads/watch/*.torrent
    schedule = untied_directory,5,5,stop_untied=
     
    port_range = 55995-56000
    port_random = no
     
    # check_hack sur 'yes' peut faire ramer le serveur
    check_hash = yes
     
    dht = disable
    peer_exchange = no
     
    #encryption = allow_incoming,require,require_rc4
    encryption = allow_incoming,enable_retry,prefer_plaintext
     
    # Ca, c'est nécessaire pour que rutorrent fonctionne
    scgi_port = localhost:5000
    EOF
    sed -i.bak "s/@user@/$user/g;" /$homedir/$user/.rtorrent.rc
    #----Fin du fichier configuration-------------
    #---------------------------------------------
     
    #---Creation du mot de passe de l'interface Rutorrent---
    #-------------------------------------------------------
    a2enmod auth_digest
    echo "${user}:rutorrent:"$(printf "${user}:rutorrent:${pwd}" | md5sum | awk '{print $1}') > $apachedir/htpasswd
     
     
    #----Debut de Creation des dossier------------
    #---------------------------------------------
    if [ ! -d $homedir/$user/downloads ]; then
    mkdir $homedir/$user/downloads
    chown $user:$user $homedir/$user/downloads
     
    else
    chown $user:$user $homedir/$user/downloads
    fi
     
     
    if [ ! -d $homedir/$user/downloads/complete ]; then
    mkdir $homedir/$user/downloads/complete
    chown $user:$user $homedir/$user/downloads/complete
     
    else
    chown $user:$user $homedir/$user/downloads/complete
    fi
     
    if [ ! -d $homedir/$user/downloads/watch ]; then
    mkdir $homedir/$user/downloads/watch
    chown $user:$user $homedir/$user/downloads/watch
     
    else
    chown $user:$user $homedir/$user/downloads/watch
    fi
     
    if [ ! -d $homedir/$user/downloads/.session ]; then
    mkdir $homedir/$user/downloads/.session
    chown $user:$user $homedir/$user/downloads/.session
     
    else
    chown $user:$user $homedir/$user/downloads/.session
    fi
    #--------------Fin de Creation des dossier---------
    #--------------------------------------------------
     
    # On instal Filemanager et  MediaStream
     
    cd $wwwdir/rutorrent/plugins
    svn co http://svn.rutorrent.org/svn/filemanager/trunk/mediastream
    svn co http://svn.rutorrent.org/svn/filemanager/trunk/filemanager
    mkdir -p $wwwdir/stream/
    ln -s $wwwdir/rutorrent/plugins/mediastream/view.php $wwwdir/stream/view.php
    sed -i.bak "s/mydomain.com/$ip/g;" /$wwwdir/rutorrent/plugins/mediastream/conf.php
     
    # FILEUPLOAD
     
    svn co http://svn.rutorrent.org/svn/filemanager/trunk/fileupload
    #----Permission Rutorrent-------------------- 
    #--------------------------------------------
     
    chown www-data: $wwwdir/stream
    chown www-data: $wwwdir/stream/view.php
    chown -R www-data:www-data $wwwdir/rutorrent
    chmod 775 fileupload/scripts/upload
     
    #---Configuration apache2--------------------
    #--------------------------------------------
    echo "
    # security
    ServerSignature Off
    ServerTokens Prod" >> $apachedir/apache2.conf
    sed -i.bak "s/Timeout 300/Timeout 30/g;" /$apachedir/apache2.conf
     
    # Installation du mode SGCI d'Apache (obligatoire pour rtorrent et rutorrent)
    echo SCGIMount /RPC2 127.0.0.1:5000 >> $apachedir/apache2.conf
     
    # SSl Configuration
     
    #Configuration du certificat ssl
    openssl req -new -x509 -days 3658 -nodes -newkey rsa:2048 -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem<<EOF
    RU
    Russia
    Moskva
    wrty
    wrty LTD
    wrty.com
    contact@wrty.com
    EOF
     
    chmod 600 $apachedir/apache.pem
     
    #Activation des module apache
     
    a2ensite default-ssl
    a2enmod ssl
    a2enmod scgi
     
    #-----Fichier Configuration default-----------
    #---------------------------------------------
    cat <<'EOF' > /$apachedir/sites-available/default
    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
     
            DocumentRoot /var/www/
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
     
            ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
            <Directory "/usr/lib/cgi-bin">
                    AllowOverride None
                    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                    Order allow,deny
                    Allow from all
            </Directory>
     
            ErrorLog /var/log/apache2/error.log
     
            # Possible values include: debug, info, notice, warn, error, crit,
            # alert, emerg.
            LogLevel warn
     
            CustomLog /var/log/apache2/access.log combined
     
        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from 127.0.0.0/255.0.0.0 ::1/128
        </Directory>
     
        <Location /rutorrent>
            AuthType Digest
            AuthName "rutorrent"
            AuthDigestDomain /var/www/rutorrent/ http://@ip@/rutorrent
     
            AuthDigestProvider file
            AuthUserFile /etc/apache2/htpasswd
            Require valid-user
            SetEnv R_ENV "/var/www/rutorrent"
        </Location>
     
    </VirtualHost>
    <IfModule mod_ssl.c>
    <VirtualHost *:443>
            ServerAdmin webmaster@localhost
     
            SSLEngine on
            SSLCertificateFile /etc/apache2/apache.pem
     
            DocumentRoot /var/www/
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
     
            ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
            <Directory "/usr/lib/cgi-bin">
                    AllowOverride None
                    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                    Order allow,deny
                    Allow from all
            </Directory>
     
            ErrorLog /var/log/apache2/error.log
     
            # Possible values include: debug, info, notice, warn, error, crit,
            # alert, emerg.
            LogLevel warn
     
            CustomLog /var/log/apache2/access.log combined
     
        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from 127.0.0.0/255.0.0.0 ::1/128
        </Directory>
        <Location /rutorrent>
            AuthType Digest
            AuthName "rutorrent"
            AuthDigestDomain /var/www/rutorrent/ http://<servername or IP>/rutorrent
     
            AuthDigestProvider file
            AuthUserFile /etc/apache2/htpasswd
            Require valid-user
            SetEnv R_ENV "/var/www/rutorrent"
         </Location>
    </VirtualHost>
    </IfModule>
    EOF
    sed -i.bak "s/@ip@/$ip/g;" /$apachedir/sites-available/default
    #----Fin du fichier configuration-------------
    #---------------------------------------------
     
    #-----Fichier Configuration rtorrent deamon---
    #---------------------------------------------
    cat <<'EOF' > /$initd/rtorrent
    ### BEGIN INIT INFO
    # Provides: chillispot et freeradius dans le chroot
    # Required-Start: \$local_fs \$network
    # Required-Stop: \$local_fs \$remote_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Wireless & LAN Access Point Controller
    # Description: ChilliSpot is an open source captive portal
    # or wireless LAN access point controller.
    ### END INIT INFO
    #!/bin/sh -e
    # Start/Stop rtorrent sous forme de daemon.
     
    NAME=rtorrent
    SCRIPTNAME=/etc/init.d/$NAME
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
     
    case $1 in
            start)
                    echo "Starting rtorrent... "
                    su -l @USER@ -c "screen -fn -dmS rtd nice -19 rtorrent"
                    echo "Terminated"
            ;;
            stop)
                    if [ "$(ps aux | grep -e '.*rtorrent$' -c)" != 0  ]; then
                    {
                            echo "Shutting down rtorrent... "
                            killall -r "^.*rtorrent$"
                            echo "Terminated"
                    }
                    else
                    {
                            echo "rtorrent not yet started !"
                            echo "Terminated"
                    }
                    fi
            ;;
            restart)
                    if [ "$(ps aux | grep -e '.*rtorrent$' -c)" != 0  ]; then
                    {
                            echo "Shutting down rtorrent... "
                            killall -r "^.*rtorrent$"
                            echo "Starting rtorrent... "
                            su -l @USER@ -c "screen -fn -dmS rtd nice -19 rtorrent"
                            echo "Terminated"
                    }
                    else
                    {
                            echo "rtorrent not yet started !"
                            echo "Starting rtorrent... "
                            su -l @USER@ -c "screen -fn -dmS rtd nice -19 rtorrent"
                            echo "Terminated"
                    }
                    fi
            ;;
            *)
                    echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
                    exit 2
            ;;
    esac
    EOF
    sed -i.bak "s/@user@/$user/g;" /$initd/rtorrent
    #----Fin du fichier configuration-------------
    #---------------------------------------------
     
    #Configuration rtorrent deamon
    chmod +x /$initd/rtorrent
    update-rc.d rtorrent defaults 99
     
     
     
     
    service apache2 reload
    clear
     
    # Demarrage de rtorrent
    su $user -c 'screen -d -m -U -fa -S rtorrent rtorrent'
    echo "--"
    echo " =========== FIN DE L'INSTALLATION ! On dirait que tout a fonctionne ! ==="
    echo "Username :$user"
    echo "Password :${pwd}"
    echo "-------------------------------"
    echo "-------------------------------"
    echo "Maintenant, rendez-vous sur Rutorrent"
    echo "https://$ip/rutorrent/"
    je début et ouvert a apprendre et au critique constructive

  2. #2
    Modérateur
    Avatar de N_BaH
    Profil pro
    Inscrit en
    Février 2008
    Messages
    7 578
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 7 578
    Points : 19 439
    Points
    19 439
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    #!/bin/bash
     
    clear
     
    #if [ $(id -u) -ne 0 ]
    if test $EUID -ne 0
    then
    #   echo
    #   echo "This script must be run as root." 1>&2
    #   echo
       printf '\n%s\n\n' "This script must be run as root" >&2
       exit 1
    fi
    # Ajouter un topo sur l'utilité du script?
     
    # demander nom et mot de passe
    read -p "Adding user now, please type your user name: " user
    read -s -p "Enter password: " pwd
    echo
     
    # ajout utilisateur
    useradd -m  -s /bin/bash "$user"
     
    # creation du mot de passe pour cet utilisateur
    echo "${user}:${pwd}" | chpasswd
     
    # gestionnaire de paquet
    if [ "`dpkg --status aptitude | grep Status:`" == "Status: install ok installed" ]
    then
       packetg="aptitude"
    else
       packetg="apt-get"
    fi
     
    ip=$(ip addr | grep eth0 | grep inet | awk '{print $2}' | cut -d/ -f1) # ah, non ! cf. http://www.developpez.net/forums/archive/index.php/t-882394.html
     
    # test -z "$homedir" || homedir="/home"
    #ou encore: 
    # : ${homedir:="/home"}
    if [ -z $homedir ]
    then
       homedir="/home"
    fi
    if [ -z $wwwdir ]
    then
       wwwdir="/var/www"
    fi
    if [ -z $apachedir ]
    then
       apachedir="/etc/apache2"
    fi
    if [ -z $initd ]
    then
       initd="/etc/init.d"
    fi
     
    ##Log de l'instalation
    exec 2>/$homedir/$user/log
     
    # Ajoute des depots non-free
    echo "deb http://ftp.fr.debian.org/debian/ wheezy main contrib non-free
    deb-src http://ftp.fr.debian.org/debian/ wheezy main contrib non-free" >> /etc/apt/sources.list
     
    # Installation des paquets vitaux
    $packetg update
    $packetg install -y  apache2 apache2-utils autoconf build-essential ca-certificates comerr-dev libapache2-mod-php5 libcloog-ppl-dev libcppunit-dev libcurl3 libcurl4-openssl-dev libncurses5-dev ncurses-base ncurses-term libterm-readline-gnu-perl libsigc++-2.0-dev libssl-dev libtool libxml2-dev ntp openssl patch libperl-dev php5 php5-cli php5-dev php5-fpm php5-curl php5-geoip php5-mcrypt php5-xmlrpc pkg-config python-scgi dtach ssl-cert subversion unrar zlib1g-dev pkg-config unzip htop irssi curl cfv rar zip ffmpeg mediainfo git screen perl libapache2-mod-scgi
     
    ##  Installation XMLRPC Libtorrent Rtorrent Plowshare
     
    # XMLRPC
     
    svn checkout http://svn.code.sf.net/p/xmlrpc-c/code/stable xmlrpc-c
    cd xmlrpc-c
    ./configure --prefix=/usr --enable-libxml2-backend --disable-libwww-client --disable-wininet-client --disable-abyss-server --disable-cgi-server
    make
    make install
    cd ..
    rm -rv xmlrpc-c
     
    # Libtorrent
     
    wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.2.tar.gz
    tar -zxvf libtorrent-0.13.2.tar.gz
    cd libtorrent-0.13.2
    ./autogen.sh
    ./configure
    make
    make install
    cd ..
    rm -rv libtorrent-0.13.2*
     
    # Rtorrent
     
    wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.9.2.tar.gz
    tar -zxvf rtorrent-0.9.2.tar.gz
    cd rtorrent-0.9.2
    ./autogen.sh
    ./configure --with-xmlrpc-c
    make
    make install
    ldconfig
    cd  ..
    rm -rv rtorrent-0.9.2*
     
    # Plowshare
    cd    /$homedir
    git clone https://code.google.com/p/plowshare/ plowshare4
    cd plowshare4
    make install
     
    #------------Instalation de Rutorrent--------
    #--------------------------------------------
     
    cd $wwwdir/
    svn checkout http://rutorrent.googlecode.com/svn/trunk/rutorrent
    svn checkout http://rutorrent.googlecode.com/svn/trunk/plugins
     
    find $wwwdir/rutorrent -depth -name plugins -type d -exec rm -rf '{}' \;
    mv plugins rutorrent/
     
    #-----Fichier Configuration Config.php--------
    #---------------------------------------------
    echo "<?php
    // configuration parameters
     
    // for snoopy client
    @define('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0', true);
    @define('HTTP_TIME_OUT', 30, true);     // in seconds
    @define('HTTP_USE_GZIP', true, true);
    \$httpIP = null;                                // IP string. Or null for any.
     
    @define('RPC_TIME_OUT', 5, true);       // in seconds
     
    @define('LOG_RPC_CALLS', false, true);
    @define('LOG_RPC_FAULTS', true, true);
     
    // for php
    @define('PHP_USE_GZIP', false, true);
    @define('PHP_GZIP_LEVEL', 2, true);
     
    \$do_diagnostic = true;
    \$log_file = '/tmp/rutorrent_errors.log';               // path to log file (comment or leave blank to disable logging)
     
    \$saveUploadedTorrents = true;          // Save uploaded torrents to profile/torrents directory or not
    \$overwriteUploadedTorrents = false;     // Overwrite existing uploaded torrents in profile/torrents directory or make unique name
     
    \$topDirectory = '/home/$user/downloads';                       // Upper available directory. Absolute path with trail slash.
    \$forbidUserSettings = false;
     
    \$scgi_port = 5000;
    \$scgi_host = \"127.0.0.1\";
     
    // For web->rtorrent link through unix domain socket
    // (scgi_local in rtorrent conf file), change variables
    // above to something like this:
    //
    //\$scgi_port = 0;
    //\$scgi_host = \"unix:///tmp/rtorrent.sock\";
     
    \$XMLRPCMountPoint = \"/RPC2\";         // DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!!
     
    \$pathToExternals = array(
    \"php\"  => '/usr/bin/php',                     // Something like /usr/bin/php. If empty, will be found in PATH.
    \"curl\" => '/usr/bin/curl',                    // Something like /usr/bin/curl. If empty, will be found in PATH.
    \"gzip\" => '/bin/gzip',                        // Something like /usr/bin/gzip. If empty, will be found in PATH.
    \"id\"   => '/usr/bin/id',                      // Something like /usr/bin/id. If empty, will be found in PATH.
    \"stat\" => '/usr/bin/stat',                    // Something like /usr/bin/stat. If empty, will be found in PATH.
    );
     
    \$localhosts = array(                   // list of local interfaces
    \"127.0.0.1\",
    \"localhost\",
    );
     
    \$profilePath = '../share';             // Path to user profiles
    \$profileMask = 0777;                   // Mask for files and directory creation in user profiles.
    // Both Webserver and rtorrent users must have read-write access to it.
    // For example, if Webserver and rtorrent users are in the same group then the value may be 0770.
     
    ?>" > /$wwwdir/rutorrent/conf/config.php
    #----Fin du fichier configuration------------- 
    #---------------------------------------------
     
    #-----Fichier Configuration plugins.ini-------
    #---------------------------------------------
    echo "
    ;; Plugins' permissions.
    ;; If flag is not found in plugin section, corresponding flag from "default" section is used.
    ;; If flag is not found in "default" section, it is assumed to be "yes".
    ;;
    ;; For setting individual plugin permissions you must write something like that:
    ;;
    ;; [ratio]
    ;; enabled = yes        ;; also may be "user-defined", in this case user can control plugin's state from UI
    ;; canChangeToolbar = yes
    ;; canChangeMenu = yes
    ;; canChangeOptions = no
    ;; canChangeTabs = yes
    ;; canChangeColumns = yes
    ;; canChangeStatusBar = yes
    ;; canChangeCategory = yes
    ;; canBeShutdowned = yes
     
    [default]
    enabled = user-defined
    canChangeToolbar = yes
    canChangeMenu = yes
    canChangeOptions = yes
    canChangeTabs = yes
    canChangeColumns = yes
    canChangeStatusBar = yes
    canChangeCategory = yes
    canBeShutdowned = yes
     
    ;; Default
     
    [_getdir]
    enabled = yes
    [cpuload]
    enabled = user-defined
    [create]
    enabled = user-defined
    [datadir]
    enabled = yes
    [diskspace]
    enabled = user-defined
    [erasedata]
    enabled = user-defined
    [show_peers_like_wtorrent]
    enabled = user-defined
    [theme]
    enabled = yes
    [tracklabels]
    enabled = user-defined
    [trafic]
    enabled = user-defined
     
    ;; Enabled
     
    [autotools]
    enabled = user-defined
    [cookies]
    enabled = user-defined
    [data]
    enabled = user-defined
    [edit]
    enabled = user-defined
    [extratio]
    enabled = user-defined
    [extsearch]
    enabled = user-defined
    [filedrop]
    enabled = user-defined
    [filemanager]
    enabled = user-defined
    [geoip]
    enabled = user-defined
    [httprpc]
    enabled = yes
    canBeShutdowned = no
    [pausewebui]
    enabled = yes
    [ratio]
    enabled = user-defined
    [ratiocolor]
    enabled = user-defined
    [rss]
    enabled = user-defined
    [_task]
    enabled = yes
    [throttle]
    enabled = user-defined
    [titlebar]
    enabled = user-defined
    [unpack]
    enabled = user-defined
     
    ;; Disabled
     
    [chat]
    enabled = no
    [chunks]
    enabled = no
    [feeds]
    enabled = no
    [fileshare]
    enabled = no
    [fileupload]
    enabled = yes
    [history]
    enabled = no
    [instantsearch]
    enabled = no
    [ipad]
    enabled = no
    [logoff]
    enabled = no
    [loginmgr]
    enabled = no
    [mediainfo]
    enabled = yes
    [mediastream]
    enabled = yes
    [check_port]
    enabled = no
    [retrackers]
    enabled = no
    [rpc]
    enabled = no
    [rssurlrewrite]
    enabled = no
    [rutracker_check]
    enabled = no
    [scheduler]
    enabled = no
    [screenshots]
    enabled = no
    [seedingtime]
    enabled = no
    [source]
    enabled = no
    " > $wwwdir/rutorrent/conf/plugins.ini
    #----Fin du fichier configuration-------------
    #---------------------------------------------
     
    #-----Fichier Configuration .rtorrent.rc------
    #---------------------------------------------
    echo "
    # Fichier de configuration de rtorrent.
     
    download_rate = 0
    upload_rate = 0
     
    directory = /home/$user/downloads/complete
    session = /home/$user/downloads/.session
    schedule = watch_directory,5,5,load_start=/home/$user/downloads/watch/*.torrent
    schedule = untied_directory,5,5,stop_untied=
     
    port_range = 55995-56000
    port_random = no
     
    # check_hack sur 'yes' peut faire ramer le serveur
    check_hash = yes
     
    dht = disable
    peer_exchange = no
     
    #encryption = allow_incoming,require,require_rc4
    encryption = allow_incoming,enable_retry,prefer_plaintext
     
    # Ca, c'est nécessaire pour que rutorrent fonctionne
    scgi_port = localhost:5000
    " >> $homedir/$user/.rtorrent.rc
     
    #----Fin du fichier configuration-------------
    #---------------------------------------------
     
    #---Creation du mot de passe de l'interface Rutorrent---
    #-------------------------------------------------------
    a2enmod auth_digest
    echo "${user}:rutorrent:"$(printf "${user}:rutorrent:${pwd}" | md5sum | awk '{print $1}') > $apachedir/htpasswd
     
     
    #----Debut de Creation des dossier------------
    #---------------------------------------------
    if [ ! -d $homedir/$user/downloads ]; then # même remarque que précédemment sur les tests simples : le ``if'' n'est pas nécessaire.
       mkdir $homedir/$user/downloads
    #   chown $user.$user $homedir/$user/downloads
    #else
    #   chown $user.$user $homedir/$user/downloads
    fi
    chown $user.$user $homedir/$user/downloads # dans les deux cas cela doit être fait, donc ça ne doit pas être dans la condition.
     
    if [ ! -d $homedir/$user/downloads/complete ]; then # idem
       mkdir $homedir/$user/downloads/complete
       chown $user.$user $homedir/$user/downloads/complete # idem
     
    else
       chown $user.$user $homedir/$user/downloads/complete # idem
    fi
     
    if [ ! -d $homedir/$user/downloads/watch ]; then # etc; une boucle plutôt qu'une suite de condition ?
       mkdir $homedir/$user/downloads/watch
       chown $user.$user $homedir/$user/downloads/watch
     
    else
       chown $user.$user $homedir/$user/downloads/watch
    fi
     
    if [ ! -d $homedir/$user/downloads/.session ]; then
       mkdir $homedir/$user/downloads/.session
       chown $user.$user $homedir/$user/downloads/.session
     
    else
       chown $user.$user $homedir/$user/downloads/.session
    fi
    #--------------Fin de Creation des dossier---------
    #--------------------------------------------------
     
    # On instal Filemanager et  MediaStream
     
    cd $wwwdir/rutorrent/plugins
    svn co http://svn.rutorrent.org/svn/filemanager/trunk/mediastream
    svn co http://svn.rutorrent.org/svn/filemanager/trunk/filemanager
    mkdir -p $wwwdir/stream/
    ln -s $wwwdir/rutorrent/plugins/mediastream/view.php $wwwdir/stream/view.php
    perl -e "s/mydomain.com/$ip/g;" -pi.bak $(find /var/www/rutorrent/plugins/mediastream/conf.php -type f)
     
    # FILEUPLOAD
     
    svn co http://svn.rutorrent.org/svn/filemanager/trunk/fileupload
    #----Permission Rutorrent-------------------- 
    #--------------------------------------------
     
    chown www-data: $wwwdir/stream
    chown www-data: $wwwdir/stream/view.php
    chown -R www-data:www-data $wwwdir/rutorrent
    chmod 775 fileupload/scripts/upload
     
    #---Configuration apache2--------------------
    #--------------------------------------------
    echo "
    # security
    ServerSignature Off
    ServerTokens Prod" >> $apachedir/apache2.conf
    perl -e "s/Timeout 300/Timeout 30/g;" -pi.bak $(find $apachedir/apache2.conf -type f)
     
    # Installation du mode SGCI d'Apache (obligatoire pour rtorrent et rutorrent)
    echo SCGIMount /RPC2 127.0.0.1:5000 >> $apachedir/apache2.conf
     
    # SSl Configuration
     
    #Configuration du certificat ssl
    openssl req -new -x509 -days 3658 -nodes -newkey rsa:2048 -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem<<EOF
    RU
    Russia
    Moskva
    wrty
    wrty LTD
    wrty.com
    contact@wrty.com
    EOF
     
    chmod 600 $apachedir/apache.pem
     
    #Activation des module apache
     
    a2ensite default-ssl
    a2enmod ssl
    a2enmod scgi
     
    #-----Fichier Configuration default-----------
    #---------------------------------------------
    echo "<VirtualHost *:80>
    ServerAdmin webmaster@localhost
     
    DocumentRoot /var/www/
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    <Directory /var/www/>
    Options -Indexes
    AllowOverride all
    Order allow,deny
    allow from all
    </Directory>
     
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
    </Directory>
     
    ErrorLog /var/log/apache2/error.log
     
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
     
    CustomLog /var/log/apache2/access.log combined
     
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
    Options -Indexes
    AllowOverride all
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
     
    <Location /rutorrent>
    AuthType Digest
    AuthName "rutorrent"
    AuthDigestDomain /var/www/rutorrent/ http://$ip/rutorrent
     
    AuthDigestProvider file
    AuthUserFile /etc/apache2/htpasswd
    Require valid-user
    SetEnv R_ENV "/var/www/rutorrent"
    </Location>
     
    </VirtualHost>
     
    <IfModule mod_ssl.c>
    <VirtualHost *:443>
    ServerAdmin webmaster@localhost
     
    SSLEngine on
    SSLCertificateFile /etc/apache2/apache.pem
     
    DocumentRoot /var/www/
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    </Directory>
     
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
    </Directory>
     
    ErrorLog /var/log/apache2/error.log
     
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
     
    CustomLog /var/log/apache2/access.log combined
     
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
    <Location /rutorrent>
    AuthType Digest
    AuthName "rutorrent"
    AuthDigestDomain /var/www/rutorrent/ http://$ip/rutorrent
     
    AuthDigestProvider file
    AuthUserFile /etc/apache2/htpasswd
    Require valid-user
    SetEnv R_ENV "/var/www/rutorrent"
    </Location>
    </VirtualHost>
    </IfModule>" > $apachedir/sites-available/default
     
    #----Fin du fichier configuration-------------
    #---------------------------------------------
     
    #-----Fichier Configuration rtorrent deamon---
    #---------------------------------------------
    echo "### BEGIN INIT INFO
    # Provides: chillispot et freeradius dans le chroot
    # Required-Start: \$local_fs \$network
    # Required-Stop: \$local_fs \$remote_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Wireless & LAN Access Point Controller
    # Description: ChilliSpot is an open source captive portal
    # or wireless LAN access point controller.
    ### END INIT INFO
    #!/bin/sh -e
    # Start/Stop rtorrent sous forme de daemon.
     
    NAME=rtorrent
    SCRIPTNAME=/etc/init.d/$NAME
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
     
    case \$1 in
       start)
          echo \"Starting rtorrent... \"
          su -l $user -c \"screen -fn -dmS rtd nice -19 rtorrent\"
          echo \"Terminated\"
          ;;
       stop)
          if [ \"\$(ps aux | grep -e '.*rtorrent\$' -c)\" != 0  ]; then
             {
                echo \"Shutting down rtorrent... \"
                killall -r \"^.*rtorrent\$\"
                echo \"Terminated\"
             }
          else
             {
                echo \"rtorrent not yet started !\"
                echo \"Terminated\"
             }
          fi
          ;;
       restart)
          if [ \"\$(ps aux | grep -e '.*rtorrent$' -c)\" != 0  ]; then
             {
                echo \"Shutting down rtorrent... \"
                killall -r \"^.*rtorrent\$\"
                echo \"Starting rtorrent... \"
                su -l $user -c \"screen -fn -dmS rtd nice -19 rtorrent\"
                echo \"Terminated\"
             }
          else
             {
                echo \"rtorrent not yet started !\"
                echo \"Starting rtorrent... \"
                su -l $user -c \"screen -fn -dmS rtd nice -19 rtorrent\"
                echo \"Terminated\"
             }
          fi
          ;;
       *)
          echo \"Usage: \$SCRIPTNAME {start|stop|restart}\" >&2
          exit 2
          ;;
    esac" > /$initd/rtorrent
     
    #----Fin du fichier configuration-------------
    #---------------------------------------------
     
    #Configuration rtorrent deamon
    chmod +x /$initd/rtorrent
    update-rc.d rtorrent defaults 99
     
    service apache2 reload
    clear
     
    # Demarrage de rtorrent
    su $user -c 'screen -d -m -U -fa -S rtorrent rtorrent'
    echo "--"
    echo " =========== FIN DE L'INSTALLATION ! On dirait que tout a fonctionne ! ==="
    echo "Username :$user"
    echo "Password :${pwd}"
    echo "-------------------------------"
    echo "-------------------------------"
    echo "Maintenant, rendez-vous sur Rutorrent"
    echo "https://$ip/rutorrent/"
    perso, je sortirais les configurations du script pour les mettre dans des fichiers annexes, et utiliserais la méthode donnée par disedorgue.
    ce serait aussi plus facile de les modifier, au lieu d'ouvrir le script, et risquer une fausse manip.
    .
    N'oubliez pas de consulter les cours shell, la FAQ, et les pages man.

  3. #3
    Modérateur
    Avatar de jlliagre
    Homme Profil pro
    Ingénieur support avancé & développement
    Inscrit en
    Juin 2007
    Messages
    2 695
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur support avancé & développement
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 695
    Points : 7 842
    Points
    7 842
    Par défaut
    Quelques remarques:

    - pas de gestion des erreurs (ex: si "wget", "apt-get install", "svn checkout" échouent, on continue quand même)
    - on ajoute les dépots non-free même s'ils y étaient déja
    - le script assume que l'interface à utiliser est eth0
    - les double-quotes ne sont pas préservées dans:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    echo "
    ...
    ;; If flag is not found in plugin section, corresponding flag from "default" section is used.
    ...
    Sans conséquence ici car il s'agit d'un commentaire. Idem plus loin:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    echo "
    ...
    <Directory "/usr/lib/cgi-bin">
    - le séparateur entre le nom d'utilisateur et groupe dans chown est ":", tu as parfois mis "." qui fonctionne avec GNU chown mais n'est pas documenté.

    - il vaut mieux utiliser $(...) que `xxx`
    - quelques problèmes d'indentation (absente ou superflue)
    ɹǝsn *sıɹɐlos*

  4. #4
    Membre à l'essai
    Profil pro
    Inscrit en
    Juillet 2013
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juillet 2013
    Messages : 38
    Points : 14
    Points
    14
    Par défaut
    erso, je sortirais les configurations du script pour les mettre dans des fichiers annexes, et utiliserais la méthode donnée par disedorgue.
    ce serait aussi plus facile de les modifier, au lieu d'ouvrir le script, et risquer une fausse manip.
    que veut tu dire ? comment les traiter ?

    jlliagre dans tout les problème cité du moins les plus importent commet les réglé ? pour l'ip surtout

  5. #5
    Modérateur
    Avatar de N_BaH
    Profil pro
    Inscrit en
    Février 2008
    Messages
    7 578
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 7 578
    Points : 19 439
    Points
    19 439
    .
    N'oubliez pas de consulter les cours shell, la FAQ, et les pages man.

  6. #6
    Membre à l'essai
    Profil pro
    Inscrit en
    Juillet 2013
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juillet 2013
    Messages : 38
    Points : 14
    Points
    14
    Par défaut
    merci n'avais pas vu le post je vais regarder cela

    - le séparateur entre le nom d'utilisateur et groupe dans chown est ":", tu as parfois mis "." qui fonctionne avec GNU chown mais n'est pas documenté.
    Donc vous recommander ":" pour tout chown ?

  7. #7
    Modérateur
    Avatar de jlliagre
    Homme Profil pro
    Ingénieur support avancé & développement
    Inscrit en
    Juin 2007
    Messages
    2 695
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur support avancé & développement
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 695
    Points : 7 842
    Points
    7 842
    Par défaut
    Citation Envoyé par debdarky Voir le message
    Donc vous recommander ":" pour tout chown ?
    Oui, voici ce que dit la doc du chown de GNU:
    New scripts should avoid the use of `.' because it is not portable, and because it has undesirable results if the entire OWNER`.'GROUP happens to identify a user whose name contains `.'.
    ɹǝsn *sıɹɐlos*

  8. #8
    Membre à l'essai
    Profil pro
    Inscrit en
    Juillet 2013
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juillet 2013
    Messages : 38
    Points : 14
    Points
    14
    Par défaut
    merci donc vais faire le nécessaire pour corriger cela


    le script assume que l'interface à utiliser est eth0
    je dois avouer j'ai reçu quel que critique pour mon chois de cette ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ip=$(ip addr | grep eth0 | grep inet | awk '{print $2}' | cut -d/ -f1)
    pour le ip j pensez a ce qui suis

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    #!/bin/bash
    read -p "entrer vottre ip: " ip
        echo
     
     
    echo mon ip est :$ip
    comme cela 1 l'utilisateur peut entrer son ip et on est sure que le ip est présent avec $ip si l'utilisateur utilise pas etho

  9. #9
    Modérateur
    Avatar de N_BaH
    Profil pro
    Inscrit en
    Février 2008
    Messages
    7 578
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 7 578
    Points : 19 439
    Points
    19 439
    Par défaut
    lister les interfaces actives, et proposer à l'utilisateur de choisir celle à utiliser
    ...
    ?


    par ailleurs, ça : perl -e "s/mydomain.com/$ip/g;" -pi.bak $(find /var/www/rutorrent/plugins/mediastream/conf.php -type f) ne sert à rien (au moins le find ):
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    sed -i.bak "s/mydomain.com/$ip/g;" /var/www/rutorrent/plugins/mediastream/conf.php
    puisque tu sais où est le fichier à modifier, et sed est peut-être un peu plus léger que perl (c'est juste une impression : je n'utilise pas perl).
    .
    N'oubliez pas de consulter les cours shell, la FAQ, et les pages man.

  10. #10
    Membre à l'essai
    Profil pro
    Inscrit en
    Juillet 2013
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juillet 2013
    Messages : 38
    Points : 14
    Points
    14
    Par défaut
    re bonjour

    merci vais changer cela aussi pour l'ip j'ai fait un bon debut

    voila le nouveau code pour détecter l'ip
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ip=$(ip route get 10.10.10.10 | awk '/src/{sub("/.*","",$NF); print $NF}')
    Ici il devrait avoir un code pour poser une question qui est
    voulez-vous gardez l'ip 192.168.1.1 ou entrer manuellement votre ip ?
    mais je ne sais pas comment faire pour le moment

    si le chois de l'utilisateur est de rentrer manuellement le code suivent est la

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    #!/bin/bash
     
    read -p "votre ip: " ip
        echo
     
    if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
      echo "vottre ip est valide"
    else
    echo  "Votre ip n'est pas valide"
      exit 1 (je ne sais pas comment retournée a l’action précédente en cas d'erreur)
     
    fi
     
    echo ton ip est:$ip

  11. #11
    Modérateur
    Avatar de N_BaH
    Profil pro
    Inscrit en
    Février 2008
    Messages
    7 578
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 7 578
    Points : 19 439
    Points
    19 439
    Par défaut
    Code bash : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    $ ip="123.456.789.123456"
    $ ipPat="^([0-9]{1,3}\.){3}[0-9]{1,3}$"
    $ [[ $ip =~ $ipPat ]]
    $ echo $?
    1
    $ ip="123.456.789.123"
    $ [[ $ip =~ $ipPat ]]
    $ echo $?
    0
    Code bash : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    until [[ $answer =~ [oO] ]]
    do
       read -p 'ça correspond à ta demande (o/n)'  answer
    done
    .
    N'oubliez pas de consulter les cours shell, la FAQ, et les pages man.

  12. #12
    Membre à l'essai
    Profil pro
    Inscrit en
    Juillet 2013
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juillet 2013
    Messages : 38
    Points : 14
    Points
    14
    Par défaut
    je ne comprend pas ton code ?

    je partais pour édité mon poste j'ai fait des modification et cela fonctionne

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    #!/bin/bash
     
    ip1=$(ip route get 10.10.10.10 | awk '/src/{sub("/.*","",$NF); print $NF}')
     
    echo ton IP est $ip1 entrer  votre IP ou remplacer le ip par défaut 
    name="$ip1"
    read -e -i "$name" -p "entrez votre ip: " ip
    name="${input:-$name}"
     echo
     
     
    if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
      echo "ton IP est valide"
    else
    echo  "ton IP n'est pas valide"
      exit 1
     
    fi
     
    echo mon ip est :$ip

  13. #13
    Modérateur
    Avatar de N_BaH
    Profil pro
    Inscrit en
    Février 2008
    Messages
    7 578
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 7 578
    Points : 19 439
    Points
    19 439
    Par défaut
    ta regex ne vérifie pas le nombre de chiffre de l'ip, elle validerait n'importe quel nombre de chiffres par série de quatre séparée par des points.

    tu n'as pas de shell pour tester les codes qu'on te donne ?
    tu copies, tu modifies, tu observes, tu finiras par comprendre.
    .
    N'oubliez pas de consulter les cours shell, la FAQ, et les pages man.

  14. #14
    Membre à l'essai
    Profil pro
    Inscrit en
    Juillet 2013
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juillet 2013
    Messages : 38
    Points : 14
    Points
    14
    Par défaut
    problème de l"ip résolu

    j'ai utiliser ta regex j'ai fait 2 test

    test 1 ip valide
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    root@debian:~# ./test.bak
    ton IP est 192.168.231.128 entrer votre IP ou remplacer le ip par défaut
    entrez votre ip: 192.168.231.128
     
    ton IP est valide
    mon ip est :192.168.231.128
    root@debian:~#
    test 2 ip non valide
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    root@debian:~# ./test.bak
    ton IP est 192.168.231.128 entrer votre IP ou remplacer le ip par défaut
    entrez votre ip: 1923.4587.8993.333
     
    ton IP n'est pas valide
    le limité a 255 serais le Best mais déjà bien

  15. #15
    Expert éminent sénior Avatar de disedorgue
    Homme Profil pro
    Ingénieur intégration
    Inscrit en
    Décembre 2012
    Messages
    4 299
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur intégration
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Décembre 2012
    Messages : 4 299
    Points : 12 783
    Points
    12 783
    Par défaut
    Bonjour,

    Pour la regex, ceci devrait fonctionner:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ipPat="^((2([0-4][0-9]|5[0-5])|[0-1]{0,1}[0-9]{1,2})\.){3}(2([0-4][0-9]|5[0-5])|[0-1]{0,1}[0-9]{1,2})$"
    Sinon, personnellement, je n'aime pas trop l'option -p de read, car si on utilise des pipes nommés pour par exemple faire un automate, on ne peut pas capturer les messages liés au -p. Mais bon, c'est une autre histoire.

    Dans ton script, je vois aussi pas mal de dépendance en dur à des package ou des lib qui sont récupérés sur des sites dédiés. En général, il est conseillé de soit se débrouiller pour que le script charge la dernière version stable et compatible, soit au pire de variabiliser ces noms en début de fichier ou de les mettre dans le fichier de variables comme suggéré par N_BaH.
    Cordialement.

  16. #16
    Membre à l'essai
    Profil pro
    Inscrit en
    Juillet 2013
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juillet 2013
    Messages : 38
    Points : 14
    Points
    14
    Par défaut
    merci pour cette regex

    maintenant vais voir comment faire pour mais, fichier configuration

    Edit

    bon après avoir observer le code de disedorgue

    je vais explique ce que je crois comprendre pour etre sure

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    $ cat tcat.sh
    #!/bin/bash
    "Toto=titi c'est la création de la variable "
    "sed "s/@@Toto@@/$Toto/g" <<'EOF' ensuite avec sed  injecter la variable"
    $Toto
    \$Toto
    "@@Toto@@ sert à introduire l'information sans variable dans le fichier configuration"
    EOF
    et donc pas de protection de fichier a faire bien sa

    edit 2

    bon je viens de terminé les modification pour les fichier configuration
    j'ai fait un Edit du code du premier code (pas terminé )

  17. #17
    Expert éminent sénior
    Avatar de Sve@r
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2006
    Messages
    12 720
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Février 2006
    Messages : 12 720
    Points : 31 037
    Points
    31 037
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par debdarky Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
      echo "ton IP est valide"
    else
    echo  "ton IP n'est pas valide"
      exit 1
     
    fi
     
    echo mon ip est :$ip
    Bonjour

    Perso je trouve plus lisible, dans le cas de gestion d'erreurs comme ici, de mettre l'erreur en premier cas
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    if [[ $ip !=~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
      echo  "ton IP n'est pas valide"
      exit 1
    fi
     
    echo "ton IP est valide"
    echo mon ip est :$ip
    Ca permet de regrouper ensemble le code gérant la suite des évènements (dans le cas normal)...
    Mon Tutoriel sur la programmation «Python»
    Mon Tutoriel sur la programmation «Shell»
    Sinon il y en a pleins d'autres. N'oubliez pas non plus les différentes faq disponibles sur ce site
    Et on poste ses codes entre balises [code] et [/code]

  18. #18
    Modérateur
    Avatar de N_BaH
    Profil pro
    Inscrit en
    Février 2008
    Messages
    7 578
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 7 578
    Points : 19 439
    Points
    19 439
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    if ! [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
    !=~ = bash: Erreur de syntaxe près de « !=~ »
    .
    N'oubliez pas de consulter les cours shell, la FAQ, et les pages man.

  19. #19
    Expert éminent sénior Avatar de disedorgue
    Homme Profil pro
    Ingénieur intégration
    Inscrit en
    Décembre 2012
    Messages
    4 299
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur intégration
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Décembre 2012
    Messages : 4 299
    Points : 12 783
    Points
    12 783
    Par défaut
    Citation Envoyé par debdarky Voir le message

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    $ cat tcat.sh
    #!/bin/bash
    "Toto=titi c'est la création de la variable "
    "sed "s/@@Toto@@/$Toto/g" <<'EOF' ensuite avec sed  injecter la variable"
    $Toto
    \$Toto
    "@@Toto@@ sert à introduire l'information sans variable dans le fichier configuration"
    EOF
    et donc pas de protection de fichier a faire bien sa
    Oui, c'est bien ça, mais il serait mieux d'avoir des fichiers template plutot que d'intégrer les template dans le script, cela donnerait quelque chose l'exemple suivant:
    Le template:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    $ cat tcat.tpl
    $topDirectory = '/home/@@user@@/downloads';                       // Upper available directory. Absolute path with trail slash.
    $forbidUserSettings = false;
     
    $group = "@@group@@";
     
    $scgi_port = 5000;
    $scgi_host = "127.0.0.1";
     
    // For web->rtorrent link through unix domain socket
    // (scgi_local in rtorrent conf file), change variables
    // above to something like this:
    //
    //$scgi_port = 0;
    //$scgi_host = "unix:///tmp/rtorrent.sock";
    Le script:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    $ cat tcat.sh
    #!/bin/bash
     
    Template1="./tcat.tpl"
    ResultTpl1="./tcat.php"
     
    Var1="titi"
    Var2="tati"
     
    cp "${Template1}" "${ResultTpl1}"
    # ici on verifie que la copie est ok
     
    sed -i "s/@@user@@/${Var1}/g" "${ResultTpl1}"
    sed -i "s/@@group@@/${Var2}/g" "${ResultTpl1}"
    Le résultat:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    $ ./tcat.sh
    $ cat tcat.php
    $topDirectory = '/home/titi/downloads';                       // Upper available directory. Absolute path with trail slash.
    $forbidUserSettings = false;
     
    $group = "tati";
     
    $scgi_port = 5000;
    $scgi_host = "127.0.0.1";
     
    // For web->rtorrent link through unix domain socket
    // (scgi_local in rtorrent conf file), change variables
    // above to something like this:
    //
    //$scgi_port = 0;
    //$scgi_host = "unix:///tmp/rtorrent.sock";
    Comme tu peux le voir, les variables ont été définies au début du script mais rien n'empêche de les mettre dans un fichier à part et de sourcer celui-ci dans le script.
    Voila, à toi de jouer
    Cordialement.

  20. #20
    Rédacteur

    Avatar de ok.Idriss
    Homme Profil pro
    IS Consultant
    Inscrit en
    Février 2009
    Messages
    5 220
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : IS Consultant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2009
    Messages : 5 220
    Points : 19 452
    Points
    19 452
    Par défaut
    Bonjour.

    Citation Envoyé par N_BaH Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    if ! [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
    !=~ = bash: Erreur de syntaxe près de « !=~ »
    Ou autre solution :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
      echo  "ton IP n'est pas valide"
      exit 1
    }
    Pour perdre un peu en lisibilité (fin moi j'aime bien)


Discussions similaires

  1. Vos avis sur mon site de jeux : http://kor6k.free.fr
    Par kor6k dans le forum Mon site
    Réponses: 1
    Dernier message: 28/08/2007, 20h05
  2. Vos avis sur mon site
    Par kodokan dans le forum Mon site
    Réponses: 11
    Dernier message: 10/10/2006, 21h06
  3. Réponses: 1
    Dernier message: 06/10/2006, 21h03
  4. [Sécurité] Vos avis sur mes scripts sécurisés
    Par nazoreen dans le forum Langage
    Réponses: 9
    Dernier message: 29/09/2006, 22h13
  5. Vos avis sur mon site perso
    Par Fildz dans le forum Mon site
    Réponses: 12
    Dernier message: 19/08/2006, 22h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo