This shows you the differences between two versions of the page.
gsr:laboratoare:laborator-12 [2013/08/23 00:12] 127.0.0.1 external edit |
gsr:laboratoare:laborator-12 [2015/02/06 16:26] (current) alexandru.carp |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Laborator 12 - Servicii pentru dezvoltatori ====== | + | ~~SHOWSOLUTION~~ |
+ | ====== Laborator 12 - Recapitulare ====== | ||
- | *Pentru acomodare cu Git consultați [[http://elf.cs.pub.ro/pisr/res/doc/git_internal.pdf | tutorialul din documentație]] sau [[http://gitimmersion.com/index.html | Git Immersion]]. | + | ===== Pachete ===== |
- | ===== 1. Operații de bază Git. Git peste SSH (2p) ===== | + | *Listati pachetele din repository-ul implicit debian care incep cu sirul "di". |
+ | *Instalati pachetul zim fara a fi nevoiti sa raspundeti la confirmarea instalarii. | ||
+ | *Instalati pachetul nmap. | ||
+ | *Dezinstalați pachetul nmap. Descarcati local pachetul .deb asosciat utilitarului nmap. | ||
+ | *Instalati pachetul .deb asociat utilitarului nmap folosind dpkg. | ||
+ | *Descărcați folosind apt-get sursele pachetului libssh2-1. | ||
+ | *Descarcati de pe site-ul de baza ultimele surse ale utilitarului transmission. | ||
+ | *Instalati pachetul build-essential. | ||
+ | *Compilati din surse utilitarul transmission. | ||
+ | *Instalati pachetul apache2. | ||
+ | *Ce pachete au fost instalate? (cautati dupa '*apache*') | ||
+ | *Ce fisiere contine pachetul apache2.2-common? | ||
+ | *Ce utilitar este folosit pentru a cauta un fisier in pachetele din repository? (Hint: 'package searching') | ||
+ | *Ce pachet contine fisierul header gdk.h? | ||
- | *Comenzi/concepte/fișiere | + | ===== Low-level și hardware ===== |
- | *git config | + | |
- | *git init | + | |
- | *git add | + | |
- | *git commit | + | |
- | *git push | + | |
- | *git clone | + | |
- | *git remote | + | |
+ | *Care sunt fisierele de tip block device asociate hard disk-urilor si CD-ROM drive-urile din sistem? | ||
+ | *Afisati dispozitivele PCI si USB ale sistemului. | ||
+ | *Listati intreruperile folosite de sistem. | ||
+ | *Ce rol are dispozitivul /dev/full? | ||
- | ==== Tutorial ==== | + | ===== Comenzi de bază ===== |
- | *N/A | + | *Folositi head si tail pentru a afisa: |
+ | *primele 5 linii din fisierul /etc/passwd | ||
+ | *ultimele 5 linii din fisierul /etc/passwd | ||
+ | *totul mai putin ultimele 5 linii din fisierul /etc/passwd | ||
+ | *totul mai putin primele 5 linii din fisierul /etc/passwd | ||
+ | *pentru documentare folositi man head, man tail, info coreutils head, info coreutils tail (opțiunea -n) | ||
+ | *Afisati primele 10 linii din fisierul /etc/services impreuna cu numarul acestora. | ||
+ | *Afisati pagina de manual a functiei C printf. | ||
+ | *Afisati pid-ul,ppid-ul si comanda completa pentru toate procesele din sistem. | ||
+ | *Folositi ps pentru a sorta procesele din sistem dupa memoria folosita (rss). | ||
+ | *Folositi o singura comanda pentru a omori toate procesele apache2 din sistem. | ||
+ | *Deschideti pagina de manual care indica tipurile de socketi de pe un sistem Linux. (Hint: find, socket, /usr/share/man) | ||
+ | ===== Discuri și sisteme de fișiere ===== | ||
- | ==== Exerciții ==== | + | *Adaugati un disc de 400MB masinii virtuale. Porniti masina virtuala. |
+ | *Creati 2 partitii primare de 200MB din noul disc. | ||
+ | *Formatati prima partitie folosind ext4 si pe a doua folosind ext3. | ||
+ | *Configurati partitia ext3 pentru a nu fi niciodata verificata consistenta folosind fsck. | ||
+ | *Configurati sistemul pentru a monta cele doua partitii in /mnt/pt1 si /mnt/pt2 la boot-are. | ||
+ | *Instalati ultima versiune de kernel Linux disponibila in repository. Verificati ca a fost instalata inspectand fisierul de configurare al GRUB. | ||
+ | *Configurati sistemul sa boot-eze implicit dupa vechea versiune. Reporniti sistemul. Verificati ca partitiile au fost montate automat. | ||
+ | *Creati fisierul temp.dat de 100MB. Configurati-l ca fisier swap si activati-l. | ||
+ | *Determinati cat spatiu ocupa directorul /boot. | ||
- | *[01]. Pe **mașina virtuală și pe mașina fizică** instalați sistemul de versionare git. (**Hint**: curs, slide 6) | + | ===== Drepturi pe sistemul de fișiere ===== |
- | <solution><code> | + | |
- | root@heimdall:~# apt-get update; apt-get install git | + | |
- | root@mjolnir:~# apt-get update; apt-get install git | + | *Creati fisierul a.txt cu drepturile in forma r w s - - s - w t. |
- | </code></solution> | + | *Creati un hard-link b.txt catre a.txt. |
+ | *Creati un soft link c.txt catre b.txt. | ||
+ | *Schimbati detinatorul fisierului a.txt in root, grupul adm. | ||
+ | *Schimbati drepturile fisierelor din /usr/share/man in rw-rw-r-- si a directoarelor in rwxrwxr-x. (Hint: folosiți opțiunea X pentru drepturi a chmod și opțiunea de recursivitate) | ||
+ | *Adaugati pe masina virtuala utilizatorul tudor. Adaugati cota pentru acesta la 100 MB si 200 de fisiere. | ||
- | *[02]. Pe **mașina virtuală și pe mașina fizică** configurați //global// git astfel încât commit-urile utilizatorului student să poata fi semnate cu numele "Student GSR" și cu adresa de email student@gsr.cs.pub.ro. | + | ===== Kernel ===== |
- | *[02].a. **Hint**: {{{man git-config}}}, {{{/global}}}, {{{/user.name}}}, {{{/user.email}}}. | + | |
- | *[02].b. **Hint**: {{{git config <file-option> <nume> <valoare>}}} | + | |
- | <solution><code> | + | |
- | student@heimdall:~$ git config --global user.name "Student GSR" | + | |
- | student@heimdall:~$ git config --global user.email student@gsr.cs.pub.ro | + | *Extrageti din kernel modulul pcspkr. (E posibil sa faceti switch cu urmatorul exercitiu.) |
+ | *Introduceti in kernel modulul pcspkr. | ||
+ | ===== Shell scripting ===== | ||
- | student@mjolnir:~$ git config --global user.name "Student GSR" | + | *Creati un script care trimite mesajul "ana are mere" utilizatorilor specificati in fisierul dest.txt |
+ | *Calculati spatiul ocupat de fisierele cu extensia .conf din /etc. (Hint: stat) | ||
+ | *Creați un script care ordonează fișierele din ''/usr/include'' în funcție de numărul de funcții declarate. Scriptul va afișa numărul de funcții declarate și numele fișierului header. | ||
- | student@mjolnir:~$ git config --global user.email student@gsr.cs.pub.ro | + | ===== Gestiunea utilizatorilor ===== |
- | </code></solution> | + | |
- | *[03]. Pe **mașina virtuală** creați un repository git gol în {{{/home/student}}}, numit //ancient.repository.git//. Folosiți pentru creare utilizatorul {{{student}}}. (**Hint**: curs, slide 8) | + | *Adaugati in sistem grupul users. |
- | <solution><code> | + | *Adaugati in sistem utilizatorii bianca si cosmin in grupul users si home-ul in /home/users/bianca si /home/users/cosmin. |
- | student@heimdall:~$ mkdir ancient.repository.git | + | *Configurati cron pentru a adauga un mesaj la sfarsitul fisierului /home/users/bianca/cron.txt la fiecare minut. |
+ | ===== Servicii web ===== | ||
- | student@heimdall:~$ cd ancient.repository.git | + | *Verificați funcționarea serverului apache conectandu-vă folosind telnet pe portul local 80. |
+ | *Configurați serverul Apache să asculte conexiuni pe portul 8080 (/etc/apache2/ports.conf). Nu uitați să reporniți serviciul. Verificați folosind netstat și un browser. | ||
+ | *Reconfigurați portul pe care ascultă Apache la valoarea implicită. | ||
+ | *Verificați statusul modulului apache //userdir//. Ce face acest modul? Daca nu este activat, activați-l. | ||
+ | *Creați o pagină numită //index.html// în /home/student/public_html, cu textul "my first public page". Accesați-o folosind un borwser web. | ||
+ | *Configurați Apache astfel încat directorul web pentru fiecare utilizator să fie /home/$USER/www. Nu uitați să reporniți serviciul. | ||
+ | *Creați o pagina numită //index.html// în /home/student/www, cu textul "my second public page". Accesați-o folosind un borwser web. | ||
- | student@heimdall:~/ancient.repository.git$ git init --bare | + | ===== Servicii SSH ===== |
- | Initialized empty Git repository in /home/student/ancient.repository.git/ | + | |
- | student@heimdall:~/ancient.repository.git$ ls -l | + | *Configurați serverul SSH să asculte conexiuni pe portul 2222 (/etc/ssh/sshd_config). Nu uitați să reporniți serviciul. Verificați folosind netstat și ssh. |
- | total 32 | + | *Creați utilizatorii horia și ioana. Configurați sistemul astfel încât horia să se conecteze la contul ioana prin SSH fără a îi fi solicitată parola (chei publice). |
- | drwxr-xr-x 2 student student 4096 Jan 19 14:52 branches | + | *Configurați sistemul local astfel încât comanda ping cs.pub.ro să ducă la interogarea sistemului cu adresa 141.85.37.25. |
- | -rw-r--r-- 1 student student 66 Jan 19 14:52 config | + | |
- | -rw-r--r-- 1 student student 73 Jan 19 14:52 description | + | |
- | -rw-r--r-- 1 student student 23 Jan 19 14:52 HEAD | + | |
- | drwxr-xr-x 2 student student 4096 Jan 19 14:52 hooks | + | |
- | drwxr-xr-x 2 student student 4096 Jan 19 14:52 info | + | |
- | drwxr-xr-x 4 student student 4096 Jan 19 14:52 objects | + | |
- | drwxr-xr-x 4 student student 4096 Jan 19 14:52 refs | + | |
- | </code></solution> | + | |
- | *[04]. Folosind utilizatorul {{{student}}} de pe **mașina virtuală** populați repository-ul creat anterior adaugând în el un fișier numit {{{planets.txt}}} ce conține liniile<code> | + | ===== Servicii de file sharing ===== |
- | P3R-272 | + | |
- | P3X-439 | + | |
- | </code> | + | |
- | *[04].a. **Hint**: curs, slide 8 | + | |
- | *[04].b. **Hint**: Folosiți pentru mesajul asociat commit-ului "initial commit" | + | |
- | *[04].c. **Hint**: Folosiți ca adresă pentru origin {{{/home/student/ancient.repository.git}}} | + | |
- | <solution><code> | + | |
- | student@heimdall:~$ mkdir local.ancient.repository.git | + | |
- | student@heimdall:~$ cd local.ancient.repository.git | + | *Configurați SAMBA pe sistemul fizic pentru a partaja directorul /share-write cu drepturi complete (read-write) pentru toți utilizatorii. Testați folosind mașina virtuală. |
+ | *Configurați SAMBA pe sistemul fizic pentru a partaja directorul /var/smb cu drepturi complete (read-write) pentru utilizatorul student. Orice alt utilizator va avea drepturi de citire. | ||
+ | *Configurați NFS pe sistemul fizic astfel încât directorul /export să fie montat cu drepturi complete de pe mașina virtuală. | ||
+ | *Configurați daemon-ul de rsync pe sistemul fizic. Folosiți rsync pentru a sincroniza, fără parolă, directorul /home/student/share de pe sistemul fizic pe mașina virtuală (nu contează cu ce utilizator). | ||
- | student@heimdall:~/local.ancient.repository.git$ git init . | + | ===== Servicii de e-mail ===== |
- | Initialized empty Git repository in /home/student/local.ancient.repository.git/.git/ | + | |
- | student@heimdall:~/local.ancient.repository.git$ echo -e "P3R-272\nP3X-439" > planets.txt | + | *Configurați Postfix astfel încât mesajele livrate către contact@info.ro să ajungă în căsuța poștală de tip Maildir/ a utilizatorului andrei. |
+ | *Configurați Postfix astfel încât mesajele către postmaster@info.ro să ajungă în căsuța poștală virtuală /usr/local/mail/info.ro/postmaster/. | ||
+ | *Configurați Maildrop astfel încât mesajele transmise către andrei@test.com care au ca sursă root@test.com să ajungă în directorul directorul root/ din Inbox-ul căsuței poștale de tip Maildir a utilizatorului andrei. | ||
- | student@heimdall:~/local.ancient.repository.git$ git add planets.txt | + | ===== Securitate ===== |
- | student@heimdall:~/local.ancient.repository.git$ git commit -m "initial commit" | + | *Limitați dimensiunea maximă a fișierelor pe care le poate crea utilizatorul ioana la 50MB. |
- | [master (root-commit) 58fdb7b] initial commit | + | *Adaugați utilizatorul alice. Limitați numarul de procese pe care le poate porni alice la 5. Autentificați ca alice, porniți 5 instanțe ale htop (daca htop nu este instalat, instalați-l). |
- | 1 files changed, 2 insertions(+), 0 deletions(-) | + | *Limitați numărul maxim de autentificări simultane pentru utilizatorii din grupul users la 2. |
- | create mode 100644 planets.txt | + | *Filtrați traficul HTTP și SSH emis de stația voastră către anaconda.cs.pub.ro |
- | + | *Restricționați accesul la toate porturile din sistem, mai putin 2222 și 80. Testați functionarea filtrului utilizand telnet. | |
- | student@heimdall:~/local.ancient.repository.git$ git remote add origin /home/student/ancient.repository.git | + | *Deschideti portul 2022, pentru a putea fi accesat. |
- | + | *Configurați "port forwarding" astfel încât la accesarea portului 2022 de pe mașina fizică, conexiunea să fie redirectată către portul 22 al mașinii virtuale. Testați folosind ssh. | |
- | student@heimdall:~/local.ancient.repository.git$ git push origin master | + | |
- | Counting objects: 3, done. | + | |
- | Writing objects: 100% (3/3), 235 bytes, done. | + | |
- | Total 3 (delta 0), reused 0 (delta 0) | + | |
- | Unpacking objects: 100% (3/3), done. | + | |
- | To /home/student/ancient.repository.git | + | |
- | * [new branch] master -> master | + | |
- | </code></solution> | + | |
- | + | ||
- | *[05]. Pe **mașina fizică** adaugați utilizatorul jack și configurați //global// git astfel încât commit-urile utilizatorului jack să poata fi semnate cu numele "Jack" și cu adresa de email jack@gsr.cs.pub.ro. | + | |
- | <solution><code> | + | |
- | root@mjolnir:~# groupadd jack | + | |
- | + | ||
- | root@mjolnir:~# useradd -d /home/jack -m -g jack -s /bin/bash jack | + | |
- | + | ||
- | root@mjolnir:~# echo "jack:student" | chpasswd | + | |
- | + | ||
- | jack@mjolnir:~$ git config --global user.name "Jack" | + | |
- | + | ||
- | jack@mjolnir:~$ git config --global user.email jack@gsr.cs.pub.ro | + | |
- | </code></solution> | + | |
- | + | ||
- | *[06]. Pe **mașina fizică**, în contul utilizatorului jack, creați o clonă repository-ului ancient.repository.git de pe mașina virtuală. | + | |
- | *[06].a. **Hint**: Folosiți git peste SSH | + | |
- | *[06].b. **Hint**: Pentru git folosiți contul utilizatorului student de pe mașina virtuală | + | |
- | *[06].c. **Hint**: {{{git clone}}} | + | |
- | <solution><code> | + | |
- | jack@mjolnir:~$ git clone student@heimdall.local:ancient.repository.git | + | |
- | Cloning into 'ancient.repository'... | + | |
- | student@heimdall.local's password: | + | |
- | remote: Counting objects: 3, done. | + | |
- | Receiving objects: 100% (3/3), done. | + | |
- | remote: Total 3 (delta 0), reused 0 (delta 0) | + | |
- | + | ||
- | jack@mjolnir:~$ ls -l | + | |
- | total 4 | + | |
- | drwxr-xr-x 3 jack jack 4096 Jan 19 15:05 ancient.repository | + | |
- | + | ||
- | jack@mjolnir:~$ cd ancient.repository/ | + | |
- | + | ||
- | jack@mjolnir:~/ancient.repository$ ls -l | + | |
- | total 4 | + | |
- | -rw-r--r-- 1 jack jack 16 Jan 19 15:05 planets.txt | + | |
- | </code></solution> | + | |
- | + | ||
- | *[07]. Pe **mașina fizică**, în clona repository-ului adaugată anterior, creați un nou fișier numit {{{people.txt}}} cu următorul conținut<code> | + | |
- | Jack O'Neill | + | |
- | </code>Comiteți fișierul nou creat în repository. | + | |
- | *[07].a. Adaugați fișierul folosind {{{git add}}} | + | |
- | *[07].b. Comiteți fișierul folosind {{{git commit}}}. Specificați la commit descrierea "Adds people.txt". | + | |
- | *[07].c. Trimiteți modificările pe server folosind {{{git push}}} | + | |
- | <solution><code> | + | |
- | jack@mjolnir:~/ancient.repository$ ls -l | + | |
- | total 4 | + | |
- | -rw-r--r-- 1 jack jack 16 Jan 19 15:05 planets.txt | + | |
- | + | ||
- | jack@mjolnir:~/ancient.repository$ echo "Jack O\'Neill" > people.txt | + | |
- | + | ||
- | jack@mjolnir:~/ancient.repository$ ls -l | + | |
- | total 8 | + | |
- | -rw-r--r-- 1 jack jack 14 Jan 19 15:07 people.txt | + | |
- | -rw-r--r-- 1 jack jack 16 Jan 19 15:05 planets.txt | + | |
- | + | ||
- | jack@mjolnir:~/ancient.repository$ git add people.txt | + | |
- | + | ||
- | jack@mjolnir:~/ancient.repository$ git commit -m "Adds people.txt" | + | |
- | [master ba2bb52] Adds people.txt | + | |
- | 1 files changed, 1 insertions(+), 0 deletions(-) | + | |
- | create mode 100644 people.txt | + | |
- | + | ||
- | jack@mjolnir:~/ancient.repository$ git push | + | |
- | student@heimdall.local's password: | + | |
- | Counting objects: 4, done. | + | |
- | Delta compression using up to 2 threads. | + | |
- | Compressing objects: 100% (2/2), done. | + | |
- | Writing objects: 100% (3/3), 288 bytes, done. | + | |
- | Total 3 (delta 0), reused 0 (delta 0) | + | |
- | To student@heimdall.local:ancient.repository.git | + | |
- | 58fdb7b..ba2bb52 master -> master | + | |
- | </code></solution> | + | |
- | + | ||
- | + | ||
- | ===== 2. Git-daemon (2p) ===== | + | |
- | + | ||
- | *Comenzi/concepte/fișiere | + | |
- | *N/A | + | |
- | + | ||
- | + | ||
- | ==== Tutorial ==== | + | |
- | + | ||
- | *N/A | + | |
- | + | ||
- | + | ||
- | ==== Exerciții ==== | + | |
- | + | ||
- | *[01]. Pe **mașina virtuală** instalați daemonul de git (**Hint**: curs, slide 10) | + | |
- | <solution><code> | + | |
- | root@heimdall:~# apt-get install git-daemon-run | + | |
- | </code></solution> | + | |
- | + | ||
- | *[02]. Pe **mașina virtuală** aflați portul pe care ascultă daemonul de git. | + | |
- | <solution><code> | + | |
- | root@heimdall:~# netstat -lntp | grep git | + | |
- | tcp 0 0 0.0.0.0:9418 0.0.0.0:* LISTEN 3039/git-daemon | + | |
- | tcp6 0 0 :::9418 :::* LISTEN 3039/git-daemon | + | |
- | </code></solution> | + | |
- | + | ||
- | *[03]. Pe **mașina virtuală** analizați fișierul de configurare al git-daemon. Care este directorul implicit în care se găsesc repository-urile cu care lucrează daemonul de git ? | + | |
- | *[03].a. **Hint**: Curs, slide 10 | + | |
- | *[03].b. **Hint**: {{{man git-daemon}}} | + | |
- | <solution><code> | + | |
- | root@heimdall:~# cat /etc/sv/git-daemon/run | + | |
- | #!/bin/sh | + | |
- | exec 2>&1 | + | |
- | echo 'git-daemon starting.' | + | |
- | exec chpst -ugitdaemon \ | + | |
- | "$(git --exec-path)"/git-daemon --verbose --reuseaddr \ | + | |
- | --base-path=/var/cache /var/cache/git | + | |
- | </code></solution> | + | |
- | + | ||
- | *[04]. Pe **mașina virtuală** faceți accesibil (doar read-only) repository-ul {{{ancient.repository.git}}} din {{{/home/student}}} în git-daemon. | + | |
- | *[04].a. Creați un link simbolic numit {{{/var/cache/git/ancient.repository.git}}} către {{{/home/student/ancient.repository.git}}} | + | |
- | <solution><code> | + | |
- | root@heimdall:/var/cache/git# ln -s /home/student/ancient.repository.git ancient.repository.git | + | |
- | + | ||
- | root@heimdall:/var/cache/git# ls -l | + | |
- | total 0 | + | |
- | lrwxrwxrwx 1 root root 36 Jan 19 15:16 ancient.repository.git -> /home/student/ancient.repository.git | + | |
- | </code></solution> | + | |
- | *[04].b. Creați în directorul rădăcină al repository-ului fișierul gol {{{git-daemon-export-ok}}}. | + | |
- | <solution><code> | + | |
- | root@heimdall:/var/cache/git# cd ancient.repo.git | + | |
- | + | ||
- | root@heimdall:/var/cache/git/ancient.repo.git# touch git-daemon-export-ok | + | |
- | </code></solution> | + | |
- | *[04].c. Pe mașina fizică, în contul utilizatorului student, clonați repository-ul {{{ancient.repository.git}}} folosind adresa {{{git://heimdall.local/git/ancient.repository.git}}} | + | |
- | <solution><code> | + | |
- | student@mjolnir:~$ git clone git://heimdall.local/git/ancient.repository.git | + | |
- | Cloning into 'ancient.repository'... | + | |
- | remote: Counting objects: 6, done. | + | |
- | remote: Compressing objects: 100% (3/3), done. | + | |
- | remote: Total 6 (delta 0), reused 0 (delta 0) | + | |
- | Receiving objects: 100% (6/6), done. | + | |
- | </code></solution> | + | |
- | + | ||
- | ===== 3. Git peste HTTP (2p) ===== | + | |
- | + | ||
- | *Comenzi/concepte/fișiere | + | |
- | *N/A | + | |
- | + | ||
- | + | ||
- | ==== Tutorial ==== | + | |
- | + | ||
- | *N/A | + | |
- | + | ||
- | + | ||
- | ==== Exerciții ==== | + | |
- | + | ||
- | *[01]. Pe **mașina virtuală** instalați serverul apache2. | + | |
- | <solution><code> | + | |
- | root@heimdall:~# apt-get update; apt-get install apache2 | + | |
- | </code></solution> | + | |
- | + | ||
- | *[02]. Pe **mașina virtuală** în site-ul default apache realizați un alias care să mapeze {{{/git}}} pe {{{/var/cache/git}}}. | + | |
- | *[02].a. **Hint**: curs, slide 11, 12, 13 | + | |
- | *[02].a. **Hint**: Aveți grijă la drepturile de acces asupra directorului, specificate în apache. | + | |
- | <solution><code> | + | |
- | root@heimdall:/etc/apache2/sites-available# cat default | tail -n 9 | + | |
- | Alias /git "/var/cache/git/" | + | |
- | <Directory "/var/cache/git/"> | + | |
- | Options Indexes MultiViews FollowSymLinks | + | |
- | AllowOverride None | + | |
- | Order deny,allow | + | |
- | Allow from all | + | |
- | </Directory> | + | |
- | + | ||
- | </VirtualHost> | + | |
- | + | ||
- | root@heimdall:/etc/apache2/sites-available# /etc/init.d/apache2 restart | + | |
- | Restarting web server: apache2 ... waiting . | + | |
- | </code></solution> | + | |
- | + | ||
- | *[03]. Pe **mașina virtuală** activați hook-ul git {{{update-server-info}}}. | + | |
- | *[03].a **Hint**: curs, slide 11 | + | |
- | *[03].b **Hint**: Citiți fișierul {{{hooks/post-update.sample}}} din repository | + | |
- | *[03].c **Hint**: Faceți un commit în repository pentru a rula hook-ul activat anterior. Puteți folosi copia repository-ului din contul utilizatorului jack. | + | |
- | <solution><code> | + | |
- | root@heimdall:/var/cache/git/ancient.repository.git# cp hooks/post-update.sample hooks/post-update | + | |
- | + | ||
- | jack@mjolnir:~/ancient.repository$ vim people.txt | + | |
- | + | ||
- | jack@mjolnir:~/ancient.repository$ git add people.txt | + | |
- | + | ||
- | jack@mjolnir:~/ancient.repository$ git commit -sm "Updated people.txt" | + | |
- | [master 79c07be] Updated people.txt | + | |
- | 1 files changed, 1 insertions(+), 1 deletions(-) | + | |
- | + | ||
- | jack@mjolnir:~/ancient.repository$ git push | + | |
- | student@heimdall.local's password: | + | |
- | Counting objects: 5, done. | + | |
- | Delta compression using up to 2 threads. | + | |
- | Compressing objects: 100% (2/2), done. | + | |
- | Writing objects: 100% (3/3), 309 bytes, done. | + | |
- | Total 3 (delta 0), reused 0 (delta 0) | + | |
- | To student@heimdall.local:ancient.repository.git | + | |
- | ba2bb52..79c07be master -> master | + | |
- | </code></solution> | + | |
- | + | ||
- | *[04]. Pe **mașina fizică** în home-ul utilizatorului jack creați un director cu numele {{{http-repo}}}. În acest director realizați o clona read-only a repository-ului {{{ancient.repositoty}}} folosind git peste HTTP. (**Hint**: curs, slide 11) | + | |
- | <solution><code> | + | |
- | jack@mjolnir:~$ mkdir http-repo | + | |
- | + | ||
- | jack@mjolnir:~$ cd http-repo/ | + | |
- | + | ||
- | jack@mjolnir:~/http-repo$ git clone http://heimdall.local/git/ancient.repository.git | + | |
- | Cloning into 'ancient.repository'... | + | |
- | + | ||
- | jack@mjolnir:~/http-repo$ ls -l | + | |
- | total 4 | + | |
- | drwxr-xr-x 3 jack jack 4096 Jan 19 15:51 ancient.repository | + | |
- | + | ||
- | jack@mjolnir:~/http-repo$ cd ancient.repository/ | + | |
- | + | ||
- | jack@mjolnir:~/http-repo/ancient.repository$ ls -l | + | |
- | total 8 | + | |
- | -rw-r--r-- 1 jack jack 13 Jan 19 15:51 people.txt | + | |
- | -rw-r--r-- 1 jack jack 16 Jan 19 15:51 planets.txt | + | |
- | </code></solution> | + | |
- | + | ||
- | *[05]. Pe **mașina virtuală** creați un nou repository, cu numele {{{atlantis.git}}}, în {{{/var/cache/git}}}. | + | |
- | *[05].a. Activati hook-ul git {{{update-server-info}}}. | + | |
- | *[05].b. Realizați un prim commit în acest repository adaugând fișierul {{{info.txt}}} cu conținutul "Atlantis database". | + | |
- | *[05].c. Schimbați recursiv userul și grupul care dețin {{{/var/cache/git/atlantis.git}}} în {{{www-data}}} | + | |
- | <solution><code> | + | |
- | root@heimdall:/var/cache/git# mkdir atlantis.git | + | |
- | + | ||
- | root@heimdall:/var/cache/git# cd atlantis.git | + | |
- | + | ||
- | root@heimdall:/var/cache/git/atlantis.git# git init --bare | + | |
- | Initialized empty Git repository in /var/cache/git/atlantis.git/ | + | |
- | + | ||
- | root@heimdall:/var/cache/git/atlantis.git# cd hooks | + | |
- | + | ||
- | root@heimdall:/var/cache/git/atlantis.git/hooks# ls -l | + | |
- | total 36 | + | |
- | -rwxr-xr-x 1 root root 452 Jan 19 15:53 applypatch-msg.sample | + | |
- | -rwxr-xr-x 1 root root 896 Jan 19 15:53 commit-msg.sample | + | |
- | -rwxr-xr-x 1 root root 189 Jan 19 15:53 post-update.sample | + | |
- | -rwxr-xr-x 1 root root 398 Jan 19 15:53 pre-applypatch.sample | + | |
- | -rwxr-xr-x 1 root root 1704 Jan 19 15:53 pre-commit.sample | + | |
- | -rwxr-xr-x 1 root root 1239 Jan 19 15:53 prepare-commit-msg.sample | + | |
- | -rwxr-xr-x 1 root root 4971 Jan 19 15:53 pre-rebase.sample | + | |
- | -rwxr-xr-x 1 root root 3611 Jan 19 15:53 update.sample | + | |
- | + | ||
- | root@heimdall:/var/cache/git/atlantis.git/hooks# cp post-update.sample post-update | + | |
- | + | ||
- | root@heimdall:/var/cache/git/atlantis.git/hooks# cd .. | + | |
- | + | ||
- | root@heimdall:/var/cache/git/atlantis.git# cd | + | |
- | + | ||
- | root@heimdall:~# mkdir local.atlantis.git | + | |
- | + | ||
- | root@heimdall:~# git init . | + | |
- | Initialized empty Git repository in /root/.git/ | + | |
- | + | ||
- | root@heimdall:~# echo "Atlantis database" > info.txt | + | |
- | + | ||
- | root@heimdall:~# git add info.txt | + | |
- | + | ||
- | root@heimdall:~# git commit -m "initial commit" | + | |
- | [master (root-commit) 83325cd] initial commit | + | |
- | Committer: root <root@heimdall.localdomain> | + | |
- | Your name and email address were configured automatically based | + | |
- | on your username and hostname. Please check that they are accurate. | + | |
- | You can suppress this message by setting them explicitly: | + | |
- | + | ||
- | git config --global user.name "Your Name" | + | |
- | git config --global user.email you@example.com | + | |
- | + | ||
- | After doing this, you may fix the identity used for this commit with: | + | |
- | + | ||
- | git commit --amend --reset-author | + | |
- | + | ||
- | 1 files changed, 1 insertions(+), 0 deletions(-) | + | |
- | create mode 100644 info.txt | + | |
- | + | ||
- | root@heimdall:~# git remote add origin /var/cache/git/atlantis.git | + | |
- | + | ||
- | root@heimdall:~# git push origin master | + | |
- | Counting objects: 3, done. | + | |
- | Writing objects: 100% (3/3), 226 bytes, done. | + | |
- | Total 3 (delta 0), reused 0 (delta 0) | + | |
- | Unpacking objects: 100% (3/3), done. | + | |
- | To /var/cache/git/atlantis.git | + | |
- | * [new branch] master -> master | + | |
- | + | ||
- | root@heimdall:~# cd /var/cache/git/ | + | |
- | + | ||
- | root@heimdall:/var/cache/git# chown -R www-data:www-data atlantis.git | + | |
- | </code></solution> | + | |
- | + | ||
- | + | ||
- | *[06]. Pe **mașina virtuală** activați modulul apache {{{dav_fs}}}. | + | |
- | <solution><code> | + | |
- | root@heimdall:~# a2enmod dav_fs | + | |
- | Considering dependency dav for dav_fs: | + | |
- | Enabling module dav. | + | |
- | Enabling module dav_fs. | + | |
- | To activate the new configuration, you need to run: | + | |
- | service apache2 restart | + | |
- | + | ||
- | root@heimdall:~# /etc/init.d/apache2 restart | + | |
- | Restarting web server: apache2 ... waiting . | + | |
- | </code></solution> | + | |
- | + | ||
- | *[07]. Pe **mașina virtuală** creați fișierul {{{/etc/apache2/git.passwd}}} ce conține utilizatori și parole în formatul {{{htpasswd}}}. Adăugați în acest fișier utilizatorul {{{jack}}} cu parola {{{impudence}}} | + | |
- | <solution><code> | + | |
- | root@heimdall:~# htpasswd -c /etc/apache2/git.passwd jack | + | |
- | New password: | + | |
- | Re-type new password: | + | |
- | Adding password for user jack | + | |
- | </code></solution> | + | |
- | + | ||
- | *[08]. Pe **mașina virtuală** configurați apache astfel încât să puteți realiza commit-uri peste HTTP în repository-urile din {{{/var/cache/git}}} (**Hint**: curs, slide 12,13) | + | |
- | <solution><code> | + | |
- | root@heimdall:/etc/apache2/sites-available# cat default | tail -n 14 | + | |
- | Alias /git "/var/cache/git/" | + | |
- | <Directory "/var/cache/git/"> | + | |
- | DAV on | + | |
- | AuthType Basic | + | |
- | AuthName "Git" | + | |
- | AuthUserFile /etc/apache2/git.passwd | + | |
- | <LimitExcept GET HEAD PROPFIND OPTIONS REPORT> | + | |
- | Require valid-user | + | |
- | </LimitExcept> | + | |
- | Order deny,allow | + | |
- | Allow from all | + | |
- | </Directory> | + | |
- | + | ||
- | </VirtualHost> | + | |
- | + | ||
- | root@heimdall:/etc/apache2/sites-available# /etc/init.d/apache2 restart | + | |
- | Restarting web server: apache2 ... waiting . | + | |
- | </code></solution> | + | |
- | + | ||
- | *[09]. Pe **mașina fizică**, în contul utilizatorului student, realizați o clonă read-write a repository-ului atlantis.git. Folosiți git peste HTTP și specificați ca user {{{jack}}} | + | |
- | *[09].a. **Hint**: {{{http://user@address/path}}} | + | |
- | <solution><code> | + | |
- | student@mjolnir:~$ git clone http://jack@heimdall.local/git/atlantis.git | + | |
- | Cloning into 'atlantis'... | + | |
- | </code></solution> | + | |
- | + | ||
- | *[10]. Realizati un commit și un push în clona creată la punctul anterior. | + | |
- | <solution><code> | + | |
- | student@mjolnir:~$ cd atlantis/ | + | |
- | + | ||
- | student@mjolnir:~/atlantis$ ls -l | + | |
- | total 4 | + | |
- | -rw-r--r-- 1 student student 18 Jan 19 16:01 info.txt | + | |
- | + | ||
- | student@mjolnir:~/atlantis$ vim info.txt | + | |
- | + | ||
- | student@mjolnir:~/atlantis$ git add info.txt | + | |
- | + | ||
- | student@mjolnir:~/atlantis$ git commit -sm "Modifies info.txt" | + | |
- | [master e2ff48a] Modifies info.txt | + | |
- | 1 files changed, 1 insertions(+), 1 deletions(-) | + | |
- | + | ||
- | student@mjolnir:~/atlantis$ git push | + | |
- | Password for 'heimdall.local': | + | |
- | Fetching remote heads... | + | |
- | refs/ | + | |
- | refs/tags/ | + | |
- | refs/heads/ | + | |
- | updating 'refs/heads/master' | + | |
- | from 83325cd5676c96c0ed6ecae35a8af83652d25334 | + | |
- | to e2ff48af5f676f69277a051077c7e4724929c7f1 | + | |
- | sending 3 objects | + | |
- | done | + | |
- | Updating remote server info | + | |
- | To http://jack@heimdall.local/git/atlantis.git | + | |
- | 83325cd..e2ff48a master -> master | + | |
- | </code></solution> | + | |
- | + | ||
- | ===== 4. GitWeb (1p) ===== | + | |
- | + | ||
- | *Comenzi/concepte/fișiere | + | |
- | *gitweb | + | |
- | */etc/gitweb.conf | + | |
- | + | ||
- | ==== Tutorial ==== | + | |
- | + | ||
- | *Instalați pachetul corespunzător GitWeb pe **mașina virtuală**. | + | |
- | <code> | + | |
- | root@heimdall:~# apt-get install gitweb | + | |
- | </code> | + | |
- | *Analizați conținutul fișierelor {{{/etc/gitweb.conf}}} și {{{/etc/apache2/conf.d/gitweb}}}. | + | |
- | <code> | + | |
- | root@heimdall:~# vim /etc/gitweb.conf | + | |
- | + | ||
- | root@heimdall:~# vim /etc/apache2/conf.d/gitweb | + | |
- | </code> | + | |
- | *Accesați într-un browser URL-ul {{{http://heimdall.local/gitweb/}}}. | + | |
- | + | ||
- | ==== Exerciții ==== | + | |
- | + | ||
- | *[01]. Pentru cele două repository-uri disponibile prin GitWeb configurați: | + | |
- | *ca descrieri: "Ancient database repository" și "Atlantis database repository" | + | |
- | *ca posesori: "The Ancients" | + | |
- | *verificați rezultatele la adresa {{{http://heimdall.local/gitweb/}}} | + | |
- | *[01].a. **Hint**: Curs, slide 21 | + | |
- | *[01].b. **Hint**: {{{/var/cache/git/<repo-name>.git/description}}} | + | |
- | *[01].c. **Hint**: {{{/var/cache/git/<repo-name>.git/config}}} | + | |
- | <solution><code> | + | |
- | root@heimdall:/var/cache/git# cat atlantis.git/description | + | |
- | Unnamed repository; edit this file 'description' to name the repository. | + | |
- | + | ||
- | root@heimdall:/var/cache/git# vim atlantis.git/description | + | |
- | + | ||
- | root@heimdall:/var/cache/git# cat atlantis.git/description | + | |
- | Atlantis database repository | + | |
- | + | ||
- | root@heimdall:/var/cache/git# cat ancient.repository.git/description | + | |
- | Unnamed repository; edit this file 'description' to name the repository. | + | |
- | + | ||
- | root@heimdall:/var/cache/git# vim ancient.repository.git/description | + | |
- | + | ||
- | root@heimdall:/var/cache/git# cat ancient.repository.git/description | + | |
- | Ancient database repository | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | root@heimdall:/var/cache/git# cat atlantis.git/config | + | |
- | [core] | + | |
- | repositoryformatversion = 0 | + | |
- | filemode = true | + | |
- | bare = true | + | |
- | + | ||
- | root@heimdall:/var/cache/git# vim atlantis.git/config | + | |
- | + | ||
- | root@heimdall:/var/cache/git# cat atlantis.git/config | + | |
- | [core] | + | |
- | repositoryformatversion = 0 | + | |
- | filemode = true | + | |
- | bare = true | + | |
- | [gitweb] | + | |
- | owner = The Ancients | + | |
- | + | ||
- | root@heimdall:/var/cache/git# cat ancient.repository.git/config | + | |
- | [core] | + | |
- | repositoryformatversion = 0 | + | |
- | filemode = true | + | |
- | bare = true | + | |
- | + | ||
- | root@heimdall:/var/cache/git# vim ancient.repository.git/config | + | |
- | + | ||
- | root@heimdall:/var/cache/git# cat ancient.repository.git/config | + | |
- | [core] | + | |
- | repositoryformatversion = 0 | + | |
- | filemode = true | + | |
- | bare = true | + | |
- | [gitweb] | + | |
- | owner = The Ancients | + | |
- | </code></solution> | + | |
- | + | ||
- | *[02]. Configurați GitWeb pentru a indica în cadrul descrierii fiecărui repository URL-urile cu care acesta poate fi accesat (URL-uri de tip git-daemon și HTTP). | + | |
- | *[02].a. **Hint**: {{{@git_base_url_list}}}, {{{/usr/share/doc/gitweb/README}}}). | + | |
- | *[02].b. **Hint**: http://zarb.org/~gc/html/git-on-a-shared-server.html | + | |
- | *[02].c. verificați rezultatele la adresa {{{http://heimdall.local/gitweb/}}} | + | |
- | <solution><code> | + | |
- | root@heimdall:~# tail -n 1 /etc/gitweb.conf | + | |
- | @git_base_url_list = qw(git://heimdall.local/git http://heimdall.local/git); | + | |
- | </code></solution> | + | |
- | + | ||
- | ===== 5. Gitolite (2p) ===== | + | |
- | + | ||
- | *Comenzi/concepte/fișiere | + | |
- | *gitolite | + | |
- | *SSH custom commands | + | |
- | *gitolite.conf | + | |
- | + | ||
- | ==== Tutorial ==== | + | |
- | + | ||
- | *N/A | + | |
- | + | ||
- | ==== Exerciții ==== | + | |
- | + | ||
- | *[01]. Verificați dacă pe **sistemul fizic** este deja generată în contul utilizatorului {{{student}}} o pereche de chei SSH. Dacă nu sunt generate, generați-le fără a utiliza un passphrase. | + | |
- | *[01].a. **Hint**: {{{ssh-keygen -t rsa}}} | + | |
- | <solution><code> | + | |
- | student@mjolnir:~/.ssh$ ls -l | + | |
- | total 16 | + | |
- | -rw-r--r-- 1 student student 397 Oct 12 15:55 authorized_keys | + | |
- | -rw------- 1 student student 1675 Oct 12 15:55 id_rsa | + | |
- | -rw-r--r-- 1 student student 397 Oct 12 15:55 id_rsa.pub | + | |
- | -rw-r--r-- 1 student student 444 Jan 19 14:44 known_hosts | + | |
- | </code></solution> | + | |
- | + | ||
- | *[02]. Copiați cheia publică de la exercițiul anterior **pe mașina virtuală**, în {{{/home/student/student-mjolnir.pub}}}. | + | |
- | <solution><code> | + | |
- | student@mjolnir:~/.ssh$ scp id_rsa.pub student@heimdall.local:student-mjolnir.pub | + | |
- | id_rsa.pub 100% 397 0.4KB/s 00:00 | + | |
- | </code></solution> | + | |
- | + | ||
- | *[03]. Pe **mașina virtuală** instalați pachetul {{{gitolite}}}. După instalare reconfigurați pachetul pentru a activa un asistent de configurare și specificați în cadrul acestuia: | + | |
- | *utilizatorul de sistem să se numească ({{{gitolite}}}); | + | |
- | *directorul implicit al repository-urilor ({{{/var/lib/gitolite/}}}); | + | |
- | *calea către cheia publică SSH copiată anterior ({{{/home/student/student-mjolnir.pub}}}). | + | |
- | *[03].a. **Hint**: {{{dpkg-reconfigure}}} | + | |
- | <solution><code> | + | |
- | root@heimdall:~# apt-get install gitolite | + | |
- | + | ||
- | root@heimdall:~# dpkg-reconfigure gitolite | + | |
- | </code></solution> | + | |
- | + | ||
- | *[04]. Pe **mașina virtuală**, autentificați ca {{{root}}}, schimbați utilizatorul curent în {{{gitolite}}}. (**Hint**: {{{su - gitolite}}}). | + | |
- | *Analizați continutul directorului home al utilizatorului {{{gitolite}}}. | + | |
- | *Analizați conținutul fișierului {{{~gitolite/.ssh/authorized_keys}}}. | + | |
- | *Analizați conținutul fișierului {{{~gitolite/.gitolite.rc}}}. | + | |
- | <solution><code> | + | |
- | root@heimdall:~# su - gitolite | + | |
- | + | ||
- | gitolite@heimdall:~$ pwd | + | |
- | /var/lib/gitolite | + | |
- | + | ||
- | gitolite@heimdall:~$ ls -l | + | |
- | total 4 | + | |
- | -rw------- 1 gitolite gitolite 0 Jan 19 16:22 projects.list | + | |
- | drwx------ 4 gitolite gitolite 4096 Jan 19 16:22 repositories | + | |
- | + | ||
- | gitolite@heimdall:~$ ls -la | + | |
- | total 28 | + | |
- | drwxr-xr-x 5 gitolite gitolite 4096 Jan 19 16:22 . | + | |
- | drwxr-xr-x 37 root root 4096 Jan 19 16:22 .. | + | |
- | drwx------ 8 gitolite gitolite 4096 Jan 19 16:22 .gitolite | + | |
- | -rw-r--r-- 1 gitolite gitolite 4217 Jan 19 16:22 .gitolite.rc | + | |
- | -rw------- 1 gitolite gitolite 0 Jan 19 16:22 projects.list | + | |
- | drwx------ 4 gitolite gitolite 4096 Jan 19 16:22 repositories | + | |
- | drwx------ 2 gitolite gitolite 4096 Jan 19 16:22 .ssh | + | |
- | + | ||
- | gitolite@heimdall:~$ cat .ssh/authorized_keys | + | |
- | # gitolite start | + | |
- | command="/usr/share/gitolite/gl-auth-command admin",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDILwQ5ohvvX5C3NcPS2JyheICl/664yjUOBh5oOrJtkI9UqwXGxVHJi0uSXvrIpHRkfPRRGv52PtkGPkvLLQhcbLKM/YgTMBxA7yUaEr2nF1zmXH+GempgeRb3T1P4T+Ele04mOi0KvOPDKuZ523p6xdH9O90NaHAauWAbF0mAHBYYIkRHD8dVMVd26Z8yzdNF9OPqVEIDRNRYYVIclK81mreG7k+x8027iIJRnSAdoLVEUn2huvzBHkAm4beMqG59HFb9ecEnA1In1wfMjmYPaTgsORojnYJzOoJeCV27bVSrkdKMuDNCQ7t4qj+pqKqmlW3jGK/TkxBvXQAHQmkx student@mjolnir | + | |
- | # gitolite end | + | |
- | + | ||
- | gitolite@heimdall:~$ cat .gitolite.rc | + | |
- | [...] | + | |
- | </code></solution> | + | |
- | + | ||
- | *[05]. Pe **sistemul fizic**, în contul utilizatorului {{{student}}} clonați repository-ul de administrare gitolite folosind comanda {{{git clone gitolite@heimdall.local:gitolite-admin}}}. | + | |
- | *[05].a. Urmăriți conținutul repository-ului clonat. | + | |
- | <solution><code> | + | |
- | student@mjolnir:~$ git clone gitolite@heimdall.local:gitolite-admin | + | |
- | Cloning into 'gitolite-admin'... | + | |
- | remote: Counting objects: 6, done. | + | |
- | remote: Compressing objects: 100% (4/4), done. | + | |
- | Receiving objects: 100% (6/6), 718 bytes, done. | + | |
- | remote: Total 6 (delta 0), reused 0 (delta 0) | + | |
- | + | ||
- | student@mjolnir:~$ cd gitolite-admin/ | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin$ ls -l | + | |
- | total 8 | + | |
- | drwxr-xr-x 2 student student 4096 Jan 19 16:24 conf | + | |
- | drwxr-xr-x 2 student student 4096 Jan 19 16:24 keydir | + | |
- | </code></solution> | + | |
- | + | ||
- | *[06]. Pe **sistemul fizic** creați utilizatorii {{{dexter}}} și {{{deedee}}}. Pentru fiecare utilizator generați o pereche de chei SSH și configurați //global// git astfel încât commit-urile utilizatorilor să poata fi semnate cu un nume și o adresă de email la alegere. | + | |
- | <solution><code> | + | |
- | root@mjolnir:~# groupadd dexter | + | |
- | + | ||
- | root@mjolnir:~# useradd -d /home/dexter -m -g dexter -s /bin/bash dexter | + | |
- | + | ||
- | root@mjolnir:~# echo "dexter:student" | chpasswd | + | |
- | + | ||
- | root@mjolnir:~# groupadd deedee | + | |
- | + | ||
- | root@mjolnir:~# useradd -d /home/deedee -m -g deedee -s /bin/bash deedee | + | |
- | + | ||
- | root@mjolnir:~# echo "deedee:student" | chpasswd | + | |
- | + | ||
- | root@mjolnir:~# su - dexter | + | |
- | + | ||
- | dexter@mjolnir:~$ ssh-keygen -t rsa | + | |
- | [...] | + | |
- | + | ||
- | dexter@mjolnir:~$ git config --global user.name "Dexter" | + | |
- | + | ||
- | dexter@mjolnir:~$ git config --global user.email dexter@gsr.cs.pub.ro | + | |
- | + | ||
- | dexter@mjolnir:~$ logout | + | |
- | + | ||
- | root@mjolnir:~# su - deedee | + | |
- | + | ||
- | deedee@mjolnir:~$ ssh-keygen -t rsa | + | |
- | [...] | + | |
- | + | ||
- | deedee@mjolnir:~$ git config --global user.name "Deedee" | + | |
- | + | ||
- | deedee@mjolnir:~$ git config --global user.email deedee@gsr.cs.pub.ro | + | |
- | + | ||
- | deedee@mjolnir:~$ logout | + | |
- | root@mjolnir:~# | + | |
- | </code></solution> | + | |
- | + | ||
- | *[07]. Pe **sistemul fizic** adăugați cheile publice generate anterior în gitolite. Redenumiți fișierele cu cheile publice astfel încât să poată fi asociate cu utilizatorii care le dețin. | + | |
- | *[07].a. **Hint**: {{{gitolite-admin/keydir}}}, nu uitați să faceți commit. | + | |
- | *[07].b. **Hint**: Cheile trebuiesc comise in repository | + | |
- | <solution><code> | + | |
- | root@mjolnir:~# su - dexter | + | |
- | + | ||
- | dexter@mjolnir:~$ cp .ssh/id_rsa.pub dexter.pub | + | |
- | + | ||
- | dexter@mjolnir:~$ logout | + | |
- | + | ||
- | root@mjolnir:~# su - deedee | + | |
- | + | ||
- | deedee@mjolnir:~$ cp .ssh/id_rsa.pub deedee.pub | + | |
- | + | ||
- | deedee@mjolnir:~$ logout | + | |
- | + | ||
- | root@mjolnir:~# | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/keydir$ cp /home/dexter/dexter.pub . | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/keydir$ cp /home/deedee/deedee.pub . | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/keydir$ git add *.pub | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/keydir$ git commit -sm "Adds dexter and deedee pub keys" | + | |
- | [master d343af5] Adds dexter and deedee pub keys | + | |
- | 2 files changed, 2 insertions(+), 0 deletions(-) | + | |
- | create mode 100644 keydir/deedee.pub | + | |
- | create mode 100644 keydir/dexter.pub | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/keydir$ git push | + | |
- | Counting objects: 7, done. | + | |
- | Delta compression using up to 2 threads. | + | |
- | Compressing objects: 100% (5/5), done. | + | |
- | Writing objects: 100% (5/5), 1.05 KiB, done. | + | |
- | Total 5 (delta 0), reused 0 (delta 0) | + | |
- | remote: | + | |
- | remote: ***** WARNING ***** | + | |
- | remote: the following users (pubkey files in parens) do not appear in the config file: | + | |
- | remote: deedee(deedee.pub),dexter(dexter.pub) | + | |
- | To gitolite@heimdall.local:gitolite-admin | + | |
- | fe0f702..d343af5 master -> master | + | |
- | </code></solution> | + | |
- | + | ||
- | *[08]. Configurați în gitolite trei repository-uri: {{{lab-dexter}}}, {{{room-deedee}}}, {{{lab-mandark}}} cu următoarele drepturi: | + | |
- | *{{{lab-dexter}}} -- {{{dexter}}} poate scrie, {{{deedee}}} poate citi; | + | |
- | *{{{room-deedee}}} -- {{{deedee}}} poate scrie; | + | |
- | *{{{lab-mandark}}} -- și {{{deedee}}} și {{{dexter}}} pot scrie. | + | |
- | *[08].a. **Hint**: Folosiți directorul {{{conf}}} din repository-ul gitolite-admin | + | |
- | *[08].b. **Hint**: Nu uitați să faceți commit la modificări | + | |
- | <solution><code> | + | |
- | student@mjolnir:~/gitolite-admin/conf$ ls -l | + | |
- | total 4 | + | |
- | -rw-r--r-- 1 student student 91 Jan 19 16:24 gitolite.conf | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/conf$ vim gitolite.conf | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/conf$ cat gitolite.conf | tail -n 9 | + | |
- | repo lab-dexter | + | |
- | RW+ = dexter | + | |
- | R = deedee | + | |
- | + | ||
- | repo room-deedee | + | |
- | RW+ = deedee | + | |
- | + | ||
- | repo lab-mandark | + | |
- | RW+ = dexter deedee | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/conf$ git add gitolite.conf | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/conf$ git commit -sm "Adds new repos" | + | |
- | [master f73144c] Adds new repos | + | |
- | 1 files changed, 7 insertions(+), 7 deletions(-) | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/conf$ git push | + | |
- | Counting objects: 7, done. | + | |
- | Delta compression using up to 2 threads. | + | |
- | Compressing objects: 100% (3/3), done. | + | |
- | Writing objects: 100% (4/4), 442 bytes, done. | + | |
- | Total 4 (delta 0), reused 0 (delta 0) | + | |
- | remote: creating lab-dexter... | + | |
- | remote: Initialized empty Git repository in /var/lib/gitolite/repositories/lab-dexter.git/ | + | |
- | remote: creating lab-mandark... | + | |
- | remote: Initialized empty Git repository in /var/lib/gitolite/repositories/lab-mandark.git/ | + | |
- | remote: creating room-deedee... | + | |
- | remote: Initialized empty Git repository in /var/lib/gitolite/repositories/room-deedee.git/ | + | |
- | To gitolite@heimdall.local:gitolite-admin | + | |
- | b971f1c..f73144c master -> master | + | |
- | </code></solution> | + | |
- | + | ||
- | *[09]. Pe **mașina fizică**, din conturile {{{deedee}}} și {{{dexter}}}, realizați un //initial commit// pentru cele trei repo-uri. | + | |
- | *În {{{lab-dexter}}} faceți un commit și un push ca utilizator {{{dexter}}} | + | |
- | *În {{{room-deedee}}} faceți un commit și un push ca utilizator {{{deedee}}} | + | |
- | *În {{{lab-mandark}}} faceți un commit și un push ca utilizator {{{dexter}}} | + | |
- | *[09].a. **Hint**: pentru URL-ul remote folosiți un URL de tip gitolite: curs, slide 17 | + | |
- | + | ||
- | <solution><code> | + | |
- | dexter@mjolnir:~$ git clone gitolite@heimdall.local:lab-dexter | + | |
- | Cloning into 'lab-dexter'... | + | |
- | The authenticity of host 'heimdall.local (192.168.48.128)' can't be established. | + | |
- | ECDSA key fingerprint is e6:2e:9a:fa:b8:2c:8c:cb:08:85:0a:16:2a:82:30:07. | + | |
- | Are you sure you want to continue connecting (yes/no)? yes | + | |
- | Warning: Permanently added 'heimdall.local,192.168.48.128' (ECDSA) to the list of known hosts. | + | |
- | warning: You appear to have cloned an empty repository. | + | |
- | + | ||
- | dexter@mjolnir:~$ ls -l | + | |
- | total 8 | + | |
- | -rw-r--r-- 1 dexter dexter 396 Jan 19 16:30 dexter.pub | + | |
- | drwxr-xr-x 3 dexter dexter 4096 Jan 19 16:40 lab-dexter | + | |
- | + | ||
- | dexter@mjolnir:~$ cd lab-dexter/ | + | |
- | + | ||
- | dexter@mjolnir:~/lab-dexter$ ls -l | + | |
- | total 0 | + | |
- | + | ||
- | dexter@mjolnir:~/lab-dexter$ touch file | + | |
- | + | ||
- | dexter@mjolnir:~/lab-dexter$ git add file | + | |
- | + | ||
- | dexter@mjolnir:~/lab-dexter$ git commit -m "Initial commit" | + | |
- | [master (root-commit) 6ca0142] Initial commit | + | |
- | 0 files changed, 0 insertions(+), 0 deletions(-) | + | |
- | create mode 100644 file | + | |
- | + | ||
- | dexter@mjolnir:~/lab-dexter$ git push origin master | + | |
- | Counting objects: 3, done. | + | |
- | Writing objects: 100% (3/3), 209 bytes, done. | + | |
- | Total 3 (delta 0), reused 0 (delta 0) | + | |
- | To gitolite@heimdall.local:lab-dexter | + | |
- | * [new branch] master -> master | + | |
- | + | ||
- | + | ||
- | + | ||
- | deedee@mjolnir:~$ git clone gitolite@heimdall.local:room-deedee | + | |
- | Cloning into 'room-deedee'... | + | |
- | The authenticity of host 'heimdall.local (192.168.48.128)' can't be established. | + | |
- | ECDSA key fingerprint is e6:2e:9a:fa:b8:2c:8c:cb:08:85:0a:16:2a:82:30:07. | + | |
- | Are you sure you want to continue connecting (yes/no)? yes | + | |
- | Warning: Permanently added 'heimdall.local,192.168.48.128' (ECDSA) to the list of known hosts. | + | |
- | warning: You appear to have cloned an empty repository. | + | |
- | + | ||
- | deedee@mjolnir:~$ | + | |
- | + | ||
- | deedee@mjolnir:~$ | + | |
- | + | ||
- | deedee@mjolnir:~$ cd room-deedee/ | + | |
- | + | ||
- | deedee@mjolnir:~/room-deedee$ ls -l | + | |
- | total 0 | + | |
- | + | ||
- | deedee@mjolnir:~/room-deedee$ touch file | + | |
- | + | ||
- | deedee@mjolnir:~/room-deedee$ git add file | + | |
- | + | ||
- | deedee@mjolnir:~/room-deedee$ git commit -sm "Initial commit" | + | |
- | [master (root-commit) 6f630d0] Initial commit | + | |
- | 0 files changed, 0 insertions(+), 0 deletions(-) | + | |
- | create mode 100644 file | + | |
- | + | ||
- | deedee@mjolnir:~/room-deedee$ git push origin master | + | |
- | Counting objects: 3, done. | + | |
- | Writing objects: 100% (3/3), 223 bytes, done. | + | |
- | Total 3 (delta 0), reused 0 (delta 0) | + | |
- | To gitolite@heimdall.local:room-deedee | + | |
- | * [new branch] master -> master | + | |
- | + | ||
- | + | ||
- | + | ||
- | dexter@mjolnir:~$ git clone gitolite@heimdall.local:lab-mandark | + | |
- | Cloning into 'lab-mandark'... | + | |
- | warning: You appear to have cloned an empty repository. | + | |
- | + | ||
- | dexter@mjolnir:~$ cd lab- | + | |
- | -su: cd: lab-: No such file or directory | + | |
- | + | ||
- | dexter@mjolnir:~$ cd lab-mandark/ | + | |
- | + | ||
- | dexter@mjolnir:~/lab-mandark$ ls -l | + | |
- | total 0 | + | |
- | + | ||
- | dexter@mjolnir:~/lab-mandark$ touch file | + | |
- | + | ||
- | dexter@mjolnir:~/lab-mandark$ git add file | + | |
- | + | ||
- | dexter@mjolnir:~/lab-mandark$ git commit -sm "Initial commit" | + | |
- | [master (root-commit) f825621] Initial commit | + | |
- | 0 files changed, 0 insertions(+), 0 deletions(-) | + | |
- | create mode 100644 file | + | |
- | + | ||
- | dexter@mjolnir:~/lab-mandark$ git push origin master | + | |
- | Counting objects: 3, done. | + | |
- | Writing objects: 100% (3/3), 224 bytes, done. | + | |
- | Total 3 (delta 0), reused 0 (delta 0) | + | |
- | To gitolite@heimdall.local:lab-mandark | + | |
- | * [new branch] master -> master | + | |
- | </code></solution> | + | |
- | + | ||
- | *[11]. Din contul utilizatorului {{{deedeee}}} încercati să faceți un commit și un push în {{{lab-dexter}}}. | + | |
- | <solution><code> | + | |
- | deedee@mjolnir:~$ git clone gitolite@heimdall.local:lab-dexter | + | |
- | Cloning into 'lab-dexter'... | + | |
- | remote: Counting objects: 3, done. | + | |
- | Receiving objects: 100% (3/3), 208 bytes, done. | + | |
- | remote: Total 3 (delta 0), reused 0 (delta 0) | + | |
- | + | ||
- | deedee@mjolnir:~$ cd lab-dexter/ | + | |
- | + | ||
- | deedee@mjolnir:~/lab-dexter$ ls -l | + | |
- | total 0 | + | |
- | -rw-r--r-- 1 deedee deedee 0 Jan 19 16:51 file | + | |
- | + | ||
- | deedee@mjolnir:~/lab-dexter$ echo "hello" > file | + | |
- | + | ||
- | deedee@mjolnir:~/lab-dexter$ git add file | + | |
- | + | ||
- | deedee@mjolnir:~/lab-dexter$ git commit -sm "Updates file" | + | |
- | [master 2d34b36] Updates file | + | |
- | 1 files changed, 1 insertions(+), 0 deletions(-) | + | |
- | + | ||
- | deedee@mjolnir:~/lab-dexter$ git push | + | |
- | W access for lab-dexter DENIED to deedee | + | |
- | (Or there may be no repository at the given path. Did you spell it correctly?) | + | |
- | fatal: The remote end hung up unexpectedly | + | |
- | </code></solution> | + | |
- | + | ||
- | + | ||
- | *[12].a. Doriți să creați, în gitolite, repository-ul {{{school}}} care să fie vizibil (read-only) prin {{{www-data}}}. Pentru aceasta, configurați întâi gitolite astfel încât noile repository-uri să fie create cu drepturi 755 pentru directoare și 644 pentru fișiere. (**Hint**: {{{.gitolite.rc}}}) | + | |
- | *[12].b. Configurați repository-ul {{{school}}} pentru a fi vizibil prin Gitweb și accesibil prin Git peste HTTP. (Hint: {{{git update-server-info}}}). | + | |
- | <solution><code> | + | |
- | gitolite@heimdall:~$ cat .gitolite.rc | grep MASK | + | |
- | $REPO_UMASK = 0022; | + | |
- | + | ||
- | + | ||
- | student@mjolnir:~/gitolite-admin/conf$ cat gitolite.conf | tail -n 2 | + | |
- | repo school | + | |
- | RW+ = dexter deedee | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/conf$ git add gitolite.conf | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/conf$ git commit -sm "Adds school repo" | + | |
- | [master 2c23965] Adds school repo | + | |
- | 1 files changed, 3 insertions(+), 0 deletions(-) | + | |
- | + | ||
- | student@mjolnir:~/gitolite-admin/conf$ git push | + | |
- | Counting objects: 7, done. | + | |
- | Delta compression using up to 2 threads. | + | |
- | Compressing objects: 100% (3/3), done. | + | |
- | Writing objects: 100% (4/4), 398 bytes, done. | + | |
- | Total 4 (delta 1), reused 0 (delta 0) | + | |
- | remote: creating school... | + | |
- | remote: Initialized empty Git repository in /var/lib/gitolite/repositories/school.git/ | + | |
- | To gitolite@heimdall.local:gitolite-admin | + | |
- | f47782b..7a9615b master -> master | + | |
- | + | ||
- | + | ||
- | gitolite@heimdall:~$ cd repositories/school.git/hooks/ | + | |
- | + | ||
- | gitolite@heimdall:~/repositories/school.git/hooks$ cp post-update.sample post-update | + | |
- | </code></solution> | + | |
- | + | ||
- | ===== 6. Redmine (2p) ===== | + | |
- | + | ||
- | *Comenzi/concepte/fișiere | + | |
- | *Redmine | + | |
- | *{{{/usr/share/redmine/}}} | + | |
- | *{{{/etc/redmine/}}} | + | |
- | + | ||
- | ==== Tutorial ==== | + | |
- | + | ||
- | *[01]. Pe **mașina virtuală**, instalați Redmine folosind {{{apt-get install redmine}}}. | + | |
- | *[01].a. Folosiți numele {{{default}}} (cel implicit) pentru instanța de Redmine și folosiți optiunile implicite în asistentul de instalare. | + | |
- | *[01].b. Alegeți o bază de date {{{sqlite3}}}. | + | |
- | <solution><code> | + | |
- | root@heimdall:~# apt-get install redmine | + | |
- | [...] | + | |
- | </code></solution> | + | |
- | + | ||
- | *[02]. Urmariți directoarele de instalare: | + | |
- | *{{{/usr/share/redmine/}}} | + | |
- | *{{{/etc/redmine/default/}}} | + | |
- | *{{{/var/lib/dbconfig-common/sqlite3/redmine/instances/default/}}} | + | |
- | *{{{/var/log/redmine/default/}}} | + | |
- | *{{{/var/lib/redmine/default/}}} | + | |
- | <solution><code> | + | |
- | cd, ls in directoare | + | |
- | </code></solution> | + | |
- | + | ||
- | *[03]. Configurați suport Redmine în Apache2. | + | |
- | *[03].a. Instalați modulul Passenger folosind {{{apt-get install libapache2-mod-passenger}}}. | + | |
- | *[03].b. Creați site-ul {{{myredmine.org}}} conținând site-ul Redmine, prin rularea comenzii {{{cp /usr/share/doc/redmine/examples/apache2-passenger-host.conf /etc/apache2/sites-available/myredmine.org}}}. | + | |
- | *[03].b.1. Eliminați directiva {{{Listen}}} din fișierul de configurare al site-ului {{{myredmine.org}}}. | + | |
- | *[03].b.2. Actualizați fișierul site-ului pentru a folosi portul standard ({{{<VirtualHost *:80>}}}). | + | |
- | *[03].b.3. Actualizați în fișierul site-ului directiva {{{ServerName}}} ls myredmine.org | + | |
- | *[03].b.4. Creați un link simbolic în {{{/var/lib/redmine/default/passenger}}} către {{{/usr/share/redmine}}} | + | |
- | *[03].c. Activați site-ul ({{{a2ensite myredmine.org}}}) și reporniți serviciul {{{/etc/init.d/apache2 restart}}}. | + | |
- | <solution><code> | + | |
- | root@heimdall:~# apt-get install libapache2-mod-passenger | + | |
- | [...] | + | |
- | + | ||
- | root@heimdall:~# cp /usr/share/doc/redmine/examples/apache2-passenger-host.conf /etc/apache2/sites-available/myredmine.org | + | |
- | + | ||
- | root@heimdall:~# cat /etc/apache2/sites-available/myredmine.org | grep -v ^# | head -n 2 | + | |
- | <VirtualHost localhost:80> | + | |
- | ServerName myredmine.org | + | |
- | + | ||
- | root@heimdall:~# a2ensite myredmine.org | + | |
- | Enabling site myredmine.org. | + | |
- | To activate the new configuration, you need to run: | + | |
- | service apache2 reload | + | |
- | + | ||
- | root@heimdall:~# service apache2 restart | + | |
- | Restarting web server: apache2 ... waiting . | + | |
- | </code></solution> | + | |
- | + | ||
- | *Pe mașina fizică mapați {{{myredmine.org}}} la ip-ul mașinii virtuale și verificați funcționalitatea site-ului creat anterior în apache. | + | |
- | <solution><code> | + | |
- | root@mjolnir:~# cat /etc/hosts | grep myredmine | + | |
- | 192.168.48.128 myredmine.org | + | |
- | </code></solution> | + | |
- | + | ||
- | + | ||
- | ==== Exerciții ==== | + | |
- | + | ||
- | *[01]. Autentificați-vă pe Redmine folosind username/password de forma {{{admin/admin}}}. Creați un cont nou căruia îi acordați drepturi administrative. | + | |
- | *[01].a. Autentificați-vă folosind contul nou creat și dezactivați contul {{{admin}}}. (**Hint**: lock) | + | |
- | *[01].b. Verificați că toate aspectele din {{{Administration->Information}}} sunt verificate/rezolvate. | + | |
- | *[02].a. Creați, în Redmine, conturile {{{dastardly}}}, {{{muttley}}}, {{{zilly}}} și {{{clunk}}}. | + | |
- | *[02].b. Creați proiectele {{{squish-squasher}}} și proiectul {{{birdie-wagon}}}. Adăugați la primul pe {{{dastardly}}} cu rol de manager și pe {{{muttley}}} cu rol de dezvoltator. Adăugați la al doilea pe {{{clunk}}} cu rol de manager și pe {{{zilly}}} cu rol de dezvoltator. | + | |
- | *[03]. Creați două repository-uri Git ({{{squish-squasher.git}}} și {{{birdie-wagon.git}}}) în home-ul utilizatorului {{{student}}} și integrați-le în Redmine, în cadrul celor două proiecte de mai sus. | + | |
- | + | ||
- | ===== Bonus ===== | + | |
- | + | ||
- | *[01]. Configurați trimiterea de mesaje în momentul în care realizați un push în cadrul unui director. | + | |
- | *Hints: | + | |
- | *Urmăriți și activați hook-ul de post-receive. | + | |
- | *Configurați variabilele de configurare Git necesare. (vedeți finalul fișierului inclus) | + | |
- | *Urmăriti configurarea variabilelor folosind comanda {{{git config nume.variabila}}}. (De exemplu: {{{git config hooks.mailinglist}}}). | + | |
- | <solution><code> | + | |
- | $ cp post-receive.sample post-receive | + | |
- | ; se decomentează ultima linie a fișierului | + | |
- | $ git config 'hooks.mailinglist=gogu@sclipici.com' | + | |
- | $ git config 'hooks.envelopesender=gitolite@destiny.local' | + | |
- | $ git config 'emailprefix=[git-post-receive]' | + | |
- | ; ulterior se va da push în directorul cu pricina | + | |
- | </code></solution> | + |