├── README.md
├── jssmanager.sh
└── license
/README.md:
--------------------------------------------------------------------------------
1 | # JSS Manager
2 |
3 | JSS Manager automates the installation and management of JAMF's manual installer in a multi-context (also known as multi-tenancy) environment.
4 |
5 | A multi-context environment will allow you to host multiple JSS contexts from a single server, like so:
6 |
7 | - https://my.jssserver.com:8443/production
8 | - https://my.jssserver.com:8443/development
9 | - https://my.jssserver.com:8443/testing
10 |
11 | ## Contents
12 |
13 | - [Features](#features)
14 | - [Installation](#installation)
15 | - [Setup](#setup)
16 | - [Java](#java)
17 | - [MySQL](#mysql)
18 | - [Tomcat](#tomcat)
19 | - [JSS Webapp](#jss-webapp)
20 | - [Environment](#environment)
21 | - [Use](#use)
22 |
23 |
24 | ## Features
25 |
26 | JSS Manager can handle the following tasks.
27 |
28 | - Deploy a new JSS context
29 | - Upgrade an existing JSS context
30 | - Upgrade all JSS contexts
31 | - Delete an existing JSS context
32 | - Display the name of all JSS contexts
33 | - Restart Tomcat
34 | - Start Tomcat
35 | - Stop Tomcat
36 |
37 | ## Installation
38 |
39 | Copy the jssmanager.sh to your desired location on your JSS server. If you are operating in a multi-server configuration, jssmanager.sh will have to be copied to every server running Tomcat, and each task must be run from each server.
40 |
41 | ## Setup
42 |
43 | You will need to meet the following pre-requisites before JSS Manager can run sucessfully.
44 |
45 | ### Java
46 |
47 | The Java JDK (Java Development Kit) will need to be installed. For more information on installing Java, please see https://jamfnation.jamfsoftware.com/article.html?id=28.
48 |
49 | ### MySQL
50 |
51 | MySQL will need to be installed.
52 |
53 | If operating in a single machine configuration, you will need to install MySQL server.
54 |
55 | If operating in a configuration where your database sever is separate from your webapp server, MySQL client will need to be installed on each server running JSS Manager.
56 |
57 | For more information on installing MySQL, please see https://jamfnation.jamfsoftware.com/article.html?id=28.
58 |
59 | ### Tomcat
60 |
61 | Tomcat will need to be installed. This can either be done via manual installation, or using JAMF Software's JSS Installer for Linux to create your first concept. JSS Manager will auto-detect which installation method was used and act accordingly.
62 |
63 | ### JSS Webapp
64 |
65 | You will need to place the JSS Webapp (ROOT.war) somewhere on your server. This can be found by logging into JAMF Nation, going to My Assets, and finding the JSS Manuall Installer under Show alternative downloads.
66 |
67 | ### Environment
68 |
69 | There are several variables in the script that need to be customized to suit your environment.
70 |
71 | dbHost - set this to the DNS name or IP of your MySQL server. If you're running MySQL on the same server as your webapp, you can leave this set to localhost, otherwise you will need to modify it.
72 |
73 | dbRoot - the MySQL root user.
74 |
75 | mysqlRootPwd - The MySQL root password. Leave this blank to be prompted each time.
76 |
77 | webapp - set this to the location or your ROOT.war file.
78 |
79 | logPath - where you want to store logs for the JSS. The default location is /var/log/jss.
80 |
81 | eth - The local ethernet interface. This is used when granting permissions on the database. This should not need to be changed unless you have multiple interfaces on your server AND your MySQL databases are on a separate server. Use the interface that will be used when communicating from the Tomcat server to the MySQL server.
82 |
83 | ## Use
84 |
85 | Coming soon.
86 |
--------------------------------------------------------------------------------
/jssmanager.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | ##########################################################################################
4 | #
5 | # JSS Manager
6 | #
7 | # This program is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation; either version 2 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with this program; if not, write to the Free Software Foundation, Inc.,
19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 | #
21 | ##########################################################################################
22 | #
23 | # ABOUT THIS PROGRAM
24 | #
25 | # NAME
26 | # jssManager
27 | #
28 | # DOCUMENTATION
29 | # See https://github.com/JSSManager/jssmanager for documentation and information
30 | #
31 | ##########################################################################################
32 |
33 |
34 | ##########################################################################################
35 | ############### Edit the following variables to suit your environment ####################
36 | ##########################################################################################
37 |
38 | # The FQDN or IP of your MySQL database host
39 | # Leave this blank to have the script prompt each time
40 |
41 | dbHost="localhost"
42 |
43 | # MySQL root user
44 |
45 | dbRoot="root"
46 |
47 | # MySQL root password
48 | # Leave this blank to have the script prompt each time
49 |
50 | mysqlRootPwd=""
51 |
52 | # Path to dump MySQL database (do not leave a trailing / at the end of your path)
53 |
54 | dbDumpPath="/usr/local/jssmanager/backups"
55 |
56 | # Set dbDump to "yes" to always dump the database without asking
57 | # Set dbDump to "no" to never dump the database without asking
58 | # Set dbDump to "prompt" to always be asked if you want to dump the database
59 |
60 | dbDump="prompt"
61 |
62 | # Path where you store your JSS logs (do not leave a trailing / at the end of your path)
63 |
64 | logPath="/var/log/JSS"
65 |
66 | # Path to your .war file
67 |
68 | webapp="/usr/local/jssmanager/ROOT.war"
69 |
70 | # Ethernet interface for the local IP of the server
71 | # This is the IP the server uses to connect to the database host
72 | # In most setups, this won't have to be changed
73 |
74 | eth="eth0"
75 |
76 | # Path to the log file for the jssmanager
77 |
78 | logLocation="/var/log/"
79 |
80 | ########### It is not recommended that you make any changes after this line ##############
81 |
82 | ##########################################################################################
83 | ################################### Begin functions ######################################
84 | ##########################################################################################
85 |
86 | # The yesNo function is used several times throughout the script to confirm the
87 | # user wants to continue with the operation.
88 |
89 | function yesNo()
90 | {
91 | yesNo=""
92 | read yno
93 | case $yno in
94 |
95 | [yY] | [yY][Ee][Ss] )
96 | yesNo="yes";;
97 |
98 | [nN] | [nN][Oo] )
99 | yesNo="no";;
100 |
101 | *) echo "Invalid input";;
102 | esac
103 | }
104 |
105 | # The deleteMenu function prompts the user for the name of the context they want to delete
106 |
107 | function deleteMenu()
108 | {
109 | echo "Please enter the name of the context you would like to delete."
110 | echo
111 | read -p "Context Name: " contextName
112 |
113 | if [ ! -d "$tomcatPath/webapps/$contextName" ]
114 | then
115 | echo "$contextName is not a valid JSS context."
116 | sleep 3
117 | else
118 | echo "$contextName will be deleted."
119 | echo "Would you like to continue?"
120 | yesNo
121 |
122 | if [ $yesNo == "yes" ]
123 | then
124 | echo "Deleting $contextName..."
125 | deleteWebapp
126 | else
127 | echo "$contextName will not be deleted."
128 | fi
129 | fi
130 | mainMenu
131 | }
132 |
133 | # The deleteWebapp function deletes the JSS webapp for the specified context.
134 |
135 | function deleteWebapp()
136 | {
137 | rm -rf $tomcatPath/webapps/$contextName.war
138 | if [ "$?" == "0" ]
139 | then
140 | echo "Deleted $tomcatPath/webapps/$contextName.war"
141 | else
142 | echo "Unable to delete $tomcatPath/webapps/$contextName.war"
143 | fi
144 |
145 | rm -rf $tomcatPath/webapps/$contextName
146 | if [ "$?" == "0" ]
147 | then
148 | echo "Deleted $tomcatPath/webapps/$contextName"
149 | else
150 | echo "Unable to delete $tomcatPath/webapps/$contextName"
151 | fi
152 | }
153 |
154 | # The readDatabaseSettings function reads the DataBase.xml file for the specified context
155 | # and reads the Database host, name, user and password settings. This is used when upgading
156 | # existing JSS contexts.
157 |
158 | function readDatabaseSettings()
159 | {
160 | echo "Reading database connection settings..."
161 |
162 | dbHost=""
163 | dbName=""
164 | dbUser=""
165 | dbPass=""
166 |
167 | dbHost=$(sed -n 's|\s*\(.*\)|\1|p' $tomcatPath/webapps/$contextName/WEB-INF/xml/DataBase.xml)
168 | if [ "$?" == "0" ]
169 | then
170 | echo "Database host is $dbHost"
171 | else
172 | echo "Unable to retrieve database host"
173 | fi
174 | dbName=$(sed -n 's|\s*\(.*\)|\1|p' $tomcatPath/webapps/$contextName/WEB-INF/xml/DataBase.xml)
175 | if [ "$?" == "0" ]
176 | then
177 | echo "Database name is $dbName"
178 | else
179 | echo "Unable to retrieve database name"
180 | fi
181 | dbUser=$(sed -n 's|\s*\(.*\)|\1|p' $tomcatPath/webapps/$contextName/WEB-INF/xml/DataBase.xml)
182 | if [ "$?" == "0" ]
183 | then
184 | echo "Database user is $dbUser"
185 | else
186 | echo "Unable to retrieve database user"
187 | fi
188 | dbPass=$(sed -n 's|\s*\(.*\)|\1|p' $tomcatPath/webapps/$contextName/WEB-INF/xml/DataBase.xml)
189 | if [ "$?" == "0" ]
190 | then
191 | echo "Database password is $dbPass"
192 | else
193 | echo "Unable to retrieve database password"
194 | fi
195 |
196 | if [ -z $dbHost ] || [ -z $dbName ] || [ -z $dbUser ] || [ -z $dbPass ]
197 | then
198 | echo
199 | echo
200 | echo "Unable to retrieve database settings"
201 | echo "Updated webapp will be unable to connect to the database"
202 | echo "Do you want to continue?"
203 | yesNo
204 | if [ $yesNo == "yes" ]
205 | then
206 | echo "Continuing update without database connection information"
207 | else
208 | mainMenu
209 | fi
210 | fi
211 | }
212 |
213 | # The touchLogFiles function first checks for the existance of the directory specified
214 | # in logPath, and gives the option to create or specify a new path if it doesn't exist.
215 | # It then checks for the existance of unique log files for the context, and creates
216 | # them if none are found.
217 |
218 | function touchLogFiles()
219 | {
220 | until [ -d "$logPath" ]
221 | do
222 | echo "$logPath does not exist!"
223 | echo "Would you like to create it?"
224 | yesNo
225 |
226 | if [ $yesNo == "yes" ]
227 | then
228 | echo Creating $logPath
229 | mkdir -p $logPath
230 | if [ "$?" == "0" ]
231 | then
232 | echo "Created $logPath"
233 | else
234 | echo "Unable to create $logPath"
235 | fi
236 | elif [ $yesNo == "no" ]
237 | then
238 | echo
239 | echo "Please specify a new directory for log files."
240 | echo "Make sure not to leave a trailing / at the end of your path."
241 | echo
242 | read -p "Log directory: " logPath
243 | fi
244 | done
245 |
246 | if [ ! -d "$logPath/$contextName" ]
247 | then
248 | echo Creating $logPath/$contextName/
249 | mkdir $logPath/$contextName
250 | if [ "$?" == "0" ]
251 | then
252 | echo "Created $logPath/$contextName/"
253 | else
254 | echo "Error: Unable to create $logPath/$contextName/"
255 | fi
256 | chown tomcat7:tomcat7 $logPath/$contextName
257 | if [ "$?" != "0" ]
258 | then
259 | echo "Error: unable to change ownership on $logPath/$contextName"
260 | fi
261 | else
262 | echo $logPath/$contextName/ exists
263 | fi
264 |
265 | if [ ! -f "$logPath/$contextName/JAMFSoftwareServer.log" ]
266 | then
267 | echo Creating $logPath/$contextName/JAMFSoftwareServer.log
268 | touch $logPath/$contextName/JAMFSoftwareServer.log
269 | if [ "$?" == "0" ]
270 | then
271 | echo "Created JAMFSoftwareServer.log in $logPath/$contextName/"
272 | else
273 | echo "Error: Unable to create JAMFSoftwareServer.log in $logPath/$contextName/"
274 | fi
275 | chown tomcat7:tomcat7 $logPath/$contextName/JAMFSoftwareServer.log
276 | if [ "$?" != "0" ]
277 | then
278 | echo "Error: Unable to change ownership on JAMFSoftwareServer.log in $logPath/$contextName/"
279 | fi
280 | else
281 | echo $logPath/$contextName/JAMFSoftwareServer.log exists
282 | fi
283 |
284 | if [ ! -f "$logPath/$contextName/jamfChangeManagement.log" ]
285 | then
286 | echo Creating $logPath/$contextName/jamfChangeManagement.log
287 | touch $logPath/$contextName/jamfChangeManagement.log
288 | if [ "$?" == "0" ]
289 | then
290 | echo "Created jamfChangeManagement.log in $logPath/$contextName/"
291 | else
292 | echo "Error: Unable to create jamfChangeManagement.log in $logPath/$contextName/"
293 | fi
294 | chown tomcat7:tomcat7 $logPath/$contextName/jamfChangeManagement.log
295 | if [ "$?" != "0" ]
296 | then
297 | echo "Error: Unable to change ownership on jamfChangeManagement.log in $logPath/$contextName/"
298 | fi
299 | else
300 | echo $logPath/$contextName/jamfChangeManagement.log exists
301 | fi
302 | }
303 |
304 | # The deployWebapp function deploys the JSS webapp using the specified context name
305 | # and database connection settings.
306 |
307 | function deployWebapp()
308 | {
309 | echo Deploying Tomcat webapp
310 | cp $webapp $tomcatPath/webapps/$contextName.war
311 | if [ "$?" != "0" ]
312 | then
313 | echo "Error: unable to copy $webapp to $tomcatPath/webapps/"
314 | fi
315 |
316 | # Sleep timer to allow tomcat app to deploy
317 |
318 | counter=0
319 | while [ $counter -lt 12 ]
320 | do
321 | if [ ! -f "$tomcatPath/webapps/$contextName/WEB-INF/xml/DataBase.xml" ]
322 | then
323 | echo "Waiting for Tomcat webapp to deploy..."
324 | sleep 5
325 | let counter=counter+1
326 | else
327 | let counter=12
328 | fi
329 | done
330 |
331 | if [ ! -f "$tomcatPath/webapps/$contextName/WEB-INF/xml/DataBase.xml" ]
332 | then
333 | echo Something is wrong...
334 | echo Tomcat webapp has not deployed.
335 | echo Aborting!
336 | sleep 1
337 | mainMenu
338 | else
339 | echo Webapp has deployed.
340 | fi
341 |
342 | # Change log4j files to point logs to new log locations
343 |
344 | echo Updating log4j files
345 | if [ -f "$tomcatPath/webapps/$contextName/WEB-INF/classes/log4j.JAMFCMFILE.properties" ]
346 | then
347 | sed -e "s@log4j.appender.JAMFCMFILE.File=.*@log4j.appender.JAMFCMFILE.File=$logPath/$contextName/jamfChangeManagement.log@" -e "s@log4j.appender.JAMF.File=.*@log4j.appender.JAMF.File=$logPath/$contextName/JAMFSoftwareServer.log@" -i $tomcatPath/webapps/$contextName/WEB-INF/classes/log4j.JAMFCMFILE.properties
348 | if [ "$?" != "0" ]
349 | then
350 | echo "Error: Unable to write settings to log4j.JAMFCMFILE.properties"
351 | fi
352 | fi
353 |
354 | if [ -f "$tomcatPath/webapps/$contextName/WEB-INF/classes/log4j.JAMFCMSYSLOG.properties" ]
355 | then
356 | sed "s@log4j.appender.JAMF.File=.*@log4j.appender.JAMF.File=$logPath/$contextName/JAMFSoftwareServer.log@" -i $tomcatPath/webapps/$contextName/WEB-INF/classes/log4j.JAMFCMSYSLOG.properties
357 | if [ "$?" != "0" ]
358 | then
359 | echo "Error: Unable to write settings to log4j.JAMFCMSYSLOG.properties"
360 | fi
361 | fi
362 |
363 | sed -e "s@log4j.appender.JAMFCMFILE.File=.*@log4j.appender.JAMFCMFILE.File=$logPath/$contextName/jamfChangeManagement.log@" -e "s@log4j.appender.JAMF.File=.*@log4j.appender.JAMF.File=$logPath/$contextName/JAMFSoftwareServer.log@" -i $tomcatPath/webapps/$contextName/WEB-INF/classes/log4j.properties
364 | if [ "$?" != "0" ]
365 | then
366 | echo "Error: Unable to write settings to log4j.properties"
367 | fi
368 | # Add database connection info to JSS context
369 |
370 | echo Writing database connection settings
371 | sed -e "s@.*@$dbHost@" -e "s@.*@$dbName@" -e "s@.*@$dbUser@" -e "s@.*@$dbPass@" -i $tomcatPath/webapps/$contextName/WEB-INF/xml/DataBase.xml
372 | if [ "$?" != "0" ]
373 | then
374 | echo "Error: Unable to write settings to DataBase.xml"
375 | fi
376 | }
377 |
378 | # The updateWebapp function asks the user for the name of the context, validates it, then
379 | # uses the readDatabaseSettings function to pull the existing database connection settings
380 | # and store them, then tests the settings to ensure authentication to the database, then
381 | # it will verify the log files exist and create them if not, then it will delete the exsting
382 | # webapp, then deploy the new webapp, and finally it prompt for a tomcat restart.
383 |
384 | function updateWebapp()
385 | {
386 | echo "Please enter the name of the context you would like to update."
387 | echo
388 | read -p "Context Name: " contextName
389 |
390 | if [ ! -d "$tomcatPath/webapps/$contextName" ]
391 | then
392 | echo "$contextName is not a valid JSS context."
393 | sleep 3
394 | else
395 | echo "$contextName will be updated."
396 | echo "Would you like to continue?"
397 | yesNo
398 |
399 | if [ $yesNo == "yes" ]
400 | then
401 | echo "Updating $contextName..."
402 | updateContext
403 | #tomcatRestartPrompt
404 | else
405 | echo "$contextName will not be updated."
406 | fi
407 | fi
408 | mainMenu
409 | }
410 |
411 | # The updateAll function will update ALL existing contexts in the Tomcat webapp directory.
412 | # The automatic Tomcat restart has been removed due to Tomcat restarts causing database
413 | # corruption when run during database upgrades from 8.7x to 9.0
414 |
415 | function updateAll()
416 | {
417 | dbDumpPrompt
418 | echo "All existing JSS contexts will be updated."
419 | echo "Are you sure you want to continue?"
420 | yesNo
421 | if [ $yesNo == "yes" ]
422 | then
423 | for dirs in $tomcatPath/webapps/*/
424 | do
425 | contextName="$(basename $dirs)"
426 | echo
427 | echo "Updating $contextName..."
428 | updateContext
429 | done
430 | fi
431 | mainMenu
432 | }
433 |
434 | # The displayAll function is used to display a list of all JSS contexts
435 |
436 | function displayAll()
437 | {
438 | echo "Existing JSS contexts:"
439 | echo
440 | for dirs in $tomcatPath/webapps/*/
441 | do
442 | contextName="$(basename $dirs)"
443 | echo "$contextName"
444 | done
445 | echo
446 | echo
447 | read -s -p "Press [Enter] to reurn to the main menu"
448 | mainMenu
449 | }
450 |
451 | function updateContext()
452 | {
453 | readDatabaseSettings
454 | if [ $dbDump == "yes" ]
455 | then
456 | dumpDatabase
457 | fi
458 | touchLogFiles
459 | deleteWebapp
460 | deployWebapp
461 | }
462 |
463 | # The newcontext function gets the context name and database connection information
464 | # from the user, and deploys a new context. If the user enters an context name
465 | # that is already in use, the script will prompt to upgrade the context instead.
466 |
467 | function newcontext()
468 | {
469 | echo
470 | echo "Please enter a name for this context."
471 | echo
472 | read -p "Context Name: " contextName
473 |
474 | if [ -d "$tomcatPath/webapps/$contextName" ]
475 | then
476 | echo "$contextName already exists!"
477 | echo "Would you like to upgrade this context?"
478 | yesNo
479 | if [ $yesNo == "yes" ]
480 | then
481 | echo "Updating $contextName..."
482 | updateContext
483 | #tomcatRestartPrompt
484 | elif [ $yesNo == "no" ]
485 | then
486 | echo "Aborting deployment."
487 | fi
488 | else
489 | echo
490 | echo "Please enter the name of the database."
491 | echo
492 | read -p "Database Name: " dbName
493 | echo
494 | echo "Please enter the name of the database user."
495 | echo
496 | read -p "Database User: " dbUser
497 | echo
498 | echo "Please enter the database user's password."
499 | echo
500 | read -s -p "Database Password: " dbPass
501 |
502 | if [ $dbHost == "" ]
503 | then
504 | echo "Please enter the hostname or IP address of the database server."
505 | echo
506 | read -p "Database Server: " dbHost
507 | fi
508 |
509 | echo "A new context will be deployed with the following settings."
510 | echo
511 | echo "Context Name: $contextName"
512 | echo "Database Name: $dbName"
513 | echo "Database User: $dbUser"
514 | echo "Database Pass: $dbPass"
515 | echo "Database Host: $dbHost"
516 | echo
517 | echo "Would you like to continue?"
518 | yesNo
519 |
520 | if [ $yesNo == "yes" ]
521 | then
522 | testDatabase
523 | touchLogFiles
524 | deployWebapp
525 | #tomcatRestartPrompt
526 | elif [ $yesNo == "no" ]
527 | then
528 | echo "Context will not be created."
529 | sleep 3
530 | mainMenu
531 | fi
532 | fi
533 | mainMenu
534 | }
535 |
536 | # The createDatabase function creates a database on the host server
537 |
538 | function createDatabase()
539 | {
540 | echo "Creating database $dbName..."
541 | mysql -h $dbHost -u $dbRoot -p$mysqlRootPwd -e "CREATE DATABASE $dbName;"
542 | if [ "$?" == "0" ]
543 | then
544 | echo "Database $dbName created"
545 | else
546 | echo "Error: Unable to create database $dbName"
547 | fi
548 |
549 | }
550 |
551 | # The grantPermissions function grants permission to a user for the specified database
552 |
553 | function grantPermissions()
554 | {
555 | echo "Granting permissions on database $dbName to user $dbUser at $serverAddress..."
556 | mysql -h $dbHost -u $dbRoot -p$mysqlRootPwd -e "GRANT ALL ON $dbName.* TO $dbUser@$serverAddress IDENTIFIED BY '$dbPass';"
557 | if [ "$?" == "0" ]
558 | then
559 | echo "Permissions granted"
560 | else
561 | echo "Error: Unable to grant permissions"
562 | fi
563 | }
564 |
565 | function testMysqlRoot()
566 | {
567 | echo "Testing MySQL root username and password..."
568 | # The following could potentially cause an infinite loop if a successful connection
569 | # to the database host can not be established
570 | until mysql -h $dbHost -u $dbRoot -p$mysqlRootPwd -e ";" ;
571 | do
572 | echo "Invalid MySQL root username or password. Please retry."
573 | read -p "MySQL Root User: " dbRoot
574 | read -s -p "MySQL Root Password: " mysqlRootPwd
575 | done
576 | }
577 |
578 | # The testDatabase function will first test for the existence of the database using the
579 | # root credentials, then checks to see if the specified user has permission to access the
580 | # database, offering to create the database and grant permissions as needed.
581 |
582 | function testDatabase()
583 | {
584 | if [ $dbHost == "localhost" ]
585 | then
586 | serverAddress="localhost"
587 | else
588 | serverAddress=`ifconfig $eth | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
589 | fi
590 |
591 | if [ -z "$mysqlRootPwd" ]
592 | then
593 | read -s -p "Enter MySQL root password: " mysqlRootPwd
594 | fi
595 |
596 | testMysqlRoot
597 |
598 | echo
599 | echo "Checking database connection settings..."
600 |
601 | dbTestUser=`mysqlshow --host=$dbHost --user=$dbUser --password=$dbPass $dbName| grep -v Wildcard | grep -o $dbName`
602 |
603 | if [ -z $dbTestUser ]
604 | then
605 | dbTestRoot=`mysqlshow --host=$dbHost --user=$dbRoot --password=$mysqlRootPwd $dbName| grep -v Wildcard | grep -o $dbName`
606 | if [ -z $dbTestRoot ]
607 | then
608 | echo "Database $dbName does not seem to exist."
609 | echo "Would you like to create it?"
610 | yesNo
611 | if [ $yesNo == "yes" ]
612 | then
613 | createDatabase
614 | grantPermissions
615 | elif [ $yesNo == "no" ]
616 | then
617 | echo "Database will not be created."
618 | echo "WARNING: Webapp may not be able to connect to database."
619 | fi
620 | elif [ $dbTestRoot == $dbName ]
621 | then
622 | echo "User $dbUser does not seem to have permission to access database $dbName."
623 | echo "Would you like to grant permissions?"
624 | yesNo
625 | if [ $yesNo == "yes" ]
626 | then
627 | grantPermissions
628 | elif [ $yesNo == "no" ]
629 | then
630 | echo "User will not be granted permission."
631 | echo "WARNING: Webapp may not be able to connect to database."
632 | fi
633 | fi
634 | else
635 | echo "Database connection test successful."
636 | fi
637 | }
638 |
639 | function dumpDatabase()
640 | {
641 | if [ -z "$mysqlRootPwd" ]
642 | then
643 | read -s -p "Enter MySQL root password: " mysqlRootPwd
644 | fi
645 |
646 | testMysqlRoot
647 |
648 | dbTestRoot=`mysqlshow --host=$dbHost --user=$dbRoot --password=$mysqlRootPwd $dbName| grep -v Wildcard | grep -o $dbName`
649 | if [ -z $dbTestRoot ]
650 | then
651 | echo "WARNING: Database $dbName does not appear to exist!"
652 | else
653 | if [ ! -d "$dbDumpPath/$dbName" ]
654 | then
655 | echo "Creating $dbDumpPath/$dbName"
656 | mkdir -p $dbDumpPath/$dbName
657 | if [ "$?" != "0" ]
658 | then
659 | echo "Error: Unable to create $dbDumpPath/$dbName"
660 | echo "Aborting!"
661 | sleep 1
662 | mainMenu
663 | fi
664 | fi
665 |
666 | NOW="$(date +"%Y-%m-%d-%H-%M")"
667 | echo "Dumping database $dbName to $dbDumpPath"
668 | mysqldump -h $dbHost -u $dbRoot -p$mysqlRootPwd $dbName > $dbDumpPath/$dbName/$NOW.$dbName.sql
669 | if [ "$?" == "0" ]
670 | then
671 | echo "Database dump successful"
672 | else
673 | echo "Error: Unable to dump database"
674 | echo "Aborting!"
675 | mainMenu
676 | fi
677 | fi
678 | }
679 |
680 | function dbDumpPrompt()
681 | {
682 | if [ $dbDump != "no" ] && [ $dbDump != "yes" ]
683 | then
684 | echo "Would you like to backup the database(s) before proceeding?"
685 | yesNo
686 | if [ $yesNo == "yes" ]
687 | then
688 | dbDump="yes"
689 | elif [ $yesNo == "no" ]
690 | then
691 | dbDump="no"
692 | fi
693 | fi
694 | }
695 |
696 | # Check to make sure script is being run as root
697 |
698 | function checkRoot()
699 | {
700 | echo "Checking to see if logged in as root..."
701 |
702 | currentUser=$(whoami)
703 |
704 | if [ $currentUser != root ]
705 | then
706 | echo "ID10T Error: You must be root to run this script."
707 | sleep 1
708 | echo "Aborting!"
709 | sleep 3
710 | exit 1
711 | else
712 | echo "Congratulations! You followed the directions and ran the script as root!"
713 | fi
714 | }
715 |
716 | # Check to make sure ROOT.war exists at the specified path
717 |
718 | function checkWebapp()
719 | {
720 |
721 | echo "Checking for $webapp..."
722 |
723 | if [ ! -f $webapp ]
724 | then
725 | echo "$webapp not found!"
726 | sleep 1
727 | echo "Aborting!"
728 | sleep 3
729 | exit 1
730 | else
731 | echo "Webapp found at $webapp."
732 | fi
733 | }
734 |
735 | # Check Tomcat installation method and set appropriate Tomcat path
736 |
737 | function checkTomcat()
738 | {
739 | echo "Checking Tomcat installation type..."
740 |
741 | if [ -d "/var/lib/tomcat7" ]
742 | then
743 | tomcatPath="/var/lib/tomcat7"
744 | elif [ -d "/usr/local/jss/tomcat" ]
745 | then
746 | tomcatPath="/usr/local/jss/tomcat"
747 | else
748 | echo "Tomcat7 does not appear to be installed."
749 | echo "Please install Tomcat7 before using this script."
750 | echo "Exiting..."
751 | sleep 3
752 | exit 1
753 | fi
754 |
755 | echo "Tomcat path is $tomcatPath"
756 | }
757 |
758 | # The tomcatRestartPrompt will ask the user if they want to restart tomcat.
759 |
760 | function tomcatRestartPrompt()
761 | {
762 | echo
763 | echo "A Tomcat restart is recommended."
764 | echo "Would you like to restart Tomcat now?"
765 | yesNo
766 | if [ $yesNo == "yes" ]
767 | then
768 | bounceTomcat
769 | elif [ $yesNo == "no" ]
770 | then
771 | echo "Tomcat will not be restarted."
772 | fi
773 | }
774 |
775 | # The bounceTomcat function checks to see if Tomcat was installed as part of the JSS
776 | # installer, or if Tomcat was installed manually, and sends the appropriate restart command.
777 |
778 | function bounceTomcat()
779 | {
780 | echo "Restarting Tomcat..."
781 |
782 | if [ -d "/var/lib/tomcat7" ]
783 | then
784 | service tomcat7 restart
785 | elif [ -d "/usr/local/jss/tomcat" ]
786 | then
787 | /etc/init.d/jamf.tomcat7 restart
788 | fi
789 | }
790 |
791 |
792 | # Starts Tomcat
793 |
794 | function startTomcat()
795 | {
796 | if [ -d "/var/lib/tomcat7" ]
797 | then
798 | service tomcat7 start
799 | elif [ -d "/usr/local/jss/tomcat" ]
800 | then
801 | /etc/init.d/jamf.tomcat7 start
802 | fi
803 | }
804 |
805 | # Stops Tomcat
806 |
807 | function stopTomcat()
808 | {
809 | if [ -d "/var/lib/tomcat7" ]
810 | then
811 | service tomcat7 stop
812 | elif [ -d "/usr/local/jss/tomcat" ]
813 | then
814 | /etc/init.d/jamf.tomcat7 stop
815 | fi
816 | }
817 |
818 |
819 | # isTomcatRunning function added 1/21/14 by kitzy to assess if Tomcat is running
820 | # wbapps will not deploy properly if Tomcat is stopped
821 |
822 | function isTomcatRunning()
823 | {
824 | tomcatPID=`ps auxw | grep "${tomcatPath}" | grep -v grep | awk '{print $2}'`
825 | if [ -z $tomcatPID ]
826 | then
827 | echo "Tomcat does not appear to be running."
828 | echo "Would you like to start it?"
829 | yesNo
830 | if [ $yesNo == "yes" ]
831 | then
832 | startTomcat
833 | elif [ $yesNo == "no" ]
834 | then
835 | echo "WARING: Webapps will not deploy properly if Tomcat is stopped!"
836 | echo "Are you sure you want to continue without starting Tomcat?"
837 | yesNo
838 | if [ $yesNo == "yes" ]
839 | then
840 | echo "You've been warned..."
841 | elif [ $yesNo == "no" ]
842 | then
843 | isTomcatRunning
844 | fi
845 | fi
846 | else
847 | echo "Tomcat is running."
848 | fi
849 | }
850 |
851 |
852 | # The exitPrep function clears variables containing passwords to eliminate a security risk
853 | # when exiting the script
854 |
855 | function exitPrep()
856 | {
857 | echo "Clearing passwords from variables..."
858 | mysqlRootPwd=""
859 | dbPass=""
860 | echo "Done."
861 | exit 0
862 | }
863 |
864 | # Main menu
865 |
866 | function mainMenu()
867 | {
868 | echo
869 | echo
870 | echo "What would you like to do?"
871 | echo
872 | echo "1 Deploy a new JSS context"
873 | echo "2 Upgrade an existing JSS context"
874 | echo "3 Upgrade ALL JSS contexts"
875 | echo "4 Delete an existing JSS context"
876 | echo "5 Display all JSS contexts"
877 | echo "6 Restart Tomcat"
878 | echo "7 Start Tomcat"
879 | echo "8 Stop Tomcat"
880 | echo "9 Exit"
881 | echo
882 |
883 | installType=""
884 |
885 | read -p "Enter your choice: " installType
886 | case $installType in
887 | 1) echo Deploying a new JSS...;
888 | newcontext;;
889 |
890 | 2) echo Upgrading an existing JSS...;
891 | updateWebapp;;
892 |
893 | 3) echo Upgrading ALL JSS contexts...;
894 | updateAll;;
895 |
896 | 4) echo Deleting an existing JSS...;
897 | deleteMenu;;
898 |
899 | 5) displayAll;;
900 |
901 | 6) bounceTomcat;
902 | mainMenu;;
903 |
904 | 7) startTomcat;
905 | mainMenu;;
906 |
907 | 8) stopTomcat;
908 | mainMenu;;
909 |
910 | 9) echo Exiting...;
911 | exitPrep;;
912 |
913 | *) echo Invalid Selection!;;
914 | esac
915 | }
916 |
917 | ##########################################################################################
918 | #################################### End functions #######################################
919 | ##########################################################################################
920 |
921 | # Trap [Ctrl+C] to clear passwords from variables when forcing exit
922 |
923 | trap 'exitPrep && exit 5' 2
924 |
925 | # Create log file
926 |
927 | NOW="$(date +"%Y-%m-%d-%H-%M")"
928 | echo "Creating $logLocation/$NOW.jssmanager.log"
929 | touch $logLocation/$NOW.jssmanager.log
930 |
931 | # Redirect stderr to stdout and print all to log
932 |
933 | exec 2>&1 > >(tee $logLocation/$NOW.jssmanager.log)
934 |
935 | clear
936 |
937 | echo "JSS Manager v2.0.2"
938 | echo "Copyright (C) 2013-2014 kitzy.org"
939 | echo "JSS Manager comes with ABSOLUTELY NO WARRANTY."
940 | echo "This is free software, and you are welcome to modify or redistribute it"
941 | echo "under certain conditions; see the GNU General Public License for details."
942 |
943 | checkRoot
944 |
945 | checkWebapp
946 |
947 | checkTomcat
948 |
949 | isTomcatRunning
950 |
951 | echo
952 | echo
953 | echo "Welcome to the JSS Manager!"
954 |
955 | mainMenu
956 |
--------------------------------------------------------------------------------
/license:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------