Files: exercises-cvs.txt

File exercises-cvs.txt, 6.1 KB (added by hervey, 9 years ago)

CVS exercises - TEXT

Line 
1CVS exercises
2AROC Workshop
3Guatemala City, Guatemala 2010
4
5
61. Install cvs
7
8        $ sudo apt-get install cvs
9
10
112. Init a new CVS ROOT:
12
13        *NOTE* Do this exercise as the normal user, NOT ROOT!
14
15        - First, set the environment variable "CVSROOT" to the path
16          Where your CVS repository will be created. We are going to
17          do this as the "tldadmin" user, so be sure you are not root.
18
19        $ CVSROOT=/home/tldadmin/cvs
20        $ export CVSROOT
21
22        - Now create the directory
23
24        $ mkdir $CVSROOT
25        $ cvs init
26
27        - Check that it was created correctly!
28
29        $ ls -l /home/tldadmin/cvs
30
31        - You should see a directory called "CVSROOT"
32        - Look at the contents of the directory.
33
34        $ ls -l /home/tldadmin/cvs/CVSROOT
35       
36        There should be quite a few files in the directory.
37
383. Let's create a project in CVS for the Nagios configuration files on your system
39   and import these files into CVS!
40
41        $ mkdir /home/tldadmin/temp
42        $ cp /etc/nagios3/conf.d/* /home/tldadmin/temp/.
43
44        - Now we need to import these files into CVS:
45        - Let's make a new project called "configs"
46
47        $ cd /home/tldadmin/temp
48        $ cvs import configs before_cvs start
49
50        (Note: the "before_cvs" and "start" are just names to say that
51        we are importing from "before we used CVS, and this is the start of the
52        new project")
53
54        - When you see this:
55
56Select an editor.  To change later, run 'select-editor'.
57  1. /bin/ed
58  2. /bin/nano        <---- easiest
59  3. /usr/bin/vim.basic
60  4. /usr/bin/vim.tiny
61
62Choose 1-4 [2]:
63
64        Select the editor you wish to use for comments in CVS. Your instructor likes choice 3.
65
66        Once you select an editor you will see this:
67
68CVS: ----------------------------------------------------------------------
69CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
70CVS:
71CVS: ----------------------------------------------------------------------
72
73        ... just enter a message saying what you did.
74
75        For example, add a line at the top of the file that says something like:
76
77        "This is a first import of our config files"
78
79        ... Then save the file + quit.
80
81        You should see something like this:
82       
83N configs/contacts_nagios2.cfg
84N configs/services_nagios2.cfg
85N configs/pcs.cfg
86N configs/timeperiods_nagios2.cfg
87N configs/switches.cfg
88N configs/extinfo_nagios2.cfg
89N configs/host-gateway_nagios3.cfg
90N configs/generic-service_nagios2.cfg
91N configs/localhost_nagios2.cfg
92N configs/hostgroups_nagios2.cfg
93N configs/routers.cfg
94N configs/servicegroups.cfg
95N configs/generic-host_nagios2.cfg
96
97No conflicts created by this import
98
99
1003b. Look at the contents of /home/tldadmin/cvs/configs
101
102        $ ls -l /home/tldadmin/cvs/configs
103
104total 52
105-r--r--r-- 1 tldadmin tldadmin 2873 2010-07-21 17:00 contacts_nagios2.cfg,v
106-r--r--r-- 1 tldadmin tldadmin 1354 2010-07-21 17:00 extinfo_nagios2.cfg,v
107-r--r--r-- 1 tldadmin tldadmin 1654 2010-07-21 17:00 generic-host_nagios2.cfg,v
108-r--r--r-- 1 tldadmin tldadmin 2305 2010-07-21 17:00 generic-service_nagios2.cfg,v
109-r--r--r-- 1 tldadmin tldadmin  714 2010-07-21 17:00 host-gateway_nagios3.cfg,v
110-r--r--r-- 1 tldadmin tldadmin 2642 2010-07-21 17:00 hostgroups_nagios2.cfg,v
111-r--r--r-- 1 tldadmin tldadmin 2669 2010-07-21 17:00 localhost_nagios2.cfg,v
112-r--r--r-- 1 tldadmin tldadmin 3669 2010-07-21 17:00 pcs.cfg,v
113-r--r--r-- 1 tldadmin tldadmin  961 2010-07-21 17:00 routers.cfg,v
114-r--r--r-- 1 tldadmin tldadmin 1088 2010-07-21 17:00 servicegroups.cfg,v
115-r--r--r-- 1 tldadmin tldadmin 2253 2010-07-21 17:00 services_nagios2.cfg,v
116-r--r--r-- 1 tldadmin tldadmin  997 2010-07-21 17:00 switches.cfg,v
117-r--r--r-- 1 tldadmin tldadmin 2111 2010-07-21 17:00 timeperiods_nagios2.cfg,v
118
119
1204. Now we can remove our temp directory, and check out the
121   configs/ project from CVS!
122
123        $ cd /home/tldadmin
124        $ rm -rf temp
125
126        - Let's now check out from cvs :
127
128        $ cvs -d /home/tldadmin/cvs co configs
129
130        - You should see the following:
131
132cvs checkout: Updating configs
133U configs/contacts_nagios2.cfg
134U configs/extinfo_nagios2.cfg
135U configs/generic-host_nagios2.cfg
136U configs/generic-service_nagios2.cfg
137U configs/host-gateway_nagios3.cfg
138U configs/hostgroups_nagios2.cfg
139U configs/localhost_nagios2.cfg
140U configs/pcs.cfg
141U configs/routers.cfg
142U configs/servicegroups.cfg
143U configs/services_nagios2.cfg
144U configs/switches.cfg
145U configs/timeperiods_nagios2.cfg
146
147        $ ls -l /home/tldadmin/configs/
148
149        - Notice the CVS directory in /home/tldadmin/configs/
150
151        *NOTE* remember, never modify the CVS/ directory by hand.
152        It is only for experienced CVS users...
153       
154        - Note that the configs directory is created in whatever directory you in
155          in when you issue the cvs co (checkout) command.
156
1575. Modify a file, add another one, and check things in again:
158
159        $ cd /home/tldadmin/configs
160        $ vi pcs.cfg
161
162        Modify the config – for example, you could add a comment line at the top of the file.
163       
164        "# This version of pcs is part of our Concurrent Versioning System repository"
165       
166        (Don't use the quotes "). Then save and quit.
167
168        - Add the APT sources.list file to the directory:
169
170        $ cp /etc/apt/sources.list .
171
172        - Tell cvs to show us the status:
173
174        $ cvs status
175       
176        - There's a lot, to see it all:
177       
178        $ cvs status | more
179
180        - Add sources.list to CVS:
181
182        $ cvs add sources.list
183
184        - You should see this:
185
186cvs add: scheduling file `sources.list' for addition
187cvs add: use `cvs commit' to add this file permanently
188
189        - You are now ready to commit!
190
191        $ cvs commit
192
193        - If all goes well, you should have this in your editor window:
194
195CVS: ----------------------------------------------------------------------
196CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
197CVS:
198CVS: Committing in .
199CVS:
200CVS: Modified Files:
201CVS:    pcs.cfg
202CVS: Added Files:
203CVS:    sources.list
204CVS: ----------------------------------------------------------------------
205
206        ... add a message:
207
208        Importing APT sources.list, and modifying the pcs.cfg file.
209
210        ... then save + quit
211
212        You should see this:
213
214cvs commit: Examining .
215/home/tldadmin/cvs/configs/pcs.cfg,v  <--  pcs.cfg
216new revision: 1.2; previous revision: 1.1
217/home/tldadmin/cvs/configs/sources.list,v  <--  sources.list
218initial revision: 1.1
219
220
2216. Let's see the history for the pcs.cfg file:
222
223        $ cvs log pcs.cfg
224
225        ... notice the output
226
227        - Finally, let's try and see the difference between two
228          versions of the config.smokeping file:
229
230        $ cvs diff -r 1.1 -r 1.2 pcs.cfg
231
232        - What do you notice ?
233