├── .gitignore
├── LICENSE
├── README.md
├── daily
├── back.sh
└── day_1.sh
├── sm-shell
├── README.md
├── Resource
│ ├── Data
│ │ ├── .bash_profile
│ │ ├── backup.dmp
│ │ ├── data.txt
│ │ ├── httpd.conf
│ │ ├── ifcfg-enp4s0
│ │ ├── initORCLCDB.ora
│ │ ├── initlinuxDB.ora
│ │ ├── listener.ora
│ │ ├── local.repo
│ │ ├── mysql-5.6.24.tar.gz
│ │ ├── oratab
│ │ ├── repodata.tar.gz
│ │ ├── settings.ini
│ │ ├── tnsnames.ora
│ │ └── xe.tar.gz
│ └── Scripts
│ │ ├── apm.sh
│ │ ├── mail.sh
│ │ ├── messages.sh
│ │ ├── oracle.sh
│ │ ├── quota.sh
│ │ ├── repo.sh
│ │ └── settings.sh
└── sm_final.sh
├── sm
├── agm_v2_kernel.sh
├── hs-user.txt
├── packages.txt
└── sm-user.txt
└── vrising
├── autoset.sh
└── back.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | *.rpm
2 | update.sh
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Shell Contents
2 |
3 | ### 🔧 Server Manager Script
4 | >* [agm_v2_kernel.sh](https://github.com/Memori-al/bash-scripts/tree/main/sm)
5 |
- CLI 용 사용자 및 그룹 관리 스크립트
6 |
7 | >* [sm_final.sh](https://github.com/Memori-al/bash-scripts/tree/main/sm-shell)
8 |
- 서버관리 기말시험 자동화 쉘 스크립트
9 |
10 |
11 |
12 | ___
13 |
14 | ### 🧄 V Rising Manager Script
15 | >* [back.sh](https://github.com/Memori-al/bash-scripts/tree/main/vrising)
16 |
- 세이브 데이터 Git 자동 백업 스크립트
17 | >* [autoset.sh](https://github.com/Memori-al/bash-scripts/tree/main/vrising)
18 |
- V Rising Linux 환경 자동 설치 스크립트
19 |
20 |
21 |
22 | ___
23 | # Reference
24 |
--------------------------------------------------------------------------------
/daily/back.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 |
4 | function _Init() {
5 | if [[ -f "./setting.ini" ]]; then
6 | _variables=("log")
7 |
8 | for _var in "${_variables[@]}"; do
9 | _value=$(grep "$_var =" "./setting.ini" | cut -f2 -d "=")
10 | _value=$(echo "$_value" | sed 's/ //g')
11 | declare "_$var"_"=$_value"
12 | done
13 | else
14 | _Handler "0" "$(date +"%H:%M:%S")" "setting.ini"
15 | fi
16 | if [[ -f "./color.sh"]]; then
17 | source ./color.sh
18 | else
19 | _Handler "0" "$(date +"%H:%M:%S")" "color.sh"
20 | fi
21 | _Check
22 | }
23 |
24 |
25 | function _Check() {
26 | if [[ ]]; then
27 |
28 | fi
29 | }
30 |
31 |
32 | function _Handler() {
33 | case $1 in
34 | 0)
35 | _exception_type_="alert"
36 | _exception_message_="$3: file dosen't exist."
37 | ;;
38 | 1)
39 | _exception_type_="warning"
40 | _exception_message_="[$2|${magenta}warning${cls}|$USER|$_client_ip_] '$3' command execution. [$_try_]"
41 | ;;
42 | 2)
43 | _exception_type_="critical"
44 | _exception_message_="[$2|${red}critical${cls}|$USER|$_client_ip_] '$3' command execution. [$_try_]"
45 | ;;
46 | esac
47 |
48 |
49 |
50 | if [[ "$_exception_type_" == "Alert" ]]; then
51 | echo -e "$_exception_message_"
52 | else # Warning & Error Logging
53 | echo "${_exception_message_}" | tee -a /var/log/rsm_$(date +"%y%m%d").log > /dev/null
54 | echo -e "${red}You do not have permission to execute the command.${cls}"
55 | fi
56 | }
57 |
58 |
59 | _Init
--------------------------------------------------------------------------------
/daily/day_1.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # 파라미터 검증 코드
3 |
4 | function _Init() {
5 | title=Console
6 | _Check
7 | }
8 |
9 | function _Check() {
10 | if [[ "$1" == "" ]]; then # 1차 파라미터 검증
11 | _Handler "$(date "+%H:%M:%S")"
12 | fi
13 | }
14 |
15 | function _Handler() {
16 | echo "[$title|$1] Empty the Parameters!"
17 | } >> day_$(date "+%m%d").log
18 |
19 | _Init # 기초 설정
--------------------------------------------------------------------------------
/sm-shell/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # 👁️🗨️ Overview
4 | ### 🎯 제작 목적
5 | * 안녕하세요! 😃 전주대학교 **19**학번 **이강일**입니다.
6 | 리눅스를 어려워하는 🌿동기 및 후배분들을 위해 본 스크립트를 제작하게 되었습니다.
7 |
8 | * 본 스크립트는 전주대학교 서버관리 기말시험에 사용되는 자동화 쉘 스크립트입니다.
9 |
10 | * 매년 시험 문제가 바뀌어도 대응할 수 있도록 각 스크립트 부분을 모듈화하여 설계했습니다.
11 |
12 | * 스크립트 사용 시 설치 시간 포함 30~40 분 내에 시험을 끝마칠 수 있습니다.
13 | > ℹ️ 해당 문서는 다크 모드🌙에 최적화 된 문서입니다.
브라우저를 다크 모드🌙로 전환 시 더욱 원활하게 읽으실 수 있습니다!
14 |
15 | [](https://github.com/Memori-al/bash-scripts)
16 |
17 |
18 | ### 📑 구현 방법
19 | * 수정 및 추가가 용이한 고가용성(High Available) 코드로 설계했습니다.
20 | - 스크립트를 `트러블슈팅` 및 `예외처리`하기 쉽도록 설계했습니다.
21 |
22 |
23 | * 인기있는 `Bash Scripts 표준화 스타일`로 코드를 리터치 했습니다.
24 | - `Reference Data` **<1번>** 참조
25 |
26 |
27 | * `복잡한 파라미터 전달 방식`을 `간소화`하여 스크립트를 쉽게 사용할 수 있도록 **변경**하였습니다.
28 |
29 |
30 | * `파라미터 전달 부분`은 `` 설정 파일로 대체되어 동적 변수를 사용할 수 있게 되었습니다.
31 |
32 | ### ©️ 전자 서명
33 | * Author : 이강일
34 | * Contacts : lki_familiar@naver.com
35 | * Commit : 23. 06. 23
36 | * Version : 2
37 | * License : GPL
38 |
39 | * OS : Centos 7.*
40 | * Language : Bash Shell
41 | * Shebang : #!/bin/bash
42 | * Scripts : 8
43 | * Indent : 4
44 |
45 |
46 | # 📜 Contents
47 | ## 📖 Theory
48 | * [아키텍처](#-architecture)
49 | * [도식도](#-architecture-diagram)
50 |
51 | ## ⚙️ Command Table
52 | * [명령어 표](#%EF%B8%8F-command-table-1)
53 |
54 | ## 🌱 Configuration
55 | * [settings.sh 초기 설정 방법](#%EF%B8%8F-settingsini-설정)
56 | * [사용자 설정](#1-사용자-설정)
57 | * [APM 설정](#2-APM-설정)
58 | * [메일 설정](#3-메일-설정)
59 | * [IP 설정](#4-IP-설정)
60 | * [DB 설정](#5-DB-설정)
61 | * [정렬 알고리즘](#6-정렬-알고리즘-설정)
62 | * [(*개발자용) 스크립트 모듈 설정](#7--개발자용--스크립트-모듈-설정)
63 |
64 | ## 📃 Guide
65 | * [쉘 사용 가이드](#-guide-1)
66 | * [repo 명령어](#1-repo-명령어)
67 | * [rpm 명령어](#2-rpm-명령어)
68 | * [apm 명령어](#3-apm-명령어)
69 | * split 명령어
70 | * merge 명령어
71 | * install 명령어
72 | * check 명령어
73 | * [quota 명령어](#4-quota-명령어)
74 | * 초기 설정
75 | * install 명령어
76 | * set 명령어
77 | * [sendmail 명령어](#5-sendmail-명령어)
78 | * install 명령어
79 | * send 명령어
80 | * [oracle 명령어](#6-oracle-명령어)
81 | * install 명령어
82 | * setdb 명령어
83 | * back 명령어
84 | * sql 명령어
85 | * sort 명령어
86 |
87 | ## 🤗 Standardization
88 | * [표준화](#-standardization-1)
89 | * [Function Renaming](#1-function-renaming-main)
90 | * [Exception & Error Handling](#2-exception--error-handling-main)
91 | * [HA Logging](#3-high-available-main)
92 |
93 | ## 🔖 Reference
94 | * [Reference Link](#-reference-1)
95 | * Bash Style 표준화 지침서
96 |
97 |
98 |
99 | # 🧱 Architecture
100 |
101 | View
102 |
103 | ## · Architecture Diagram
104 |
105 | AA :
106 | ```mermaid
107 | graph TD;
108 | sm_final.sh-->settings.sh-->;
109 | A-->C;
110 | B-->D;
111 | C-->D;
112 | ```
113 |
114 |
115 |
116 |
117 | # 🏷️ Command Table
118 | ## 🏷️ 명령어 테이블
119 |
120 | View
121 |
122 | | Command | Parameters $1 | Parameters $2 | Description |
123 | | :---: | :---: | :---: | :---: |
124 | | `repo` | * | * | 로컬 저장소 10초 내에 구성 |
125 | | `rpm` | * | * | 설치된 패키지 목록 저장 |
126 | | `apm` | install | * | APM 서비스 설치 |
127 | | | split | * | MySQL 소스 파일 두 개로 분할 |
128 | | | merge | * | 두 개로 분할한 MySQL 소스 파일 병합 |
129 | | | check | * | APM 서비스 장애 유무 확인 |
130 | | `quota` | install | * | Quota 서비스 설치 |
131 | | | set | `/dev/sda3` | 파라미터 $2 기반으로 Quota 자동 설정 |
132 | | `mail` | install | * | 설치된 패키지 목록 저장 |
133 | | | send | local | <`settings.ini`> 설정 파일
`root@localhost.localdomain` 계정으로 TO = `lki_familiar@naver.com` 주소로 송부합니다.
134 | | | send | global | <`settings.ini`> 설정 파일
`luikie@luikie.sm.jj.ac.kr` 계정으로 TO = `lki_familiar@naver.com` 주소로 송부합니다 |
135 | | `oracle` | install | * | Oracle 21c **Preinstall** &
**EE 서비스 설치** 및 **DB 생성** |
136 | | | setdb | * | <`settings.ini`> 설정 파일
DB = linuxDB
TABLE = final_record
**DB 명 변경** 및 **테이블 생성**|
137 | | | back | * | **DB 오류 발생** 시 이전 설정으로 **복구** |
138 | | | sql | * | **``** 데이터 레코드를
**final_record** 테이블에 자동 삽입
|
139 | | | sort | * | **``** 데이터 레코드를
조건에 맞게 정렬 후
**``** 파일로 저장 |
140 |
141 |
142 |
143 |
144 |
145 | # ⚙️ Configuration
146 |
147 | ## 🏷️ `` 설정
148 |
149 | View
150 |
151 |
152 |
153 | ### 1. 사용자 설정
154 |
155 | View
156 |
157 | ```css
158 | [USER DATA]
159 | ID = 15
160 | NICK = luikie
161 | NAME = 이강일
162 | ```
163 | | 필드 | 값 | 설명 |
164 | | :---: | :---: | :---: |
165 | |`ID`| 15 |수업번호를 의미합니다.
166 | |`NICK`| luikie |수업별칭을 의미합니다.
167 | |`NAME`| 이강일 |본인의 이름을 의미합니다.
168 |
169 |
170 |
171 |
172 | ### 2. APM 설정
173 |
174 | View
175 |
176 | ```css
177 | [APM DATA]
178 | FILES = xe.tar.gz
179 | DIRECTORY = xe
180 | ```
181 | | 필드 | 값 | 설명 |
182 | | :---: | :---: | :---: |
183 | |`FILES`| xe.tar.gz |웹 소스 파일명
184 | |`DIRECTORY`| xe |압축 해제 후 저장되는 폴더명
185 |
186 |
187 |
188 |
189 | ### 3. 메일 설정
190 |
191 | View
192 |
193 | ```css
194 | [MAIL DATA]
195 | TO = 이메일 주소
196 | ```
197 | | 필드 | 값 | 설명 |
198 | | :---: | :---: | :---: |
199 | |`TO`| 이메일 주소 | 전송할 이메일 주소 입력
200 |
201 |
202 |
203 |
204 | ### 4. IP 설정
205 |
206 | View
207 |
208 | ```css
209 | [IP DATA]
210 | IP = 본인 자리의 아이피 주소
211 | ```
212 | | 필드 | 값 | 설명 |
213 | | :---: | :---: | :---: |
214 | |`IP`| 본인 자리의 아이피 주소 | 시험 자리 아이피 입력
215 |
216 |
217 |
218 |
219 | ### 5. DB 설정
220 |
221 | View
222 |
223 | ```css
224 | [ORACLE DATA]
225 | DB = linuxDB
226 | TABLE = final_record
227 | ```
228 | | 필드 | 값 | 설명 |
229 | | :---: | :---: | :---: |
230 | |`DB`| linuxDB | 변경할 DB 명
231 | |`TABLE`| final_record | 생성 · 삽입할 TABLE 명
232 |
233 |
234 |
235 |
236 | ### 6. 정렬 알고리즘 설정
237 |
238 | View
239 |
240 | ```css
241 | [SORT DATA]
242 | HEAD = 5
243 | TAIL = 5
244 | TYPE = 1
245 | ```
246 | | 필드 | 값 | 설명 | | 조건 |
247 | | :---: | :---: | :---: | :---: |:---: |
248 | |`HEAD`| 5 | 위부터 아래로 5 라인 설정 ||
249 | |`TAIL`| 5 | 아래부터 위로 5 라인 설정 ||
250 | |`TYPE`| 0 | 정렬 알고리즘 유형 ||자신의 위아래 10개 데이터의 수업번호가 한 가지 조건일 때
1~10, 11~20, 21~30, 31~40 해당
251 | || 1 | 정렬 알고리즘 유형 ||수업번호 01∼10번까지는 학년 순으로 만약 같으면 그룹 순
수업번호 11∼20번까지는 이름 순과 만약 같으면 학년 순
252 | || 2 | 정렬 알고리즘 유형 ||수업번호 11∼20번까지는 이름 순과 만약 같으면 학년 순
수업번호 21∼30번까지는 그룹 순과 만약 같으면 학년 순
253 | || 3 | 정렬 알고리즘 유형 ||수업번호 21∼30번까지는 그룹 순과 만약 같으면 학년 순
수업번호 31∼40번까지는 학점 순과 만약 같으면 학년 순
254 | || 4 | 정렬 알고리즘 유형 ||수업번호 31∼40번까지는 학점 순과 만약 같으면 학년 순
수업번호 41∼48번까지는 높은 학년 순과 만약 같으면 그룹 순
255 |
256 | `[예시] : 자신의 위 5, 아래 4 10개의 데이터가 8 ~ 17 범위에 포함될 때`
257 | * HEAD = 3
258 | * TAIL = 7
259 | * TYPE = 1
260 | ### 따라서 `[TYPE 1]` 알고리즘으로 8~10 번(HEAD 3), 11~17 번(TAIL 7) 정렬이 가능함
261 |
262 |
263 |
264 |
265 | ### 7. * **개발자용** * 스크립트 모듈 설정
266 |
267 | View
268 |
269 | ```css
270 | [SCRIPT DATA]
271 | MODULES = settings, repo, apm, quota, mail, oracle, messages
272 | ```
273 | | 필드 | 값 | 설명 |
274 | | :---: | :---: | :---: |
275 | |`MODULES`| settings, repo, apm, quota, mail, oracle, messages| 사용자 정의 스크립트 파일을 `./Resource/Scripts/`
경로에 저장 후 추가하여 자동 연결
276 |
277 | ### * 안정성과 호환성을 위하여, 개발자 설정 부분을 최대한 수정하지 않는 것을 권장합니다.
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 | # 📃 Guide
286 |
287 | ## 🏷️ 명령어 가이드
288 |
289 | View
290 |
291 |
292 | ### 1. repo 명령어
293 |
294 | View
295 |
296 | ```css
297 | [root@locahost sm-shell]# ./sm_final.sh repo
298 | ```
299 | * repo 명령 입력 시 아래와 같은 동작을 수행합니다.
300 | - /etc/yum.repo.d 에 존재하는 온라인 repo 를 모두 삭제하고, loca.repo 를 복사합니다.
301 | - 가장 많은 시간이 소요되는 `createrepo` 명령을 수행할 필요가 없어 `10초` 이내에 레포가 설치됩니다.
302 |
303 |
304 |
305 | ### 2. rpm 명령어
306 |
307 | View
308 |
309 | ```css
310 | [root@localhost sm-shell]# ./sm_final.sh rpm
311 | -rw-r--r-- 1 root root 56227 Jun 19 21:27 15-이강일-rpm-list.log
312 | ```
313 | * 시스템에 존재하는 패키지 목록을 $ID-$NAME-rpm-list.log 로 저장합니다.
314 |
315 |
316 |
317 | ### 3. apm 명령어
318 |
319 | View
320 |
321 | ```css
322 | [root@localhost sm-shell]# ./sm_final.sh apm split
323 | -rw-r--r-- 1 root root 16589296 Jun 19 21:27 mysql-5.6.24.tar.gz.part-0
324 | -rw-r--r-- 1 root root 16589296 Jun 19 21:27 mysql-5.6.24.tar.gz.part-1
325 |
326 | [root@localhost sm-shell]# ./sm_final.sh apm merge
327 | -rw-r--r-- 1 root root 33178592 Jun 19 21:27 mysql-5.6.24.tar.gz
328 | ```
329 | * split 명령어로 mysql-5.6.24.tar.gz 소스 압축파일을 2개로 분할합니다.
330 | * merge 명령어로 mysql-5.6.24.tar.gz.part0-1 분할 파일을 하나로 병합합니다.
331 |
332 |
333 | ```css
334 | [root@localhost sm-shell]# ./sm_final.sh apm install
335 | ... # 설치 및 압축 해제 후
336 | Enter current password for root (enter for none): (엔터)
337 | Change the root password? [Y/n] y
338 | New password: (비밀번호 입력)
339 | Re-enter new password: (비밀번호 재입력)
340 | Remove anonymous users? [Y/n] y
341 | Disallow root login remotely? [Y/n] n
342 | Remove test database and access to it? [Y/n] y
343 | Reload privilege tables now? [Y/n] y
344 |
345 | ```
346 | * apm `install` 명령 사용 시 아래와 같은 동작이 수행됩니다.
347 | - Apache(2.4.6) PHP(5.4.16) Mariadb(5.5.68) 및 의존, 종속성 패키지 자동 설치
348 | - Web 소스 /var/www/html 압축 해제 후 권한 부여
349 | - DB 연결 후 복구
350 |
351 |
352 | ```css
353 | [root@localhost sm-shell]# ./sm_final.sh apm check
354 | ```
355 | * APM 서비스 오류 유무를 확인합니다.
356 | > ℹ️ 서비스 비정상 동작 시에만 오류 메세지 출력
357 |
358 |
359 |
360 |
361 | ### 4. quota 명령어
362 |
363 | View
364 |
365 | ```css
366 | [root@localhost ~]# mkdir /quotahome
367 | [root@localhost ~]# fdisk -l
368 | [root@localhost ~]# fdisk /dev/sda
369 |
370 | Command (m for help): n
371 | Partition type:
372 | p primary (3 primary, 0 extended, 1 free)
373 | e extended
374 | Select (default e): p
375 | Partition number (3-4, default 3): 3
376 | First sector (10001-209715, default 10001): 10001
377 | Last sector, +sectors or +size{K,M,G} (10000-209715, default 209715): +1G
378 | Partition 3 of type Linux and of size 1 GiB is set
379 | Command (m for help): w
380 |
381 | [root@localhost ~]# partprobe -s
382 | [root@localhost ~]# fdisk -l
383 | [root@localhost ~]# mkfs.ext4 /dev/sda3
384 | [root@localhost ~]# mount /dev/sda3 /quotahome
385 | [root@localhost ~]# cd /quotahome
386 | ```
387 | * 위와 같이 초기 파티션 설정을 해줍니다.
388 | * 보통 디스크 이름은 HDD : `sda`, SSD : `nvme0n1p` 입니다.
389 | > ℹ️ `fdisk -l` 명령으로 정확한 파티션을 지정해줘야 합니다.
390 |
391 |
392 |
393 | ```css
394 | [root@localhost quotahome]# /sm-shell/sm_final.sh quota install
395 | [root@localhost quotahome]# ls -al
396 | .
397 | ..
398 | ...
399 | drwxr--r-- 1 root root 33 Jun 19 21:27 csejj
400 | drwxr--r-- 1 root root 33 Jun 19 21:27 samuel
401 | drwxr--r-- 1 root root 33 Jun 19 21:27 luikie
402 | drwxr--r-- 1 root root 0 Jun 19 21:27 lost+found
403 | ```
404 | * 초기 파티션 설정 후 명령어를 입력해 사용자 및 그룹을 자동 구성합니다.
405 | * `ls-al` 명령어 실행 결과가 위와 같다면 성공입니다.
406 | * `lost+found` 디렉토리는 ext4 파일 시스템으로 포맷되었다는 것을 의미합니다.
407 | > ℹ️ `lost+found` 디렉토리가 존재하지 않는 경우 마운트 재확인
408 |
409 |
410 |
411 | ```css
412 | [root@localhost quotahome]# /sm-shell/sm_final.sh quota set /dev/sda3
413 | [quotaoff] off /dev/sda3
414 | [quotaon] on /dev/sda3
415 | [quota] completed
416 |
417 | [root@localhost quotahome]# mount -o remount /dev/sda3
418 | [root@localhost quotahome]# repquota -au
419 | [root@localhost quotahome]# repquota -ag
420 | ```
421 | * `repquota -au` 사용자 quota 확인 명령어
422 | * `repquota -ag` 그룹 quota 확인 명령어
423 |
424 |
425 |
426 |
427 | ### 5. sendmail 명령어
428 |
429 | View
430 |
431 | ```css
432 | [root@localhost ~]# /sm-shell/sm_final.sh mail install
433 | ```
434 | * `mail install` 명령어는 sendmail 및 의존 · 종속 패키지를 설치합니다.
435 |
436 |
437 | ```css
438 | [root@localhost ~]# /sm-shell/sm_final.sh mail send local
439 |
440 | [root@localhost ~]# /sm-shell/sm_final.sh mail send global
441 | ```
442 | * `mail send local` 명령어는 root@localhost.localdomain 계정으로 전송합니다.
443 | * `mail send global` 명령어는 luikie@luikie.sm.jj.ac.kr 계정으로 전송합니다.
444 | * TO 에 설정해둔 주소
445 | * 미리 설정해둔 이메일 주소로 `score_result.txt` 첨부 메일을 송부합니다.
446 | > ℹ️ 메일 첨부 양식
447 | > > View
448 | > > attachment="/sm-shell/score_result.txt"
449 | > > echo "From: $domain"
450 | > > echo "To: lki_familiar@naver.com, $domain"
451 | > > echo "Subject: $subject"
452 | > > echo "Content-Type: multipart/mixed; boundary=XYZ"
453 | > > echo ""
454 | > > echo "--XYZ"
455 | > > echo "Content-Type: text/plain; charset=utf-8"
456 | > > echo ""
457 | > > echo "$body"
458 | > > echo "--XYZ"
459 | > > echo "Content-Type: text/plain"
460 | > > echo "Content-Disposition: attachment; filename=\"score-result.txt\""
461 | > > echo ""
462 | > > cat "$attachment"
463 | > > echo "--XYZ--"
464 | > > EOF
465 |
466 |
467 |
468 |
469 | ### 6. Oracle 명령어
470 |
471 | View
472 |
473 | ---
474 | #### 6-1. oracle install
475 | ___
476 | ```css
477 | [root@localhost home]# /sm-shell/sm_final.sh oracle install
478 | ```
479 | * `oracle install` 명령 사용 시 아래와 같은 동작이 수행됩니다
480 | - Oracle 21c Preinstall, EE 설치
481 | - /etc/init.d/oracledb_ORCLCDB-21c configure 명령으로 초기 DB 구축
482 | - oracle 사용자 dba 그룹 추가 후 비밀번호 wjsansrk 설정
483 | - .bash_profile oracle 홈 디렉토리에 복사
484 | > ℹ️ 설치 및 초기 DB 구성까지 약 10분 소요됩니다.
485 |
486 |
487 |
488 | ___
489 | #### 6-2. oracle setdb (수동 설정)
490 | ___
491 | ```css
492 | [oracle@localhost home]$ cd ~
493 | [oracle@localhost ~]$ cat .bash_profile | grep "ORACLE_SID"
494 | export ORACLE_SID=ORCLCDB
495 | ```
496 | * 명령어 입력 시 export ORACLE_SID=ORCLCDB 가 출력되면 정상입니다.
497 |
498 |
499 | ```css
500 | [oracle@localhost ~]$ source .bash_profile
501 | [oracle@localhost ~]$ ora
502 | SQL> shutdown immediate;
503 | SQL> startup mount;
504 | SQL> exit;
505 | ```
506 | * source .bash_profile 명령어로 설정을 적용해줍니다.
507 |
508 | * ora 명령어로 db 접속해 위 SQL 명령어 3개를 순차적으로 입력합니다.
509 |
510 |
511 | ```css
512 | [oracle@localhost ~]$ nid target=sys dbname=linuxDB
513 | 비밀번호 : wjsansrk
514 | ... (생략)
515 | > [Y/N]: y
516 | ...Success (생략)
517 | ```
518 | * nid 명령어로 ORCLCDB 에서 linuxDB 로 DB 명을 변경합니다.
519 |
520 |
521 | 오류 발생 시 해결 방법
522 |
523 | * ORA-01034 oracle avaliable 오류
524 | - startup mount;
525 | - select name from v$database;
526 |
527 | + ORA-01109 데이터베이스 개방 오류
528 | - alter database open;
529 |
530 | + NID-00106 오라클 오류와 함께 DB 로그인 실패
531 | - DB 로그인 실패 오류임. 비번 확인
532 | - 오라클 startup mount; 가 되어 있지 않아 발생함.
533 |
534 | + NID-00121 데이터 베이스 오픈 오류
535 | - shutdown immediate;
536 |
537 | + NID-00135 활성 스레드 오류
538 | - alter database open;
539 | - shutdown immediate;
540 | - startup mount;
541 |
542 |
543 |
544 |
545 | ```css
546 | [oracle@localhost ~]$ sed -i 's/export ORACLE_SID=ORCLCDB/export ORACLE_SID=linuxDB/g' /home/oracle/.bash_profile
547 | [oracle@localhost ~]$ cat .bash_profile | grep "ORACLE_SID"
548 | export ORACLE_SID=linuxDB
549 | [oracle@localhost ~]$ source .bash_profile
550 | [oracle@localhost ~]$ cp -rf /sm-shell/Resource/Data/initlinuxDB.ora /opt/oracle/dbs
551 | ```
552 | * sed 명령어로 .bash_profile ORACLE_SID 값을 ORCLCDB -> linuxDB 로 변경합니다.
553 | * cat 명령어로 변경이 잘되었는지 확인합니다.
554 | * 변경이 올바르게 되었다면, source 명령어로 변경된 설정을 적용합니다.
555 | * cp -rf 명령을 수행하여 /opt/oracle/dbs 경로에 initlinuxDB.ora 을 복사합니다.
556 |
557 |
558 | ```css
559 | [oracle@localhost ~]$ ora
560 | SQL> shutdown immediate;
561 | SQL> startup mount;
562 | SQL> select name from v$database;
563 | SQL> alter database open resetlogs;
564 | SQL> exit;
565 | ```
566 | * ora 를 입력해 DB 접속 후 아래 SQL 6개 명령을 순차적으로 수행합니다.
567 | * select name from v$database; 명령 입력 시 LINUXDB 명이 출력되면 DB 명 변경 성공입니다.
568 |
569 |
570 |
571 | ___
572 | #### 6-3. oracle back
573 | ___
574 | ```css
575 | [oracle@localhost home]$ /sm-shell/sm_final.sh oracle back
576 | ```
577 | * `oracle setdb` 명령 수행 후 오류 발생 시 초기 상태로 복구해주는 명령어입니다.
578 |
579 |
580 | ___
581 | #### 6-4. oracle sql
582 | ___
583 | ```css
584 | [oracle@localhost home]$ /sm-shell/sm_final.sh oracle sql
585 | [oracle@localhost home]$ ora
586 | SQL> select * from final_record;
587 | ```
588 | * `oracle sql` 명령 사용 시 아래와 같은 동작이 수행됩니다.
589 | - sql 실행하고 final_record 테이블 생성
590 | - sqlldr(sql loader) 를 사용하여 `./Resource/Data/score.txt` 데이터 삽입
591 | * 사용자 명 : sys as sysdba
592 | * 비밀번호 : wjsansrk
593 |
594 |
595 | ___
596 | #### 6-5. oracle sort
597 | ___
598 | ```css
599 | [oracle@localhost home]$ su
600 | [root@localhost ~]# /sm-shell/sm_final.sh oracle sort
601 | ```
602 | * 미리 설정해둔 조건으로 `./Resource/Data/score.txt` 데이터 정렬 후 `./score_result.txt` 파일로 저장합니다.
603 |
604 |
605 | ___
606 | #### 6-6. oracle sort
607 | ___
608 | ```css
609 | [root@localhost ~]# ls -al /sm-shell | grep score*
610 | [root@localhost ~]# /sm-shell/sm_final.sh mail send
611 | ```
612 | * `ls -al` 명령어로 score_result.txt 파일 존재 유무 확인
613 | * `mail send` 명령어로 미리 설정한 이메일 주소로 첨부 메일 송부
614 |
615 | > ℹ️ `'./Resource/Data/settings.ini'`
> TO 필드에 설정된 이메일 주소로 전송됩니다.
616 |
617 |
618 |
619 |
620 |
621 |
622 | # 🤗 Standardization
623 |
624 | ## 📰 코드 표준화
625 |
626 | View
627 |
628 |
629 | ## 1. Function Renaming (`main`)
630 |
631 | View
632 |
633 | ```bash
634 | # Global _Function > __Function
635 | __Global_Function() {
636 | ...
637 | }
638 |
639 | # Local _Function > __Function
640 | _Local_Function() {
641 | ...
642 | }
643 |
644 | ```
645 | * 전역 함수는 `Underbar(_) 2개`로 구분합니다.
646 | * 지역 함수는 `Underbar(_) 1개`로 구분합니다.
647 |
648 |
649 | ---
650 |
651 | ## 2. Exception & Error Handling (`main`)
652 |
653 | View
654 |
655 | ```bash
656 | # Exception $ Error Send
657 | __Function() {
658 | ... # 정상 출력
659 | else # 예외 및 오류 발생
660 | # __Handler:함수호출 $Function:오류함수 $date:발생시간 $Error_Out:오류전달"
661 | __Handler "$Function" "$date" "$Error_Out"
662 | }
663 |
664 | # Exception & Error Handler
665 | __Handler() {
666 | # 전달 받은 인자 출력
667 | echo -e "$white""$b_red[$2] $1 $3 Error$cls"
668 | }
669 |
670 | ```
671 | * 오류 발생 값을 `파라미터`로 `명확하게 전달`하는 구문을 사용합니다.
672 | * 예외 및 오류 처리를 위한 `핸들링 함수`를 추가합니다.
673 |
674 |
675 | ---
676 |
677 | ## 3. High Available (`main`)
678 |
679 | View
680 |
681 | ```bash
682 | # Exception & Error Handler
683 | __Handler() {
684 | # 전달 받은 인자 Error_$date.log Append Logging
685 | echo "[$2] $1 $3 Error" >> $log_path/Error_"$(date +"%m%d")".log
686 | echo -e "$white""$b_red[$2] $1 $3 Error$cls"
687 | } 2>> $log_path/Error_"$(date +"%m%d")".log
688 |
689 | ```
690 | * `2>> ./path/file` Redirection 명령줄로 `성공 | 오류` 표준 입출력을 지정합니다.
691 | * 코드를 효율적으로 관리하기 위하여 각 함수 별로 표준 입출력 및 동작 로그를 저장합니다.
692 |
693 |
694 |
695 |
696 |
697 |
698 | # 🔖 Reference
699 |
700 | View
701 |
702 | ## 1. Reference Link
703 |
704 | * [[Bash Style 표준화 지침] : 원문본(English)](https://github.com/icy/bash-coding-style)
705 | * [[Bash Style 표준화 지침] : 번역본(Korean)](https://sepiros.tistory.com/28)
706 |
707 |
708 |
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/.bash_profile:
--------------------------------------------------------------------------------
1 | # .bash_profile
2 |
3 | # Get the aliases and functions
4 | if [ -f ~/.bashrc ]; then
5 | . ~/.bashrc
6 | fi
7 |
8 | # User specific environment and startup programs
9 |
10 | PATH=$PATH:$HOME/.local/bin:$HOME/bin
11 |
12 | export PATH
13 | export TMP=/tmp;
14 | export ORACLE_BASE=/opt/oracle
15 | export ORACLE_HOME=/opt/oracle/product/21c/dbhome_1
16 | export ORACLE_SID=ORCLCDB
17 | export PATH=$PATH:$ORACLE_HOME/bin
18 | export NLS_LANG=KOREAN_KOREA.AL32UTF8
19 | alias ora='sqlplus / as sysdba'
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/data.txt:
--------------------------------------------------------------------------------
1 | LM07 백민규 2 lgt D-
2 | LM08 김주연 4 kt A+
3 | LM09 조윤호 2 lgt C+
4 | LM10 배호빈 3 skt B-
5 | LM11 이강일 1 skt B+
6 | LM12 송연규 3 lgt C0
7 | LM13 박지혁 1 kt C-
8 | LM14 장보란 4 lgt A+
9 | LM15 임진성 3 skt B+
10 | LM16 유현빈 4 lgt D-
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/httpd.conf:
--------------------------------------------------------------------------------
1 | #
2 | # This is the main Apache HTTP server configuration file. It contains the
3 | # configuration directives that give the server its instructions.
4 | # See for detailed information.
5 | # In particular, see
6 | #
7 | # for a discussion of each configuration directive.
8 | #
9 | # Do NOT simply read the instructions in here without understanding
10 | # what they do. They're here only as hints or reminders. If you are unsure
11 | # consult the online docs. You have been warned.
12 | #
13 | # Configuration and logfile names: If the filenames you specify for many
14 | # of the server's control files begin with "/" (or "drive:/" for Win32), the
15 | # server will use that explicit path. If the filenames do *not* begin
16 | # with "/", the value of ServerRoot is prepended -- so 'log/access_log'
17 | # with ServerRoot set to '/www' will be interpreted by the
18 | # server as '/www/log/access_log', where as '/log/access_log' will be
19 | # interpreted as '/log/access_log'.
20 |
21 | #
22 | # ServerRoot: The top of the directory tree under which the server's
23 | # configuration, error, and log files are kept.
24 | #
25 | # Do not add a slash at the end of the directory path. If you point
26 | # ServerRoot at a non-local disk, be sure to specify a local disk on the
27 | # Mutex directive, if file-based mutexes are used. If you wish to share the
28 | # same ServerRoot for multiple httpd daemons, you will need to change at
29 | # least PidFile.
30 | #
31 | ServerRoot "/etc/httpd"
32 |
33 | #
34 | # Listen: Allows you to bind Apache to specific IP addresses and/or
35 | # ports, instead of the default. See also the
36 | # directive.
37 | #
38 | # Change this to Listen on specific IP addresses as shown below to
39 | # prevent Apache from glomming onto all bound IP addresses.
40 | #
41 | #Listen 12.34.56.78:80
42 | Listen 80
43 |
44 | #
45 | # Dynamic Shared Object (DSO) Support
46 | #
47 | # To be able to use the functionality of a module which was built as a DSO you
48 | # have to place corresponding `LoadModule' lines at this location so the
49 | # directives contained in it are actually available _before_ they are used.
50 | # Statically compiled modules (those listed by `httpd -l') do not need
51 | # to be loaded here.
52 | #
53 | # Example:
54 | # LoadModule foo_module modules/mod_foo.so
55 | #
56 | Include conf.modules.d/*.conf
57 |
58 | #
59 | # If you wish httpd to run as a different user or group, you must run
60 | # httpd as root initially and it will switch.
61 | #
62 | # User/Group: The name (or #number) of the user/group to run httpd as.
63 | # It is usually good practice to create a dedicated user and group for
64 | # running httpd, as with most system services.
65 | #
66 | User apache
67 | Group apache
68 |
69 | # 'Main' server configuration
70 | #
71 | # The directives in this section set up the values used by the 'main'
72 | # server, which responds to any requests that aren't handled by a
73 | # definition. These values also provide defaults for
74 | # any containers you may define later in the file.
75 | #
76 | # All of these directives may appear inside containers,
77 | # in which case these default settings will be overridden for the
78 | # virtual host being defined.
79 | #
80 |
81 | #
82 | # ServerAdmin: Your address, where problems with the server should be
83 | # e-mailed. This address appears on some server-generated pages, such
84 | # as error documents. e.g. admin@your-domain.com
85 | #
86 | ServerAdmin root@localhost
87 |
88 | #
89 | # ServerName gives the name and port that the server uses to identify itself.
90 | # This can often be determined automatically, but we recommend you specify
91 | # it explicitly to prevent problems during startup.
92 | #
93 | # If your host doesn't have a registered DNS name, enter its IP address here.
94 | #
95 | #ServerName www.example.com:80
96 |
97 | #
98 | # Deny access to the entirety of your server's filesystem. You must
99 | # explicitly permit access to web content directories in other
100 | # blocks below.
101 | #
102 |
103 | AllowOverride none
104 | Require all denied
105 |
106 |
107 | #
108 | # Note that from this point forward you must specifically allow
109 | # particular features to be enabled - so if something's not working as
110 | # you might expect, make sure that you have specifically enabled it
111 | # below.
112 | #
113 |
114 | #
115 | # DocumentRoot: The directory out of which you will serve your
116 | # documents. By default, all requests are taken from this directory, but
117 | # symbolic links and aliases may be used to point to other locations.
118 | #
119 | DocumentRoot "/var/www/html/xe"
120 |
121 | #
122 | # Relax access to content within /var/www.
123 | #
124 |
125 | AllowOverride None
126 | # Allow open access:
127 | Require all granted
128 |
129 |
130 | # Further relax access to the default document root:
131 |
132 | #
133 | # Possible values for the Options directive are "None", "All",
134 | # or any combination of:
135 | # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
136 | #
137 | # Note that "MultiViews" must be named *explicitly* --- "Options All"
138 | # doesn't give it to you.
139 | #
140 | # The Options directive is both complicated and important. Please see
141 | # http://httpd.apache.org/docs/2.4/mod/core.html#options
142 | # for more information.
143 | #
144 | Options Indexes FollowSymLinks
145 |
146 | #
147 | # AllowOverride controls what directives may be placed in .htaccess files.
148 | # It can be "All", "None", or any combination of the keywords:
149 | # Options FileInfo AuthConfig Limit
150 | #
151 | AllowOverride None
152 |
153 | #
154 | # Controls who can get stuff from this server.
155 | #
156 | Require all granted
157 |
158 |
159 | #
160 | # DirectoryIndex: sets the file that Apache will serve if a directory
161 | # is requested.
162 | #
163 |
164 | DirectoryIndex index.html
165 |
166 |
167 | #
168 | # The following lines prevent .htaccess and .htpasswd files from being
169 | # viewed by Web clients.
170 | #
171 |
172 | Require all denied
173 |
174 |
175 | #
176 | # ErrorLog: The location of the error log file.
177 | # If you do not specify an ErrorLog directive within a
178 | # container, error messages relating to that virtual host will be
179 | # logged here. If you *do* define an error logfile for a
180 | # container, that host's errors will be logged there and not here.
181 | #
182 | ErrorLog "logs/error_log"
183 |
184 | #
185 | # LogLevel: Control the number of messages logged to the error_log.
186 | # Possible values include: debug, info, notice, warn, error, crit,
187 | # alert, emerg.
188 | #
189 | LogLevel warn
190 |
191 |
192 | #
193 | # The following directives define some format nicknames for use with
194 | # a CustomLog directive (see below).
195 | #
196 | LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
197 | LogFormat "%h %l %u %t \"%r\" %>s %b" common
198 |
199 |
200 | # You need to enable mod_logio.c to use %I and %O
201 | LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
202 |
203 |
204 | #
205 | # The location and format of the access logfile (Common Logfile Format).
206 | # If you do not define any access logfiles within a
207 | # container, they will be logged here. Contrariwise, if you *do*
208 | # define per- access logfiles, transactions will be
209 | # logged therein and *not* in this file.
210 | #
211 | #CustomLog "logs/access_log" common
212 |
213 | #
214 | # If you prefer a logfile with access, agent, and referer information
215 | # (Combined Logfile Format) you can use the following directive.
216 | #
217 | CustomLog "logs/access_log" combined
218 |
219 |
220 |
221 | #
222 | # Redirect: Allows you to tell clients about documents that used to
223 | # exist in your server's namespace, but do not anymore. The client
224 | # will make a new request for the document at its new location.
225 | # Example:
226 | # Redirect permanent /foo http://www.example.com/bar
227 |
228 | #
229 | # Alias: Maps web paths into filesystem paths and is used to
230 | # access content that does not live under the DocumentRoot.
231 | # Example:
232 | # Alias /webpath /full/filesystem/path
233 | #
234 | # If you include a trailing / on /webpath then the server will
235 | # require it to be present in the URL. You will also likely
236 | # need to provide a section to allow access to
237 | # the filesystem path.
238 |
239 | #
240 | # ScriptAlias: This controls which directories contain server scripts.
241 | # ScriptAliases are essentially the same as Aliases, except that
242 | # documents in the target directory are treated as applications and
243 | # run by the server when requested rather than as documents sent to the
244 | # client. The same rules about trailing "/" apply to ScriptAlias
245 | # directives as to Alias.
246 | #
247 | ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
248 |
249 |
250 |
251 | #
252 | # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
253 | # CGI directory exists, if you have that configured.
254 | #
255 |
256 | AllowOverride None
257 | Options None
258 | Require all granted
259 |
260 |
261 |
262 | #
263 | # TypesConfig points to the file containing the list of mappings from
264 | # filename extension to MIME-type.
265 | #
266 | TypesConfig /etc/mime.types
267 |
268 | #
269 | # AddType allows you to add to or override the MIME configuration
270 | # file specified in TypesConfig for specific file types.
271 | #
272 | #AddType application/x-gzip .tgz
273 | #
274 | # AddEncoding allows you to have certain browsers uncompress
275 | # information on the fly. Note: Not all browsers support this.
276 | #
277 | #AddEncoding x-compress .Z
278 | #AddEncoding x-gzip .gz .tgz
279 | #
280 | # If the AddEncoding directives above are commented-out, then you
281 | # probably should define those extensions to indicate media types:
282 | #
283 | AddType application/x-compress .Z
284 | AddType application/x-gzip .gz .tgz
285 |
286 | #
287 | # AddHandler allows you to map certain file extensions to "handlers":
288 | # actions unrelated to filetype. These can be either built into the server
289 | # or added with the Action directive (see below)
290 | #
291 | # To use CGI scripts outside of ScriptAliased directories:
292 | # (You will also need to add "ExecCGI" to the "Options" directive.)
293 | #
294 | #AddHandler cgi-script .cgi
295 |
296 | # For type maps (negotiated resources):
297 | #AddHandler type-map var
298 |
299 | #
300 | # Filters allow you to process content before it is sent to the client.
301 | #
302 | # To parse .shtml files for server-side includes (SSI):
303 | # (You will also need to add "Includes" to the "Options" directive.)
304 | #
305 | AddType text/html .shtml
306 | AddOutputFilter INCLUDES .shtml
307 |
308 |
309 | #
310 | # Specify a default charset for all content served; this enables
311 | # interpretation of all content as UTF-8 by default. To use the
312 | # default browser choice (ISO-8859-1), or to allow the META tags
313 | # in HTML content to override this choice, comment out this
314 | # directive:
315 | #
316 | AddDefaultCharset UTF-8
317 |
318 |
319 | #
320 | # The mod_mime_magic module allows the server to use various hints from the
321 | # contents of the file itself to determine its type. The MIMEMagicFile
322 | # directive tells the module where the hint definitions are located.
323 | #
324 | MIMEMagicFile conf/magic
325 |
326 |
327 | #
328 | # Customizable error responses come in three flavors:
329 | # 1) plain text 2) local redirects 3) external redirects
330 | #
331 | # Some examples:
332 | #ErrorDocument 500 "The server made a boo boo."
333 | #ErrorDocument 404 /missing.html
334 | #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
335 | #ErrorDocument 402 http://www.example.com/subscription_info.html
336 | #
337 |
338 | #
339 | # EnableMMAP and EnableSendfile: On systems that support it,
340 | # memory-mapping or the sendfile syscall may be used to deliver
341 | # files. This usually improves server performance, but must
342 | # be turned off when serving from networked-mounted
343 | # filesystems or if support for these functions is otherwise
344 | # broken on your system.
345 | # Defaults if commented: EnableMMAP On, EnableSendfile Off
346 | #
347 | #EnableMMAP off
348 | EnableSendfile on
349 |
350 | # Supplemental configuration
351 | #
352 | # Load config files in the "/etc/httpd/conf.d" directory, if any.
353 | IncludeOptional conf.d/*.conf
354 |
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/ifcfg-enp4s0:
--------------------------------------------------------------------------------
1 | TYPE=Ethernet
2 | PROXY_METHOD=none
3 | BROWSER_ONLY=no
4 | BOOTPROTO=none
5 | DEFROUTE=yes
6 | IPV4_FAILURE_FATAL=no
7 | IPV6INIT=yes
8 | IPV6_AUTOCONF=yes
9 | IPV6_DEFROUTE=yes
10 | IPV6_FAILURE_FATAL=no
11 | IPV6_ADDR_GEN_MODE=stable-privacy
12 | NAME=enp4s0
13 | UUID=3cb8f0fd-2d09-484f-a247-cb96171e535d
14 | DEVICE=enp4s0
15 | ONBOOT=no
16 | IPADDR=202.31.247.146
17 | PREFIX=24
18 | GATEWAY=202.31.247.254
19 | DNS1=202.31.224.3
20 | DNS2=202.31.240.2
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/initORCLCDB.ora:
--------------------------------------------------------------------------------
1 | ORCLCDB.__data_transfer_cache_size=0
2 | ORCLCDB.__db_cache_size=1811939328
3 | ORCLCDB.__inmemory_ext_roarea=0
4 | ORCLCDB.__inmemory_ext_rwarea=0
5 | ORCLCDB.__java_pool_size=0
6 | ORCLCDB.__large_pool_size=50331648
7 | ORCLCDB.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
8 | ORCLCDB.__pga_aggregate_target=805306368
9 | ORCLCDB.__sga_target=2399141888
10 | ORCLCDB.__shared_io_pool_size=0
11 | ORCLCDB.__shared_pool_size=520093696
12 | ORCLCDB.__streams_pool_size=0
13 | ORCLCDB.__unified_pga_pool_size=0
14 | *.audit_file_dest='/opt/oracle/admin/ORCLCDB/adump'
15 | *.audit_trail='db'
16 | *.compatible='21.0.0'
17 | *.control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl','/opt/oracle/oradata/ORCLCDB/control02.ctl'
18 | *.db_block_size=8192
19 | *.db_name='ORCLCDB'
20 | *.diagnostic_dest='/opt/oracle'
21 | *.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLCDBXDB)'
22 | *.enable_pluggable_database=true
23 | *.local_listener='LISTENER_ORCLCDB'
24 | *.nls_language='KOREAN'
25 | *.nls_territory='KOREA'
26 | *.open_cursors=300
27 | *.pga_aggregate_target=763m
28 | *.processes=480
29 | *.remote_login_passwordfile='EXCLUSIVE'
30 | *.sga_target=2288m
31 | *.undo_tablespace='UNDOTBS1'
32 |
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/initlinuxDB.ora:
--------------------------------------------------------------------------------
1 | linuxDB.__data_transfer_cache_size=0
2 | linuxDB.__db_cache_size=1694498816
3 | linuxDB.__inmemory_ext_roarea=0
4 | linuxDB.__inmemory_ext_rwarea=0
5 | linuxDB.__java_pool_size=0
6 | linuxDB.__large_pool_size=50331648
7 | linuxDB.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
8 | linuxDB.__pga_aggregate_target=805306368
9 | linuxDB.__sga_target=2399141888
10 | linuxDB.__shared_io_pool_size=117440512
11 | linuxDB.__shared_pool_size=520093696
12 | linuxDB.__streams_pool_size=0
13 | linuxDB.__unified_pga_pool_size=0
14 | *.audit_file_dest='/opt/oracle/admin/ORCLCDB/adump'
15 | *.audit_trail='db'
16 | *.compatible='21.0.0'
17 | *.control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl','/opt/oracle/oradata/ORCLCDB/control02.ctl'
18 | *.db_block_size=8192
19 | *.db_name='linuxDB'
20 | *.diagnostic_dest='/opt/oracle'
21 | *.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLCDBXDB)'
22 | *.enable_pluggable_database=true
23 | *.local_listener='LISTENER_linuxDB'
24 | *.nls_language='KOREAN'
25 | *.nls_territory='KOREA'
26 | *.open_cursors=300
27 | *.pga_aggregate_target=763m
28 | *.processes=480
29 | *.remote_login_passwordfile='EXCLUSIVE'
30 | *.sga_target=2288m
31 | *.undo_tablespace='UNDOTBS1'
32 |
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/listener.ora:
--------------------------------------------------------------------------------
1 | LISTENER =
2 | (DESCRIPTION_LIST =
3 | (DESCRIPTION =
4 | (ADDRESS = (PROTOCOL = TCP)(HOST = linuxDB.db)(PORT = 1521))
5 | (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
6 | )
7 | )
8 |
9 | LISTENER_INTERNAL =
10 | (DESCRIPTION_LIST =
11 | (DESCRIPTION =
12 | (ADDRESS = (PROTOCOL = TCP)(HOST = linuxDB.db)(PORT = 1521))
13 | (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
14 | )
15 | )
16 |
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/local.repo:
--------------------------------------------------------------------------------
1 | [local-repo]
2 | name=local repo
3 | baseurl=file:///sm-shell/Resource
4 | enabled=1
5 | gpgcheck=0
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/mysql-5.6.24.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Memori-al/bash-scripts/f872f1b295bdc08f6c0ff44cea311894df95ae4f/sm-shell/Resource/Data/mysql-5.6.24.tar.gz
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/oratab:
--------------------------------------------------------------------------------
1 | #
2 |
3 |
4 |
5 | # This file is used by ORACLE utilities. It is created by root.sh
6 | # and updated by either Database Configuration Assistant while creating
7 | # a database or ASM Configuration Assistant while creating ASM instance.
8 |
9 | # A colon, ':', is used as the field terminator. A new line terminates
10 | # the entry. Lines beginning with a pound sign, '#', are comments.
11 | #
12 | # Entries are of the form:
13 | # $ORACLE_SID:$ORACLE_HOME::
14 | #
15 | # The first and second fields are the system identifier and home
16 | # directory of the database respectively. The third field indicates
17 | # to the dbstart utility that the database should , "Y", or should not,
18 | # "N", be brought up at system boot time.
19 | #
20 | # Multiple entries with the same $ORACLE_SID are not allowed.
21 | #
22 | #
23 | linuxDB:/opt/oracle/product/21c/dbhome_1:N
24 |
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/repodata.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Memori-al/bash-scripts/f872f1b295bdc08f6c0ff44cea311894df95ae4f/sm-shell/Resource/Data/repodata.tar.gz
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/settings.ini:
--------------------------------------------------------------------------------
1 | #### 서버관리 자동화 SHELL SCRIPTS SETTING FILE ####
2 | #### AUTHOR : LEE KANG IL / SM15-LUIKIE ####
3 |
4 | # ID 수업번호, NICK 별명, NAME 이름
5 | [USER DATA]
6 | ID = 15
7 | NICK = luikie
8 | NAME = 이강일
9 |
10 | # './Resource/Data/' FILES 경로에 저장되어 있는 WEB 소스 파일명
11 | # DIRECTORY 압축 풀었을 때 생기는 디렉토리명
12 | [APM DATA]
13 | FILES = xe.tar.gz
14 | DIRECTORY = xe
15 |
16 | # 보낼 메일 주소 입력 테스트 할때는 자신의 이메일 주소
17 | # 실제 시험 시간에는 samuel@jj.ac.kr
18 | [MAIL DATA]
19 | TO = lki_familiar@naver.com
20 | TO_ME = lki_familiar@naver.com
21 |
22 | # 아이피 주소 입력
23 | [IP DATA]
24 | IP = 202.31.247.146
25 |
26 | # 오라클 정보 입력
27 | [ORACLE DATA]
28 | DB = linuxDB
29 | TABLE = final_record
30 |
31 | # 정렬 알고리즘 정보 입력
32 | # 1 ~ 10 정렬 sort -k3,3n -k4,4
33 | # 11 ~ 20 정렬 sort -k2,2 -k3,3n
34 | # 21 ~ 30 정렬 sort -k4,4 -k3,3n
35 | # TYPE 1 = 1 ~ 20 까지 조건에 맞게 정렬
36 | # TYPE 2 = 11 ~ 30 까지 조건에 맞게 정렬
37 | # TYPE 3 = 21 ~ 40 까지 조건에 맞게 정렬
38 | # TYPE 4 = 31 ~ 48 까지 조건에 맞게 정렬
39 | # HEAD, TAIL 설정 방법
40 | # 자신의 위 5, 아래 4 가 8 ~ 17 범위와 같을 때
41 | # HEAD 는 3, TAIL 7 임
42 | # HEAD 위부터 아래로 8~10까지 조건 1에 해당함, TAIL 아래부터 위로 11부터 17까지 TYPE 2에 해당함.
43 | [SORT DATA]
44 | HEAD = 4
45 | TAIL = 6
46 | TYPE = 1
47 |
48 | # Scripts 를 추가할 사람만 수정하세요.
49 | # MODULES 설정에 스크립트 명 입력 시 모든 스크립트에 유기적으로 연결됩니다.
50 | # *** 대소문자 정확히 구분
51 | [SCRIPT DATA]
52 | MODULES = settings, repo, apm, quota, mail, oracle, messages
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/tnsnames.ora:
--------------------------------------------------------------------------------
1 | HOME =
2 | (DESCRIPTION =
3 | (ADDRESS = (PROTOCOL = TCP)(HOST = linuxDB.db)(PORT = 1521))
4 | (CONNECT_DATA =
5 | (SERVER = DEDICATED)
6 | (SERVICE_NAME = linuxDB.db)
7 | )
8 | )
9 |
10 | LISTENER_linuxDB =
11 | (ADDRESS = (PROTOCOL = TCP)(HOST = linuxDB.db)(PORT = 1521))
12 |
--------------------------------------------------------------------------------
/sm-shell/Resource/Data/xe.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Memori-al/bash-scripts/f872f1b295bdc08f6c0ff44cea311894df95ae4f/sm-shell/Resource/Data/xe.tar.gz
--------------------------------------------------------------------------------
/sm-shell/Resource/Scripts/apm.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | _Split() {
4 | # Split Mysql.tar.gz
5 | split -n 2 -d -a 1 $data_path/mysql-5.6.24.tar.gz $data_path/mysql-5.6.24.tar.gz.part-
6 | rm -rf $data_path/mysql-5.6.24.tar.gz
7 | pwd
8 | ls -al $data_path/ | grep part*
9 | }
10 |
11 | _Merge() {
12 | # merge Mysql.tar.gz
13 | cat $data_path/*part* > $data_path/mysql-5.6.24.tar.gz
14 | rm -rf $data_path/*part*
15 | pwd
16 | ls -al $data_path/ | grep mysql
17 | }
18 |
19 | _Ins() {
20 | # Install APM
21 | packages=("httpd" "mariadb-server" "php" "mariadb")
22 | for package in "${packages[@]}";
23 | do
24 | if [[ ! $(rpm -qa | grep $package) ]]; then
25 | if [[ $package == "php" ]]; then
26 | yum install -y $package* --skip-broken
27 | else
28 | yum install -y $package
29 | fi
30 | fi
31 | done
32 |
33 | # Update $DIRECTORY Src
34 | if [[ -f "/var/www/html/$FILES" ]]; then
35 | if [[ ! $(diff -q $data_path/$FILES /var/www/html/$FILES) ]]; then
36 | cp -rf $data_path/$FILES /var/www/html
37 | tar -xvf /var/www/html/$FILES -C /var/www/html
38 | chmod -R 777 /var/www/html/$DIRECTORY
39 | fi
40 | else
41 | cp -rf $data_path/$FILES /var/www/html
42 | tar -xvf /var/www/html/$FILES -C /var/www/html
43 | chmod -R 777 /var/www/html/$DIRECTORY
44 | fi
45 |
46 | # Httpd Settings
47 | if [[ ! $(diff -q $data_path/httpd.conf /etc/httpd/conf/httpd.conf) ]]; then
48 | cp -rf $data_path/httpd.conf /etc/httpd/conf
49 | ls -al /etc/httpd/conf | grep httpd.conf
50 | fi
51 |
52 | # DB Restore
53 | if [[ $(rpm -qa | grep mariadb) ]]; then
54 | systemctl restart mariadb
55 | mysql_secure_installation
56 | mysql -u root -p < $data_path/backup.dmp
57 | systemctl restart mariadb
58 | systemctl restart httpd
59 | setenforce 0
60 | fi
61 | }
62 |
63 | # 오류 처리 함수
64 | _Check() {
65 | # Function $1 $2 $3 parameters
66 | if [[ $(systemctl is-active httpd) != "active" ]]; then
67 | _Handler httpd "$(date '+%H:%M:%S')" service
68 | systemctl start httpd
69 | fi
70 | if [[ $(systemctl is-active mariadb) != "active" ]]; then
71 | _Handler mariadb "$(date '+%H:%M:%S')" service
72 | systemctl start mariadb
73 | fi
74 | if [[ ! $(rpm -qa | grep php) ]]; then
75 | _Handler php "$(date '+%H:%M:%S')" install
76 | fi
77 | }
78 |
79 | if [[ "$1" == "install" ]]; then
80 | _Ins
81 | elif [[ "$1" == "split" ]]; then
82 | _Split
83 | elif [[ "$1" == "merge" ]]; then
84 | _Merge
85 | elif [[ "$1" == "check" ]]; then
86 | _Check
87 | fi
--------------------------------------------------------------------------------
/sm-shell/Resource/Scripts/mail.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # DB Sorting 후 Score-result.txt 첨부 메일 송부
4 | _Send_root() {
5 | subject="$ID-$NAME-리눅스-6번-문제"
6 | body=$(cat <<-EOT
7 | $NAME 메일 송부 드립니다.
8 | 한 학기 동안 감사했습니다!
9 | (별첨) score-result.txt
10 | EOT
11 | )
12 | attachment="/sm-shell/score_result.txt"
13 |
14 | echo "From: root@localhost.localdomain"
15 | echo "To: $TO, root@localhost.localdomain"
16 | echo "Subject: $subject"
17 | echo "Content-Type: multipart/mixed; boundary=XYZ"
18 | echo ""
19 | echo "--XYZ"
20 | echo "Content-Type: text/plain; charset=utf-8"
21 | echo ""
22 | echo "$body"
23 | echo "--XYZ"
24 | echo "Content-Type: text/plain"
25 | echo "Content-Disposition: attachment; filename=\"score-result.txt\""
26 | echo ""
27 | cat "$attachment"
28 | echo "--XYZ--"
29 | }
30 |
31 | _Send_nofile() {
32 | subject="$ID-$NAME-리눅스-6번-문제"
33 | body=$(cat <<-EOT
34 | $NAME 메일 송부 드립니다.
35 | 한 학기 동안 감사했습니다!
36 | EOT
37 | )
38 |
39 | echo "From: root@localhost.localdomain"
40 | echo "To: $TO"
41 | echo "Subject: $subject"
42 | echo "Content-Type: multipart/mixed; boundary=XYZ"
43 | echo ""
44 | echo "--XYZ"
45 | echo "Content-Type: text/plain; charset=utf-8"
46 | echo ""
47 | echo "$body"
48 | echo "--XYZ"
49 | echo "Content-Type: text/plain"
50 | echo ""
51 | cat "$attachment"
52 | echo "--XYZ--"
53 | }
54 |
55 | _Minstall() {
56 | if [[ ! $(rpm -qa | grep sendmail) ]]; then
57 | yum install -y sendmail*
58 | fi
59 | }
60 |
61 | # 전달된 파라미터 필터링
62 | if [[ "$1" == "send" ]]; then
63 | if [[ "$2" == "local" ]]; then
64 | if [[ $(systemctl is-active sendmail) ]]; then
65 | _Send_root | /usr/sbin/sendmail -t
66 | echo
67 | echo -e "$white$b_green"" Complete $cls Mail transfer to "$line"$TO$cls"
68 | echo
69 | else
70 | _Handler sendmail "$(date '+%H:%M:%S')" service
71 | fi
72 | elif [[ "$2" == "nofile" ]]; then
73 | if [[ $(systemctl is-active sendmail) ]]; then
74 | _Send_nofile | /usr/sbin/sendmail -t
75 | echo
76 | echo -e "$white$b_green"" Complete $cls Mail transfer to "$line"$TO$cls"
77 | echo
78 | else
79 | _Handler sendmail "$(date '+%H:%M:%S')" service
80 | fi
81 | fi
82 | elif [[ "$1" == "install" ]]; then
83 | _Minstall
84 | else
85 | source $shell_path/messages.sh send
86 | fi
--------------------------------------------------------------------------------
/sm-shell/Resource/Scripts/messages.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | title="$italic$black$b_yellow Usage $cls"
3 | usage="$white$b_blue command $b_gray$blue$bold"" $1 $cls"
4 |
5 | echo # 공통 개행 처리 구문
6 | if [[ "$1" == "oracle" ]]; then
7 | echo -e "$usage {install|setdb|sorting}"
8 | echo -e $blue$bold"install$cls : oracle preinstall & 21c ee install"
9 | echo -e $blue$bold"setdb$cls : db name change"
10 | echo -e $blue$bold"back$cls : db reverting to before setting"
11 | echo -e $blue$bold"sql$cls : table record insertion"
12 | echo -e $blue$bold"sort$cls : db data sorting"
13 | elif [[ "$1" == "apm" ]]; then
14 | echo -e "$usage {install|split|merge|check}"
15 | echo -e $blue$bold"install$cls : Apache, Php, Mysql Install"
16 | echo -e $blue$bold"split$cls : Mysql.tar.gz split part 2"
17 | echo -e $blue$bold"merge$cls : Mysql.part1-2.tar.gz Merge"
18 | echo -e $blue$bold"check$cls : APM Service Check"
19 | elif [[ "$1" == "mail" ]]; then
20 | echo -e "$usage {install|send}"
21 | echo -e $blue$bold"install$cls : sendmail install & composition"
22 | echo -e $blue$bold"send$cls : Send to score_result.txt file"
23 | echo -e $blue$bold"send local$cls : Send to score_result.txt file (root@localhost.localdomain)"
24 | echo -e $blue$bold"send global$cls : Send to score_result.txt file ($TO)"
25 | elif [[ "$1" == "help" ]]; then
26 | echo -e "$usage {rpm|repo|apm|oracle|quota|mail}"
27 | echo -e $blue$bold"rpm$cls : rpm -qa list output"
28 | echo -e $blue$bold"repo$cls : local repository composition"
29 | echo -e $blue$bold"apm$cls : Apache, Php, Mysql Install"
30 | echo -e $blue$bold"oracle$cls : oracle install"
31 | echo -e $blue$bold"quota$cls : quota install & composition"
32 | echo -e $blue$bold"mail$cls : Install & Send mail"
33 | elif [[ "$1" == "quota" ]]; then
34 | echo -e "$usage {install|set}"
35 | echo -e $blue$bold"install$cls : quota install"
36 | echo -e $blue$bold"set$cls : quota options setting"
37 | else
38 | echo -e "$title : $shell_path/$(basename $0) $tear'$1'$cls is available command."
39 | echo
40 | echo -e "$usage {rpm|repo|apm|oracle|quota|mail}"
41 | echo -e $blue$bold"rpm$cls : rpm -qa list output"
42 | echo -e $blue$bold"repo$cls : local repository composition"
43 | echo -e $blue$bold"apm$cls : Apache, Php, Mysql Install"
44 | echo -e $blue$bold"oracle$cls : oracle install"
45 | echo -e $blue$bold"quota$cls : quota install & composition"
46 | echo -e $blue$bold"mail$cls : Install & Send mail"
47 | fi
48 | echo # 공통 개행 처리 구문
--------------------------------------------------------------------------------
/sm-shell/Resource/Scripts/oracle.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | _OInstall() {
3 | yum install -y --nogpgcheck $data_path/oracle-database-preinstall-21c-1.0-1.el7.x86_64.rpm
4 | yum install -y --nogpgcheck $data_path/oracle-database-ee-21c-1.0-1.ol8.x86_64.rpm
5 | /etc/init.d/oracledb_ORCLCDB-21c configure
6 | usermod -a -G dba oracle
7 | echo "oracle:wjsansrk" | chpasswd
8 | cp -rf $data_path/.bash_profile /home/oracle/.bash_profile
9 | }
10 |
11 | _ODatabase() {
12 | source /home/oracle/.bash_profile
13 | if [[ -f "$log_path/Oracle_DB_S_"$(date +"%m%d")".log" ]]; then # BS_S 파일이 존재할 때 n 차 실행 시
14 | if [[ ! $(cat $log_path/Oracle_DB_S_"$(date +"%m%d")".log | grep "오류") ]]; then # BS_S 로그에 오류 문구 존재하지 않을 때
15 | sqlplus -S / as sysdba << SQL
16 | startup mount;
17 | ALTER USER sys IDENTIFIED BY wjsansrk;
18 | commit;
19 | exit;
20 | SQL
21 | else
22 | _Handler oracle "$(date '+%H:%M:%S')" "$(cat $log_path/Oracle_DB_S_"$(date +"%m%d")".log | grep "오류")"
23 | fi
24 | else # BS_S 파일이 없을 때 즉 최초 실행 시
25 | sqlplus -S / as sysdba << SQL 2> $log_path/Oracle_DB_S_"$(date +"%m%d")".log
26 | startup mount;
27 | ALTER USER sys IDENTIFIED BY wjsansrk;
28 | commit;
29 | exit;
30 | SQL
31 | fi
32 |
33 | # initlinuxDB.ora /opt/oracle/dbs 경로에 복사
34 | #if [[ ! -f "$data_path/init$DB.ora" ]]; then
35 | cp -rf $data_path/initlinuxDB.ora /opt/oracle/dbs
36 | # if [[ ! $(cat /etc/opt/oracle/dbs/init$DB.ora | grep "$DB") ]]; then
37 | # sed -i 's/linuxDB/$DB/g' /etc/opt/oracle/dbs/init$DB.ora
38 | # fi
39 | #fi
40 |
41 | file_lists=("listener.ora" "tnsnames.ora" "oratab")
42 | for file_list in "${file_lists[@]}";
43 | do
44 | if [[ $file_list != "oratab" ]]; then
45 | if [[ ! $(diff -q $data_path/$file_list $ORACLE_HOME/network/admin) ]]; then
46 | cp -rf $data_path/$file_list $ORACLE_HOME/network/admin
47 | fi
48 | else
49 | if [[ ! $(diff -q $data_path/$file_list /etc/oratab) ]]; then
50 | cp -rf $data_path/$file_list /etc/oratab
51 | fi
52 | fi
53 | done
54 |
55 | # settinsg.ini 의 DB 명이 linuxDB 가 아닐 때
56 | # if [[ $DB != "linuxDB" ]]; then
57 | # sed -i 's/linuxDB.db/$DB.db/g' $ORACLE_HOME/network/admin/listener.ora
58 | # sed -i 's/linuxDB.db/$DB.db/g' $ORACLE_HOME/network/admin/tnsnames.ora
59 | # sed -i 's/linuxDB.db/$DB.db/g' /etc/oratab
60 | # fi
61 |
62 | # 예외처리 오류 리스트
63 | # ORA-01034 : 오라클 존재하지 않음
64 | # ORA-01109 : 데이터베이스 개방 오류
65 | # NID-00106 : 오라클 오류와 함께 DB 로그인 실패
66 | # NID-00121 : 데이터 베이스가 열리면 안됨
67 | # NID-00135 : 오라클 활성 스레드 오류
68 |
69 | nid target=sys DBNAME=linuxDB 2> $log_path/Oracle_DB_S_"$(date +"%m%d")".log
70 | if [[ ! $(cat $log_path/Oracle_DB_"$(date +"%m%d")".log | grep -o -e "NID-00106" -e "NID-00135" -e "ORA-01034" -e "NID-00121") ]]; then
71 | sed -i 's/export ORACLE_SID=ORCLCDB/export ORACLE_SID=linuxDB/g' /home/oracle/.bash_profile
72 | source /home/oracle/.bash_profile
73 | sqlplus -S / as sysdba << SQL 2> $log_path/Oracle_DB_S_"$(date +"%m%d")".log
74 | startup mount;
75 | ALTER database open resetlogs;
76 | exit;
77 | SQL
78 | else
79 | _Handler oracle "$(date '+%H:%M:%S')" "$(cat $log_path/Oracle_DB_"$(date +"%m%d")".log | grep -o -e "NID-00106" -e "NID-00135" -e "ORA-01034" -e "NID-00121")"
80 | fi
81 | }
82 |
83 | _OBack() {
84 | sed -i 's/export ORACLE_SID=linuxDB/export ORACLE_SID=ORCLCDB/g' /home/oracle/.bash_profile
85 | source /home/oracle/.bash_profile
86 | }
87 |
88 | _OSql() {
89 | sqlplus -S / as sysdba << SQL
90 | CREATE TABLE $TABLE (수번 VARCHAR2(10),이름 VARCHAR2(15),학년 INT,그룹 VARCHAR2(10),학점 VARCHAR2(15));
91 | SQL
92 |
93 | cat > load_data.ctl << EOF
94 | LOAD DATA
95 | INFILE '$data_path/data.txt'
96 | APPEND
97 | INTO TABLE $TABLE
98 | FIELDS TERMINATED BY '\t'
99 | (수번, 이름, 학년, 그룹, 학점)
100 | EOF
101 |
102 | # SQL Loader "load_data.ctl" load
103 | sqlldr control=load_data.ctl
104 | }
105 |
106 | # 알고리즘 수정 필요.
107 | _OSort() {
108 | # 1 ~ 10 정렬 sort -k3,3n -k4,4
109 | # 11 ~ 20 정렬 sort -k2,2 -k3,3n
110 | # 21 ~ 30 정렬 sort -k4,4 -k3,3n
111 | # 31 ~ 40 정렬 sort -k5,5 -k3,3n
112 | # 41 ~ 48 정렬 sort -k3,3nr -k4,4
113 | if [[ $TYPE == "1" ]]; then
114 | SORT_1="-k3,3n -k4,4"
115 | SORT_2="-k2,2 -k3,3n"
116 | elif [[ $TYPE == "2" ]]; then
117 | SORT_1="-k2,2 -k3,3n"
118 | SORT_2="-k4,4 -k3,3n"
119 | elif [[ $TYPE == "3" ]]; then
120 | SORT_1="-k4,4 -k3,3n"
121 | SORT_2="-k5,5 -k3,3n"
122 | elif [[ $TYPE == "4" ]]; then
123 | SORT_1="-k5,5 -k3,3n"
124 | SORT_2="-k3,3nr -k4,4"
125 | fi
126 |
127 | if [[ $TYPE != "0" ]]; then
128 | head -n $HEAD $data_path/data.txt > /sm-shell/data_1.txt
129 | tail -n $TAIL $data_path/data.txt > /sm-shell/data_2.txt
130 | sort $SORT_1 /sm-shell/data_1.txt > /sm-shell/score_result.txt
131 | sort $SORT_2 /sm-shell/data_2.txt >> /sm-shell/score_result.txt
132 | rm -rf /sm-shell/data_1.txt
133 | rm -rf /sm-shell/data_2.txt
134 | else
135 | sort -k2,2 -k3,3n $data_path/data.txt > /sm-shell/score_result.txt
136 | fi
137 | }
138 |
139 | # 전달된 파라미터 필터링
140 | chmod 777 -R /sm-shell/Log/*
141 | if [[ "$1" == "install" ]]; then
142 | _OInstall
143 | elif [[ "$1" == "sort" ]]; then
144 | _OSort
145 | elif [[ "$1" == "setdb" ]]; then
146 | _ODatabase
147 | elif [[ "$1" == "sql" ]]; then
148 | _OSql
149 | elif [[ "$1" == "back" ]]; then
150 | _OBack
151 | else
152 | source $shell_path/messages.sh oracle
153 | fi
--------------------------------------------------------------------------------
/sm-shell/Resource/Scripts/quota.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | _QInstall() {
4 | users=("samuel" "$NICK" "csejj")
5 | groups=("linuxadmin" "linuxuser")
6 |
7 | # quota 패키지 설치되지 않을 시 설치
8 | if [[ ! $(rpm -qa | grep quota) ]]; then
9 | yum install -y quota
10 | fi
11 |
12 | # quotahome 폴더 존재하지 않을 시 생성
13 | if [[ ! -d "/quotahome" ]]; then
14 | mkdir /quotahome
15 | fi
16 |
17 | # group 배열에 저장된 계정 조건문
18 | for group in "${groups[@]}";
19 | do
20 | if [[ $(group "$group") ]]; then
21 | groupdel $group
22 | else
23 | groupadd $group
24 | fi
25 | done
26 |
27 | # user 배열에 저장된 계정 조건문
28 | for user in "${users[@]}";
29 | do
30 | if [[ $(id "$user") ]]; then
31 | userdel $user
32 | useradd -d /quotahome/$user $user
33 | if [[ $user == "csejj" ]]; then
34 | chgrp linuxuser /quotahome/$user
35 | chmod g+s /quotahome/$user
36 | usermod -a -G linuxuser $user
37 | elif [[ $user == "samuel" ]]; then
38 | chgrp linuxadmin /quotahome/$user
39 | usermod -a -G linuxadmin $user
40 | fi
41 | else
42 | useradd -d /quotahome/$user $user
43 | if [[ $user == "csejj" ]]; then
44 | chgrp linuxuser /quotahome/$user
45 | chmod g+s /quotahome/$user
46 | usermod -a -G linuxuser $user
47 | elif [[ $user == "samuel" ]]; then
48 | chgrp linuxadmin /quotahome/$user
49 | usermod -a -G linuxadmin $user
50 | fi
51 | fi
52 | done
53 | }
54 |
55 | _QSettings() {
56 | if [[ ! $(grep "$2 /quotahome ext4 defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 1 2" "/etc/fstab") ]]; then
57 | echo "$2 /quotahome ext4 defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 1 2">> /etc/fstab
58 | fi
59 | mount -o remount $2 > $log_path/Quota_Mount_"$(date +"%m%d")".log
60 | if [[ ! $(cat $log_path/Oracle_DB_"$(date +"%m%d")".log | grep "") ]]; then
61 | quotaoff -avug
62 | quotacheck -augmn
63 | rm -rf aquota.*
64 | quotacheck -augmn
65 |
66 | touch aquota.user aquota.group
67 | chmod 600 aquota.*
68 |
69 | quotacheck -augmn
70 | quotaon -avug
71 | setquota -g linuxuser 1M 1M 20 20 /quotahome
72 | setquota -u samuel 0 0 10 10 /quotahome
73 | setquota -u $NICK 0 0 0 0 /quotahome
74 | echo -e "$white$b_green"" Complete$cls quota composition!"
75 | else
76 | _Handler Quota "$(date '+%H:%M:%S')" "$2"_Mount
77 | fi
78 | }
79 |
80 | # 전달된 파라미터 필터링
81 | if [[ $(mount | grep "/quotahome type ext4") ]]; then
82 | if [[ "$1" == "install" ]]; then
83 | _QInstall
84 | elif [[ "$1" == "set" ]]; then
85 | _QSettings $1 $2
86 | fi
87 | else
88 | _Handler Quota "$(date '+%H:%M:%S')" Check_Mount_Partition
89 | fi
--------------------------------------------------------------------------------
/sm-shell/Resource/Scripts/repo.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # 예외 처리 핸들러
4 | if [[ ! -d "/sm-shell" ]]; then
5 | _Handler /sm-shell "$(date '+%H:%M:%S')" Directory
6 | mkdir /sm-shell
7 | elif [[ ! -d "/sm-shell/Resource" ]]; then
8 | _Handler /sm-shell/Resource "$(date '+%H:%M:%S')" Directory
9 | mkdir /sm-shell/Resource
10 | elif [[ ! -d "/sm-shell/Resource/Rpm" ]]; then
11 | _Handler /sm-shell/Resource/Rpm "$(date '+%H:%M:%S')" Directory
12 | mkdir /sm-shell/Resource/Rpm
13 | fi
14 |
15 | rm -rf /etc/yum.repos.d/* # 이전 레포 삭제
16 | cp /sm-shell/Resource/Data/local.repo /etc/yum.repos.d # 레포 복붙
17 | yum clean all # 레포 리스트 초기화
18 | yum repolist # 레포리스트 구성
19 | echo -e "$white$b_green"" Complete$cls repo composition!"
20 | if [[ $(cat /etc/sysconfig/selinux | grep SELINUX=enforcing) ]]; then
21 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
22 | fi
--------------------------------------------------------------------------------
/sm-shell/Resource/Scripts/settings.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Foreground Color
4 | red="\e[91m"
5 | black="\e[30m"
6 | white="\e[97m"
7 | green="\e[92m"
8 | blue="\e[94m"
9 | tear="\e[96m"
10 | yellow="\e[93m"
11 | magenta="\e[95m"
12 | cyan="\e[0;96m"
13 | cls="\e[m"
14 |
15 | # Font Styles
16 | bold="\e[1m"
17 | italic="\e[3m"
18 | line="\e[4m"
19 |
20 | # Background Color
21 | b_red="\e[41m"
22 | b_green="\e[42m"
23 | b_blue="\e[44m"
24 | b_yellow="\e[43m"
25 | b_magenta="\e[45m"
26 | b_cyan="\e[46m"
27 | b_white="\e[47m"
28 | b_gray="\e[007m"
29 |
30 | # '../Data/settings.ini'
31 | src_path="/sm-shell/Resource"
32 | data_path="/sm-shell/Resource/Data"
33 | shell_path="/sm-shell/Resource/Scripts"
34 | log_path="/sm-shell/Log"
35 | set_path="$data_path/settings.ini"
36 | net_path="/etc/sysconfig/network-scripts/ifcfg-enp4s0"
37 |
38 | if [[ ! -d "/sm-shell/Log" ]]; then
39 | mkdir /sm-shell/Log
40 | fi
41 |
42 | if [[ -f "$set_path" ]]; then
43 | ID=$(cat $set_path | grep "ID =" | cut -f2 -d "=")
44 | NICK=$(cat $set_path | grep "NICK =" | cut -f2 -d "=")
45 | NAME=$(cat $set_path | grep "NAME =" | cut -f2 -d "=")
46 | IP=$(cat $set_path | grep "IP =" | cut -f2 -d "=")
47 | TO=$(cat $set_path | grep "TO =" | cut -f2 -d "=")
48 | FILES=$(cat $set_path | grep "FILES =" | cut -f2 -d "=")
49 | DIRECTORY=$(cat $set_path | grep "DIRECTORY =" | cut -f2 -d "=")
50 |
51 | # DB 설정 변수
52 | DB=$(cat $set_path | grep "DB =" | cut -f2 -d "=")
53 | TABLE=$(cat $set_path | grep "TABLE =" | cut -f2 -d "=")
54 |
55 | # SORT 설정 변수
56 | HEAD=$(cat $set_path | grep "HEAD =" | cut -f2 -d "=")
57 | TAIL=$(cat $set_path | grep "TAIL =" | cut -f2 -d "=")
58 | TYPE=$(cat $set_path | grep "TYPE =" | cut -f2 -d "=")
59 |
60 | # 변수 공백 제거
61 | variables=("ID" "NICK" "NAME" "IP" "TO" "FILES" "DIRECTORY" "DB" "TABLE" "HEAD" "TAIL" "TYPE")
62 | for space in "${variables[@]}"
63 | do
64 | var_value="${!space}"
65 | var_value=$(echo "$var_value" | sed 's/ //g')
66 | eval "$space=\"$var_value\""
67 | done
68 | else
69 | _Handler '$data_path/settings.ini' "$(date '+%H:%M:%S')" File_exist
70 | exit 1
71 | fi
72 |
73 | # Network Settings
74 | if [[ $(cat $net_path | grep "BOOTPROTO=dhcp") ]]; then
75 | sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/g' $net_path
76 | echo "IPADDR=$IP" >> $net_path
77 | echo "PREFIX=24" >> $net_path
78 | echo "GATEWAY=202.31.247.254" >> $net_path
79 | echo "DNS1=202.31.224.3" >> $net_path
80 | echo "DNS2=202.31.240.2" >> $net_path
81 | systemctl restart network
82 | fi
--------------------------------------------------------------------------------
/sm-shell/sm_final.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #### 서버관리 자동화 SHELL SCRIPTS 시작부 ####
3 | #### AUTHOR : LEE KANG IL / SM15-LUIKIE ####
4 | #### EMAIL : lki_familiar@naver.com ####
5 | #### GIT : https://github.com/Memori-al ####
6 |
7 | # 스크립트 동작부
8 | _Init() {
9 | source /sm-shell/Resource/Scripts/settings.sh
10 | case "$1" in
11 | "rpm")
12 | rpm -qa > "/sm-shell/$ID-$NAME-rpm-list.log"
13 | ;;
14 | "oracle")
15 | chmod 777 -R /sm-shell/Log/*
16 | case "$2" in
17 | "install" | "setdb" | "sort" | "sql" | "back")
18 | source "$shell_path/oracle.sh" "$2" >> "$log_path/Oracle_$(date +"%m%d").log" 2>&1
19 | ;;
20 | *)
21 | source "$shell_path/messages.sh" oracle
22 | exit 1
23 | ;;
24 | esac
25 | ;;
26 | "repo")
27 | source "$shell_path/repo.sh"
28 | ;;
29 | "apm")
30 | case "$2" in
31 | "install" | "split" | "merge" | "check")
32 | source "$shell_path/apm.sh" "$2" >> "$log_path/APM_$(date +"%m%d").log" 2>&1
33 | ;;
34 | *)
35 | source "$shell_path/messages.sh" apm
36 | exit 1
37 | ;;
38 | esac
39 | ;;
40 | "quota")
41 | case "$2" in
42 | "install")
43 | source "$shell_path/quota.sh" install >> "$log_path/Quota_$(date +"%m%d").log" 2>&1
44 | ;;
45 | "set")
46 | source "$shell_path/quota.sh" set "$3" >> "$log_path/Quota_$(date +"%m%d").log" 2>&1
47 | ;;
48 | *)
49 | source "$shell_path/messages.sh" quota
50 | exit 1
51 | ;;
52 | esac
53 | ;;
54 | "mail")
55 | case "$2" in
56 | "send")
57 | case "$3" in
58 | "local" | "global" | "nofile")
59 | source "$shell_path/mail.sh" send "$3" >> "$log_path/Mail_Tranfer_$(date +"%m%d").log" 2>&1
60 | ;;
61 | *)
62 | source "$shell_path/messages.sh" mail
63 | exit 1
64 | ;;
65 | esac
66 | ;;
67 | "install")
68 | source "$shell_path/mail.sh" install >> "$log_path/Mail_Tranfer_$(date +"%m%d").log" 2>&1
69 | ;;
70 | *)
71 | source "$shell_path/messages.sh" mail
72 | exit 1
73 | ;;
74 | esac
75 | ;;
76 | "help")
77 | source "$shell_path/messages.sh" help
78 | ;;
79 | *)
80 | source "$shell_path/messages.sh" "$1"
81 | exit 1
82 | ;;
83 | esac
84 | } 2>> /sm-shell/Log/Init_"$(date +"%m%d")".log
85 |
86 | # 예외 처리 핸들러
87 | _Handler() {
88 | echo "[$2] $1 $3 Error" >> $log_path/Error_"$(date +"%m%d")".log
89 | echo -e "$white$b_red[$2] $1 $3 Error$cls"
90 | } 2>> $log_path/Error_"$(date +"%m%d")".log
91 |
92 | # 시작 함수
93 | _Init $1 $2 $3 $4 $5
94 |
--------------------------------------------------------------------------------
/sm/agm_v2_kernel.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Made by luikie #
3 | # Commit Date : 2023. 10. 03. Tue. #
4 |
5 | Main() {
6 | # sm-*.txt 파일 확인
7 | if [[ ! -f "./hs-user.txt" ]]; then
8 | wget "https://raw.githubusercontent.com/Memori-al/bash-scripts/main/sm/hs-user.txt" # git 서버에서 hs-user.txt 파일 다운로드
9 | fi
10 | if [[ ! -f "./sm-deluser.txt" ]]; then
11 | wget -O "./sm-deluser.txt" "https://raw.githubusercontent.com/Memori-al/bash-scripts/main/sm-user.txt" # git 서버에서 sm-user.txt 파일 다운로드 후 sm-deluser.txt 로 저장
12 | fi
13 | # 변수 설정
14 | title="[Console]"
15 | red="\e[91m"
16 | white="\e[97m"
17 | green="\e[92m"
18 | blue="\e[94m"
19 | tear="\e[96m"
20 | yellow="\e[93m"
21 | magenta="\e[95m"
22 | cyan="\e[0;96m"
23 | cls="\e[m" # 색상 초기화
24 | Menu # Menu 함수 호출
25 | }
26 |
27 | # Menu Function
28 | Menu() {
29 | count=0
30 | clear
31 | echo -e "[${blue}U S E R G R O U P A U T O G E N E R A T O R S${cls}]"
32 | echo
33 | echo -e "[${green}1${cls}] Useradd to Group"
34 | echo -e "[${cyan}2${cls}] Delete users from group"
35 | echo -e "[${magenta}3${cls}] 5000 Useradd to Group"
36 | echo -e "[${magenta}4${cls}] Delete 5000 users from group"
37 | echo -e "[${red}0${cls}] Exit"
38 | echo
39 | echo -e -n "$title ${tear}Select Menu:${cls} "
40 | read key
41 | if [ ${key} -eq 1 ] ; then
42 | Utg
43 | elif [ ${key} -eq 2 ] ; then
44 | Dfg
45 | elif [ ${key} -eq 3 ] ; then
46 | Ua5
47 | elif [ ${key} -eq 4 ] ; then
48 | Ud5
49 | elif [ ${key} -eq 0 ] ; then
50 | exit 0
51 | else
52 | Error 1
53 | fi
54 | }
55 |
56 | # Add non-existent users to the group
57 | Utg() {
58 | if [ ! -s "./hs-user.txt" ]; then # uid_arr 데이터가 비었을 때 예외 처리
59 | Error "$title Unable to read user list. please check ./sm-user.txt"
60 | fi
61 |
62 | # Group Settings
63 | groups=("hsa:6000" "hsb:6001") # 그룹:그룹아이디 배열
64 | for group in "${groups[@]}" # group 변수에 groups 배열 입력
65 | do
66 | gname=$(echo $group | cut -d: -f1) # group 배열의 1번 필드 분할 후 저장
67 | gid=$(echo $group | cut -d: -f2) # group 배열의 2번 필드 분할 후 저장
68 | if ! getent group "$gname" | grep &>/dev/null "\b$gid\b"; then # 그룹이 존재하지 않을 때
69 | groupadd -g $gid $gname # 그룹 ID 인 그룹 생성
70 | echo "$title Created group $gname with group ID $gid." # 생성 후 결과 보고
71 | fi
72 | done
73 |
74 | # Utg
75 | while read -r name user group # sm-user.txt 데이터를 읽어옴
76 | do
77 | if getent group "$group" | grep &>/dev/null "\b$user\b"; then # 그룹에 사용자가 존재할 때
78 | echo -e "$title ${red}User $user already exists in group $group.${cls}"
79 | else
80 | if id -u "$user" >/dev/null 2>&1; then # 사용자가 시스템 상에 존재할 때
81 | usermod -a -G "$group" "$user" # 그룹에 사용자 추가
82 | usermod -c "$name" "$user"
83 | chgrp "$group" "/home/$user" # 그룹에 사용자 추가
84 | else
85 | useradd -m -d /home/$user -s /bin/bash $user # 사용자와 사용자의 home 디렉토리 생성
86 | echo "$user:wjsansrk"|chpasswd # 사용자의 비밀번호 변경
87 | usermod -a -G "$group" "$user" # 그룹에 사용자 추가
88 | usermod -c "$name" "$user"
89 | chgrp "$group" "/home/$user" # 그룹에 사용자 추가
90 | echo "$title Create $user and move to $group group" # 생성 후 결과 보고
91 | fi
92 | count=$(($count+1))
93 | fi
94 | done < hs-user.txt
95 | echo "$title $count Created!"
96 | read -t 3 -s
97 | Menu
98 | }
99 |
100 | # Delete users in a group
101 | Dfg() {
102 | if [ ! -s "sm-deluser.txt" ]; then # sm-deluser.txt 데이터가 비었을 때 예외 처리
103 | Error "$title Unable to read user list. please check ./sm-deluser.txt"
104 | fi
105 |
106 | while read -r user group # 데이터를 읽어와 f1, f2 필드에 user group 각각 저장
107 | do
108 | if getent group "$group" | grep &>/dev/null "\b$d\b"; then # 그룹에 사용자가 존재할 때
109 | userdel -r $user
110 | echo "$title User $user deleted from $group"
111 | count=$(($count+1))
112 | else
113 | echo "$title ${red}User $user does not exist in the group.${cls}"
114 | fi
115 | done < sm-deluser.txt
116 | echo "$title $count Deleted!"
117 | read -t 3 -s
118 | Menu
119 | }
120 |
121 | Ua5() {
122 | echo -n "$title Please specify a group name: "
123 | read group
124 | if grep -q "^$group:" /etc/group; then # 그룹이 시스템에 존재할 때
125 | echo -n "$title $group group already exists. Are you sure you want to select it to that group?(y/n): " # 해당 그룹으로 진행할 지 출력
126 | read Fkey
127 | if [[ ${Fkey} == "n" ]]; then # n 값 입력 시 add5000 함수로 다시 돌아감
128 | Ua5
129 | elif [[ ${Fkey} == "y" ]]; then # y 값 입력 시 출력 후 진행
130 | echo "$title Selected $group group"
131 | else # y, n 값이 아닐 때 예외 처리
132 | Error "$title key input Error!"
133 | fi
134 | fi
135 | if ! grep -q "^$group:" /etc/group; then # 그룹이 시스템에 존재하지 않을 때
136 | echo -n "$title $group group does not exist. Do you want to create that group?(y/n): " #그룹이 시스템에 존재하지 않아 그룹을 생성할지 출력
137 | read Fkey
138 | if [[ ${Fkey} == "n" ]]; then # n 값 입력 시 재귀
139 | Ua5
140 | elif [[ ${Fkey} == "y" ]]; then # y 값 입력 시 진행
141 | groupadd $group
142 | echo "$title $group add"
143 | else # y, n 값이 아닐 때 예외 처리
144 | Error "$title key input Error!"
145 | fi
146 | fi
147 | echo -n "$title Please specify a user name: "
148 | read user
149 | if [ ! -d "/home2" ]; then # home2 디렉토리가 존재하지 않을 때
150 | mkdir /home2 # home2 디렉토리 생성
151 | fi
152 | for i in {1..5000}
153 | do
154 | if getent group "$group" | grep &>/dev/null "\b$user-$i\b"; then # 그룹에 사용자가 존재할 때
155 | echo "$title User $user-$i already exists in group $group."
156 | else # 그룹에 사용자가 존재하지 않을 때
157 | if id -u "$user-$i" >/dev/null 2>&1; then # 사용자가 시스템 상에 존재할 때
158 | usermod -a -G "$group" "$user-$i" # 그룹에 사용자 추가
159 | chgrp "$group" "/home2/$user-$i" # 사용자 디렉토리 권한 그룹으로 변경
160 | else
161 | useradd -m -d /home2/$user-$i -s /bin/bash $user-$i # 사용자와 사용자의 home 디렉토리 생성
162 | echo "$user-$i:wjsansrk"|chpasswd # 사용자의 비밀번호 변경
163 | usermod -a -G "$group" "$user-$i" # 그룹에 사용자 추가
164 | chgrp "$group" "/home2/$user-$i" # 사용자 디렉토리 권한 그룹으로 변경
165 | echo "$title Create $user-$i and move to $group group" # 생성 후 결과 보고
166 | fi
167 | fi
168 | count=$(($i+1))
169 | done
170 | Menu
171 | }
172 |
173 | Ud5() {
174 | echo -n "$title Please specify the name of the group to delete: "
175 | read group
176 | if ! grep -q "^$group:" /etc/group; then # 그룹이 시스템에 존재하지 않을 때
177 | "$title $group group does not exist."
178 | read -t 3 -s
179 | Menu
180 | fi
181 |
182 | Ud5_array=($(getent group $group | cut -d: -f4 | tr ',' ' ')) # getent group 명령어로 group 내 사용자 배열에 저장
183 | U_count=${#Ud5_array[*]} # 그룹 내 사용자 수 변수에 저장
184 | if [[ $U_count -eq 0 ]]; then # 그룹 내에 사용자가 존재하지 않을 때
185 | echo "$title There are no users in the $group group."
186 | read -t 3 -s
187 | Menu
188 | else # 그룹 내에 사용자가 존재할 때
189 | echo "$title ${#Ud5_array[*]} users in $group group"
190 | for user in ${Ud5_array[*]}
191 | do
192 | userdel -r "$user" # 사용자 삭제
193 | echo "$title user $user deleted."
194 | done
195 | fi
196 | Menu
197 | }
198 |
199 | # error exception
200 | Error() { # 에러 예외 처리 함수
201 | echo "$title ERROR: $1"
202 | read -t 3 -s
203 | Menu
204 | }
205 |
206 | # Call Main Function
207 | Main # Main 함수 호출
208 |
--------------------------------------------------------------------------------
/sm/hs-user.txt:
--------------------------------------------------------------------------------
1 | 김호준 riveria hsa
2 | 이동수 dogger hsa
3 | 최부건 winner hsb
4 | 유태현 thyer hsb
5 | 유종환 civeria hsa
6 | 박용현 piber hsb
7 | 백민규 begger hsb
8 | 이강일 luikie hsa
9 | 박지혁 pibber hsa
10 | 송재형 thember hsb
11 | 정한나 tajer hsa
12 | 한재성 shiniper hsa
13 | 강은종 whitemer hsa
14 | 이환희 lipelra hsb
15 | 유기석 jamber hsb
16 | 연건모 yetter hsa
17 | 양가은 dweler hsb
18 | 응웬반 tientail hsb
19 |
--------------------------------------------------------------------------------
/sm/packages.txt:
--------------------------------------------------------------------------------
1 | glibc.i686
2 | libstdc++.i686
3 | epel-release
4 | wine
5 | xorg-x11-server-Xvfb
6 | xrdp
--------------------------------------------------------------------------------
/sm/sm-user.txt:
--------------------------------------------------------------------------------
1 | katie kt
2 | noner lgt
3 | rover skt
4 | winner kt
5 | thyer lgt
6 | piber kt
7 | begger skt
8 | lunner skt
9 | sibber kt
10 | quicker kt
11 | luikie kt
12 | saker lgt
13 | pibber lgt
14 | jacker lgt
15 | zeroer skt
16 | hidy kt
17 | thember kt
18 | viser skt
19 | tajer lgt
20 | shiniper lgt
21 | kimbel lgt
22 | divier kt
23 | happy kt
24 | whitemer kt
25 | souer kt
26 | lipelra skt
27 | truer lgt
28 | harris skt
29 | penter lgt
30 | yeller skt
31 | byden lgt
32 | alice kt
33 | yumber kt
34 | roller skt
35 | oidy lgt
36 | dweler kt
37 | katie kt
38 | opper lgt
39 | fixer lgt
40 | corner skt
41 | kamala kt
--------------------------------------------------------------------------------
/vrising/autoset.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # 패키지 설치
4 | Install() {
5 | wget http://github.com/Memori-al/bash-scripts/packages.txt
6 | local packages=$(cat ./packages.txt)
7 | local pack=
8 | for rpm_pack in $packages
9 | do
10 | check=$(rpm -q $rpm_pack|cut -d " " -f4-5)
11 | if [[ $check == "not installed" ]]; then
12 | pack+= $pack
13 | fi
14 | done
15 | yum install -y $pack
16 | }
17 |
18 | # Steamcmd 설치
19 | Steam() {
20 | useradd steam
21 | echo -r "Input Steam User Passwd" | read -r passwd
22 | echo "steam:$passwd" | chpasswd
23 | mkdir /home/steam/steamcmd | mkdir /home/steam/steamcmd/VRising | mkdir /home/steam/steamcmd/VRising/save-data/Settings
24 | wget -O- "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - /home/steam/steamcmd/VRising
25 | chmod 777 -R /home/steam/steamcmd
26 | cd /home/steam/steamcmd/VRising/
27 | ./steamcmd.sh +force_install_dir VRising +quit
28 | ./steamcmd.sh +login anonymous +app_update 1829350 +quit
29 | }
30 |
31 | # 방화벽 설정
32 | Firewall() {
33 | firewall-cmd --add-port=9876/tcp | firewall-cmd --add-port=9876/udp
34 | firewall-cmd --add-port=9877/tcp | firewall-cmd --add-port=9877/udp
35 | firewall-cmd --add-port=3389/tcp | firewall-cmd --add-port=3389/udp
36 | firewall-cmd --runtime-to-permanent
37 | firewall-cmd --reload
38 | }
39 |
40 | # 서버 설치 및 설정
41 | Server() {
42 | export WINEARCH=win64
43 | xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' wine VRisingServer.exe -persistentDataPath ./save-data -logFile server.log
44 | read -t 60 -s
45 | echo '#!/bin/bash' > run.sh
46 | echo 'xvfm-run --auto-servernum --server-args='-screen 0 640x480x24:32' wine VRisingServer.exe -persistentDataPath ./save-data -logFile server.log' >> run.sh
47 | echo '[Unit]' > /etc/systemd/system/VRising.service
48 | echo 'After=network.target' >> /etc/systemd/system/VRising.service
49 | echo '[Service]' >> /etc/systemd/system/VRising.service
50 | echo 'User=steam' >> /etc/systemd/system/VRising.service
51 | echo 'Group=steam' >> /etc/systemd/system/VRising.service
52 | echo 'WorkingDirectory=/home/steam/steamcmd/VRising' >> /etc/systemd/system/VRising.service
53 | echo 'ExecStart=/home/steam/steamcmd/VRising/run.sh' >> /etc/systemd/system/VRising.service
54 | echo '[Install]' >> /etc/systemd/system/VRising.service
55 | echo 'WantedBy=multi-user.target' >> /etc/systemd/system/VRising.service
56 | chmod +rwx ./run.sh
57 |
58 | systemctl start VRising.service
59 | read -t 60 -s
60 | systemctl stop VRising.service
61 | systemctl enable VRising.service
62 | }
63 |
64 | # 메인 함수
65 | Main() {
66 | Install
67 | Steam
68 | Firewall
69 | Server
70 | }
71 |
72 | # 메인 함수 호출
73 | Main
74 |
75 | # packages.txt, run.sh, /etc/systemd/system/VRising.service
--------------------------------------------------------------------------------
/vrising/back.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Variable & File Check Function
4 | Init() {
5 | s_date=$(date +"%Y-%m") # YYYY-MM Format
6 | s_date_all=$(date +"%Y-%m-%d") # YYYY-MM-DD Format
7 | save_path=/home/steam/steamcmd/VRising/VRising/save-data/Saves/v1/world1
8 | git_path=/home/steam/sh/VRising
9 | if [ ! -f "/var/log/VMS.$s_date_all.log" ]; then # BK-YY-MM-DD Folder Create
10 | echo "[$(date '+%H:%M:%S')] Started V Rising Server Management Scripts" > /var/log/VMS.$s_date_all.log
11 | fi
12 | if [ ! -d "$git_path/BK-$s_date" ]; then # BK-YY-MM Folder Create
13 | mkdir $git_path/BK-$s_date
14 | echo "[$(date '+%H:%M:%S')|Alert] Created $git_path/BK-$s_date directory because it does not exist." >> /var/log/VMS.$s_date_all.log
15 | fi
16 | if [ ! -d "$git_path/BK-$s_date_all" ]; then # BK-YY-MM-DD Folder Create
17 | mkdir $git_path/BK-$s_date_all
18 | echo "[$(date '+%H:%M:%S')|Alert] Created $git_path/BK-$s_date_all directory because it does not exist." >> /var/log/VMS.$s_date_all.log
19 | fi
20 | Loop
21 | }
22 |
23 | # Time Check Function
24 | Loop() {
25 | s_time=$(date +"%H:%M") # HH:MM Format
26 | if [[ $s_time == "07:00" ]]; then
27 | echo "[$(date '+%H:%M:%S')] Starting Save Data Backup" >> /var/log/VMS.$s_date_all.log
28 | Process # Call Server Control Function
29 | if [ -f $git_path/BK-$s_date/$s_date_all.7z ]; then
30 | echo "[$(date '+%H:%M:%S')|Success] Save data backup complete in Git repository." >> /var/log/VMS.$s_date_all.log
31 | else
32 | echo "[$(date '+%H:%M:%S')|Error] Failed to back up Save Data on Git repository." >> /var/log/VMS.$s_date_all.log
33 | echo "[$(date '+%H:%M:%S')|Error] $git_path/BK-$s_date/$s_date_all.7z file because it does not exist." >> /var/log/VMS.$s_date_all.log
34 | fi
35 | echo "[$(date '+%H:%M:%S')|Alert] The local server and game server have been restarted." >> /var/log/VMS.$s_date_all.log
36 | # reboot # Server Restart
37 | fi
38 | read -t 10 -s
39 | Loop # Recursion Function
40 | }
41 |
42 | # Game Server Control Function
43 | Process() {
44 | if [[ $(systemctl is-active vrising.service) -eq "active" ]]; then # Server On
45 | systemctl stop vrising.service
46 | echo "[$(date '+%H:%M:%S')|Alert] V Rising Service has been stopped." >> /var/log/VMS.$s_date_all.log
47 | read -t 10 -s # 10 s input waiting = 10 s timeout
48 | Backup # Save Data Copy
49 | Git # Git Push
50 | else # Server Off
51 | systemctl start vrising.service
52 | fi
53 | }
54 |
55 | # Data Copy Function
56 | Backup() {
57 | save=$(ls -r $save_path/*.save | head -n 2) # Split String
58 | for file in $save
59 | do
60 | cp -f $file $git_path/BK-$s_date_all # Copy Save Data
61 | done
62 | 7za a $git_path/BK-$s_date/$s_date_all.7z $git_path/BK-$s_date_all/ # 7Zip Pack
63 | rm -rf $git_path/BK-$s_date_all/ # Remove Data
64 | }
65 |
66 | # Git Upload Function
67 | Git() {
68 | git add $git_path/BK-$s_date/$s_date_all.7z
69 | git commit -m "$s_date_all 세이브 파일 백업"
70 | git push origin main
71 | }
72 |
73 | # Call Time Check Function
74 | Init
--------------------------------------------------------------------------------