├── .github
├── FUNDING.yml
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ ├── shellcheck.yml
│ └── ubuntu_2004.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── base
├── ALPINE
│ └── README.md
├── ARCH
│ ├── README.md
│ ├── after.sh
│ └── packages.list
├── CYGWIN
│ └── README.md
├── DEBIAN
│ ├── README.md
│ ├── after.sh
│ ├── packages.list
│ ├── server
│ │ ├── after.sh
│ │ └── packages.list
│ └── workstation
│ │ ├── before.sh
│ │ └── packages.list
├── FREEBSD
│ ├── README.md
│ └── packages.list
├── HAIKU
│ ├── README.md
│ └── packages.list
├── MACOS
│ ├── README.md
│ └── after.sh
├── MAGEIA
│ └── README.md
├── NETBSD
│ └── README.md
├── OPENBSD
│ ├── README.md
│ ├── after.sh
│ ├── before.sh
│ ├── packages.list
│ └── pf.conf
├── OPENWRT
│ └── README.md
├── PUPPY
│ ├── README.md
│ └── before.sh
├── REDHAT
│ ├── README.md
│ ├── after.sh
│ ├── packages.list
│ ├── server
│ │ └── packages.list
│ └── workstation
│ │ ├── before.sh
│ │ └── packages.list
├── SLACKWARE
│ ├── README.md
│ └── packages.list
├── SUSE
│ ├── README.md
│ ├── after.sh
│ └── packages.list
├── TERMUX
│ ├── README.md
│ └── packages.list
├── after.sh
├── before.sh
├── packages.list
├── server
│ └── after.sh
└── workstation
│ └── packages.list
├── img
└── WSL_Screenshot.jpg
└── postinstall.sh
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: Cyclenerd
2 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | First off, thanks for taking the time to contribute!
2 |
3 | ## Please Complete the Following
4 |
5 | - [ ] I used tabs to indent
6 | - [ ] I checked my code with [ShellCheck](https://www.shellcheck.net/)
7 |
8 | ## Notes
9 |
10 | Feel free to put whatever you want here.
--------------------------------------------------------------------------------
/.github/workflows/shellcheck.yml:
--------------------------------------------------------------------------------
1 | name: "ShellCheck"
2 |
3 | # Controls when the workflow will run
4 | on:
5 | # Triggers the workflow on push or pull request events but only for the master branch
6 | push:
7 | branches: [ master ]
8 | pull_request:
9 | branches: [ master ]
10 |
11 | # Allows you to run this workflow manually from the Actions tab
12 | workflow_dispatch:
13 |
14 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel
15 | jobs:
16 | # This workflow contains a single job called "test"
17 | shellcheck:
18 | # The type of runner that the job will run on
19 | runs-on: ubuntu-latest
20 |
21 | # Steps represent a sequence of tasks that will be executed as part of the job
22 | steps:
23 | - name: Install dependencies 🔧
24 | run: sudo apt-get install shellcheck
25 |
26 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
27 | - name: Checkout 🛎️
28 | uses: actions/checkout@v3
29 |
30 | # Run ShellCheck
31 | - name: ShellCheck 🔎
32 | run: shellcheck postinstall.sh
--------------------------------------------------------------------------------
/.github/workflows/ubuntu_2004.yml:
--------------------------------------------------------------------------------
1 | name: "Ubuntu 20.04 LTS"
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | pull_request:
7 | branches: [ master ]
8 |
9 | workflow_dispatch:
10 |
11 | jobs:
12 | ubuntu-2004:
13 | name: Test Ubuntu 20.04 LTS
14 | runs-on: ubuntu-20.04
15 | steps:
16 |
17 | # git clone
18 | - name: Checkout 🛎️
19 | uses: actions/checkout@v3
20 |
21 | # Test commands
22 | - name: Run postinstall.sh 🐧
23 | run: sudo -E bash postinstall.sh
24 |
25 | # Run tests
26 | - name: Log 📜
27 | run: cat /tmp/install_*
28 | - name: Test 🛠️
29 | run: grep "CI detected" < /tmp/install_*
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | test.sh
3 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to contribute
2 |
3 | First off, thanks for taking the time to contribute!
4 |
5 | ## Submitting changes
6 |
7 | Please send a [GitHub Pull Request](https://github.com/Cyclenerd/postinstall/pull/new/master) with a clear list of what you've done (read more about [pull requests](http://help.github.com/pull-requests/)).
8 |
9 | Always write a clear log message for your commits. One-line messages are fine for small changes, but bigger changes should look like this:
10 |
11 | $ git commit -m "A brief summary of the commit
12 | >
13 | > A paragraph describing what changed and its impact."
14 |
15 |
16 | ## Coding style
17 |
18 | Start reading the code and you'll get the hang of it. It is optimized for readability:
19 |
20 | * Variables must be uppercase and should begin with `MY_`.
21 | * Functions must be lower case and should begin with `my_`.
22 | * Check your shell scripts with [ShellCheck](https://www.shellcheck.net/) before submitting.
23 | * Please use tabs to indent.
24 |
25 | One more thing:
26 |
27 | * Keep it simple! 👍
28 |
29 | Thanks! ❤️❤️❤️
--------------------------------------------------------------------------------
/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 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
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 | {project} Copyright (C) {year} {fullname}
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 | # postinstall.sh
2 |
3 | [](https://github.com/Cyclenerd/postinstall/actions/workflows/shellcheck.yml)
4 | [](https://github.com/Cyclenerd/postinstall/actions/workflows/ubuntu_2004.yml)
5 |
6 | Bash Script to automate post-installation steps.
7 | Helps to install packages on different operating systems:
8 |
9 | * [x] Alpine Linux
10 | * [x] Android (Termux)
11 | * [x] Apple macOS
12 | * [x] Arch Linux
13 | * [x] CentOS
14 | * [x] Debian
15 | * [x] Fedora
16 | * [x] FreeBSD
17 | * [x] Haiku
18 | * [x] Mageia
19 | * [x] NetBSD
20 | * [x] OpenBSD
21 | * [x] OpenWRT
22 | * [x] Puppy
23 | * [x] RedHat
24 | * [x] RockyLinux
25 | * [x] Slackware
26 | * [x] SUSE
27 | * [x] Ubuntu
28 | * [x] Windows (Cygwin)
29 |
30 | ## Overview
31 |
32 | `postinstall.sh` is simple bash shell script which in turn generates scripts.
33 | The generation depends on the operating system and type of installation.
34 | The templates that are included in the generation can be stored in the file system or on a web server.
35 | This can also be your GitHub repository.
36 | Just fork this repository and edit it according to your needs.
37 |
38 | `postinstall.sh` is not a configuration management system.
39 | If you want to install many servers automatically, you should look at [ansible](https://github.com/ansible/ansible).
40 | But if you want to quickly reinstall your laptop or Raspberry Pi, `postinstall.sh` can help you.
41 |
42 | __Please check the [Wiki](https://github.com/Cyclenerd/postinstall/wiki/postinstall.sh) for more information.__
43 |
44 |
45 | ## Installation
46 |
47 | Download:
48 |
49 | ```shell
50 | curl -O "https://raw.githubusercontent.com/Cyclenerd/postinstall/master/postinstall.sh"
51 | ```
52 |
53 | Alternative download with short URL:
54 |
55 | ```shell
56 | curl -fL http://bit.ly/get_postinstall -o postinstall.sh
57 | ```
58 |
59 | Create a package lists and scripts as explained in this [repository](https://github.com/Cyclenerd/postinstall/tree/master/base) or in the [Wiki](https://github.com/Cyclenerd/postinstall/wiki/postinstall.sh).
60 |
61 | Example:
62 |
63 | ```shell
64 | mkdir install
65 | cd install
66 | vi packages.list
67 | ```
68 |
69 | Run as root:
70 |
71 | ```shell
72 | bash postinstall.sh -b install
73 | ```
74 |
75 | ## Usage
76 |
77 | ```txt
78 | Usage: postinstall.sh [-t ] [-b ] [-h]:
79 | [-t ] sets the type of installation (default: server)
80 | [-b ] sets the base url or dir (default: https://raw.githubusercontent.com/Cyclenerd/postinstall/master/base)
81 | [-h] displays help (this message)
82 | ```
83 |
84 | Example: `postinstall.sh` or `postinstall.sh -t workstation`
85 |
86 |
87 | ## Screenshot
88 |
89 | 
90 |
91 |
92 | ## Program Flow
93 |
94 | * Determine operating system and architecture
95 | * Check package manager and requirements
96 | * Generate script to run before and after installation and list of packages to install
97 | * Install packages
98 |
99 |
100 | ## Requirements
101 |
102 | Only `bash`, `curl`, `tput` (`ncurses-utils`) and a package manager for the respective operating system:
103 |
104 | * Alpine Linux → `apk`
105 | * Apple macOS → `port` or `brew`
106 | * Arch Linux → `pacman`
107 | * Cygwin → `apt-cyg`
108 | * Debian / Ubuntu → `apt-get`
109 | * FreeBSD → `pkg`
110 | * Haiku → `pkgman`
111 | * Mageia → `urpmi`
112 | * NetBSD → `pkg_add`
113 | * OpenBSD → `pkg_add`
114 | * OpenWRT → `opkg`
115 | * Puppy → `pkg` (https://gitlab.com/sc0ttj/Pkg)
116 | * Red Hat / Fedora / CentOS → `dnf` or `yum`
117 | * Slackware → `slackpkg`
118 | * SUSE / openSUSE → `zypper`
119 | * Termux → `pkg`
120 |
121 |
122 | ## TODO
123 |
124 | * More and better documentation
125 | * Support for even more operating systems and package managers
126 |
127 | Help is welcome 👍
128 |
129 |
130 | ## License
131 |
132 | GNU Public License version 3.
133 | Please feel free to fork and modify this on GitHub (https://github.com/Cyclenerd/postinstall).
134 |
--------------------------------------------------------------------------------
/base/ALPINE/README.md:
--------------------------------------------------------------------------------
1 | # Alpine Linux
2 |
3 | Alpine Linux is a Linux distribution based on musl and BusyBox, primarily designed for "power users who appreciate security, simplicity and resource efficiency".
4 |
5 | ## Using apk for Binary Package Management
6 |
7 | `apk` is a package management tool for Alpine Linux.
8 |
9 | It is already installed in the standard. You do not have to do anything.
10 |
11 | ### Install bash
12 |
13 | # apk add bash
14 |
15 | ### Install curl
16 |
17 | # apk add curl
--------------------------------------------------------------------------------
/base/ARCH/README.md:
--------------------------------------------------------------------------------
1 | # Arch Linux
2 |
3 | Arch Linux is a lightweight and flexible Linux distribution that tries to Keep It Simple.
4 |
5 | ## Using pacman for Binary Package Management
6 |
7 | `pacman` is a package management tool for Arch Linux.
8 |
9 | It is already installed in the standard. You do not have to do anything.
10 |
11 |
--------------------------------------------------------------------------------
/base/ARCH/after.sh:
--------------------------------------------------------------------------------
1 | #
2 | # after.sh for ARCH and ALL types
3 | #
4 |
5 |
6 | #
7 | # systemd-swap
8 | # https://www.archlinux.org/packages/?name=systemd-swap
9 | #
10 |
11 | SWAP_CONF_FILE="/etc/systemd/swap.conf"
12 | echo_step " Modifying systemd-swap configuration file at $SWAP_CONF_FILE"
13 | if [ -f "$SWAP_CONF_FILE" ]; then
14 | # Backup
15 | cp "$SWAP_CONF_FILE" "$SWAP_CONF_FILE.$OPERATING_SYSTEM"
16 | # Disable Zswap
17 | perl -i -pe "s,^zswap_enabled.*,zswap_enabled=0,g" "$SWAP_CONF_FILE"
18 | # Disable ZRam
19 | perl -i -pe "s,^zram_enabled.*,zram_enabled=0,g" "$SWAP_CONF_FILE"
20 | # Disable Swap File Universal
21 | perl -i -pe "s,^swapfu_enabled.*,swapfu_enabled=0,g" "$SWAP_CONF_FILE"
22 | # Enable Swap File Chunked
23 | perl -i -pe "s,^swapfc_enabled.*,swapfc_enabled=1,g" "$SWAP_CONF_FILE"
24 | # Enable Swap devices
25 | perl -i -pe "s,^swapd_auto_swapon.*,swapd_auto_swapon=1,g" "$SWAP_CONF_FILE"
26 | # OK?
27 | if [ "$?" -ne 0 ]; then
28 | echo_warning "Failed, will attempt to continue"
29 | else
30 | echo_success
31 | fi
32 | else
33 | echo_warning "$SWAP_CONF_FILE not found, will attempt to continue"
34 | fi
35 |
36 | echo_step " Enable systemd-swap"
37 | if systemctl enable systemd-swap >>"$INSTALL_LOG" 2>&1; then
38 | echo_success
39 | else
40 | echo_warning "Failed, will attempt to continue"
41 | fi
42 |
43 | echo_step " Start systemd-swap"
44 | if systemctl start systemd-swap >>"$INSTALL_LOG" 2>&1; then
45 | echo_success
46 | else
47 | echo_warning "Failed, will attempt to continue"
48 | fi
49 |
50 | #
51 | # Set the swappiness
52 | # https://wiki.archlinux.org/index.php/Swap
53 | #
54 |
55 | echo_step " Set the swappiness (vm.swappiness=10)"
56 | echo "vm.swappiness=10" >> "/etc/sysctl.d/99-sysctl.conf"
57 | echo_success
58 |
--------------------------------------------------------------------------------
/base/ARCH/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for ARCH and all TYPEs
3 | #
4 | # One package per line
5 | systemd-swap
6 | net-tools
7 | openssh
8 | postfix
9 | cronie
10 | ufw
11 | mutt
12 |
--------------------------------------------------------------------------------
/base/CYGWIN/README.md:
--------------------------------------------------------------------------------
1 | # Cygwin
2 |
3 | Cygwin has no package manager in the standard installation.
4 |
5 | You must install a package manager.
6 |
7 | ## Using apt-cyg for Binary Package Management
8 |
9 | apt-cyg is a simple script. To install:
10 |
11 | curl -L -k rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
12 | install apt-cyg /bin
13 |
14 | In addition to `curl`, you must also have `wget` installed.
15 |
--------------------------------------------------------------------------------
/base/DEBIAN/README.md:
--------------------------------------------------------------------------------
1 | # Debian
2 |
3 | Debian is a Unix-like computer operating system. Ubuntu is a Debian-based Linux operating system.
4 |
5 | ## Using APT for Binary Package Management
6 |
7 | `apt-get` is a package management tool for Debian and other Linux distributions.
8 |
9 | It is already installed in the standard. You do not have to do anything.
10 |
11 |
--------------------------------------------------------------------------------
/base/DEBIAN/after.sh:
--------------------------------------------------------------------------------
1 | #
2 | # after.sh for DEBIAN and ALL types
3 | #
4 |
5 |
6 | #
7 | # Set the swappiness
8 | # https://en.wikipedia.org/wiki/Swappiness
9 | #
10 |
11 | echo_step " Set the swappiness (vm.swappiness=10)"
12 | echo "vm.swappiness=10" >> "/etc/sysctl.conf"
13 | echo_success
14 |
15 | #
16 | # Edit motd
17 | #
18 |
19 | echo_step " Edit motd"
20 | chmod -x "/etc/update-motd.d/10-help-text" >>"$INSTALL_LOG" 2>&1
21 | chmod -x "/etc/update-motd.d/50-motd-news" >>"$INSTALL_LOG" 2>&1
22 | chmod -x "/etc/update-motd.d/80-livepatch" >>"$INSTALL_LOG" 2>&1
23 | echo_success
--------------------------------------------------------------------------------
/base/DEBIAN/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for DEBIAN and all TYPEs
3 | #
4 | # One package per line
5 | screen
6 | nano
7 | git
8 | ufw
9 |
--------------------------------------------------------------------------------
/base/DEBIAN/server/after.sh:
--------------------------------------------------------------------------------
1 | #
2 | # after.sh for DEBIAN and TYPE=server
3 | #
4 |
5 |
6 | #
7 | # Edit local fail2ban customizations for jail.conf
8 | #
9 |
10 | echo_step " Edit fail2ban customizations for jail.conf"
11 | cat > "/etc/fail2ban/jail.local" <>"$INSTALL_LOG" 2>&1
8 | if [ "$?" -ne 0 ]; then
9 | echo_warning "Failed to install signing key, will attempt to continue"
10 | else
11 | echo_success
12 | fi
13 |
14 | # Add the Spotify repository
15 | echo_step " Installing Spotify repository"
16 | echo "deb http://repository.spotify.com stable non-free" | tee "/etc/apt/sources.list.d/spotify.list" >>"$INSTALL_LOG" 2>&1
17 | if [ "$?" -ne 0 ]; then
18 | echo_warning "Failed to install repositories, will attempt to continue"
19 | else
20 | echo_success
21 | fi
22 |
23 | # Update list of available packages
24 | echo_step " Update list of available packages"
25 | apt-get update >>"$INSTALL_LOG" 2>&1
26 | if [ "$?" -ne 0 ]; then
27 | echo_warning "Failed to install repositories, will attempt to continue"
28 | else
29 | echo_success
30 | fi
--------------------------------------------------------------------------------
/base/DEBIAN/workstation/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for DEBIAN and TYPE=workstation
3 | #
4 | # One package per line
5 | imagemagick
6 | jhead
7 | vlc
8 | spotify-client
9 |
--------------------------------------------------------------------------------
/base/FREEBSD/README.md:
--------------------------------------------------------------------------------
1 | # FreeBSD
2 |
3 | Bash is not included in the default installation. Instead, FreeBSD uses `tcsh` as the default root shell, and the Bourne shell-compatible `sh` as the default user shell.
4 | Generally shell scripts written for `sh` will run in Bash, but the reverse is not always true.
5 |
6 | So you have to install Bash.
7 |
8 | ## Using pkg for Binary Package Management
9 |
10 | pkg is the FreeBSD package management tool.
11 | More details can be found at https://www.freebsd.org/doc/handbook/pkgng-intro.html
12 |
13 | ### Getting Started with pkg
14 |
15 | FreeBSD includes a bootstrap utility which can be used to download and install pkg, along with its manual pages.
16 |
17 | To bootstrap the system, run:
18 |
19 | # /usr/sbin/pkg
20 |
21 | For earlier FreeBSD versions, pkg must instead be installed from the Ports Collection or as a binary package.
22 |
23 | To install the port, run:
24 |
25 | # cd /usr/ports/ports-mgmt/pkg
26 | # make
27 | # make install clean
28 |
29 | ### Install bash
30 |
31 | # pkg install bash
32 | # ln -s /usr/local/bin/bash /bin/bash
33 |
34 | ### Install curl
35 |
36 | # pkg install curl
37 |
--------------------------------------------------------------------------------
/base/FREEBSD/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for FREEBSD and all TYPEs
3 | #
4 | # One package per line
5 | screen
6 | nano
7 | git
8 |
--------------------------------------------------------------------------------
/base/HAIKU/README.md:
--------------------------------------------------------------------------------
1 | # Haiku
2 |
3 | Haiku is a free and open-source operating system compatible with the now discontinued BeOS.
4 |
5 | As of September 2013, Haiku includes a package management system called "Haiku Depot,"
6 | enabling software to be compiled into dependency tracking compressed packages.
7 |
8 | ## Using Package Management
9 |
10 | `pkgman` is a package management tool for Haiku.
11 |
12 | It is already installed in the standard. You do not have to do anything.
--------------------------------------------------------------------------------
/base/HAIKU/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for HAIKU and all TYPEs
3 | #
4 | # One package per line
5 | nano
6 | bezilla
7 |
--------------------------------------------------------------------------------
/base/MACOS/README.md:
--------------------------------------------------------------------------------
1 | # macOS
2 |
3 | macOS has no package manager in the standard installation.
4 |
5 | You must install a package manager.
6 |
7 | ## Using MacPorts for Binary Package Management
8 |
9 | `port` is a package management tool for macOS.
10 | More details can be found at https://www.macports.org/
11 |
12 |
13 | ## Using Homebrew for Binary Package Management
14 |
15 | `brew` is a package management tool for macOS.
16 | More details can be found at http://brew.sh/
--------------------------------------------------------------------------------
/base/MACOS/after.sh:
--------------------------------------------------------------------------------
1 | #
2 | # after.sh for MACOS and all TYPEs
3 | #
4 |
5 |
6 | #
7 | # Set system defaults for macOS
8 | # https://github.com/mathiasbynens/dotfiles/blob/master/.macos
9 | #
10 |
11 | echo_step " Set system defaults for macOS"
12 |
13 | # Disable the sound effects on boot
14 | nvram SystemAudioVolume=" "
15 |
16 | # Reveal IP address, hostname, OS version, etc. when clicking the clock
17 | # in the login window
18 | defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
19 |
20 | # Restart automatically if the computer freezes
21 | systemsetup -setrestartfreeze on
22 |
23 | # Never go into computer sleep mode
24 | systemsetup -setcomputersleep Off > /dev/null
25 |
26 | # Set the timezone; see `sudo systemsetup -listtimezones` for other values
27 | systemsetup -settimezone "Europe/Berlin" > /dev/null
28 |
29 | # Show the /Volumes folder
30 | chflags nohidden /Volumes
31 |
32 | # Kill affected applications
33 | for app in "Dock" "Finder"; do
34 | killall "${app}" &> /dev/null
35 | done
36 |
37 | echo_success
38 |
39 |
40 | #
41 | # Trigger a Notification Center notification from an AppleScript
42 | #
43 |
44 | echo_step " Trigger a Notification Center notification"
45 | osascript -e 'display notification "Installation completed 👍 "' 2>&1
46 | if [ "$?" -ne 0 ]; then
47 | echo_warning "Failed to trigger notification, will attempt to continue"
48 | else
49 | echo_success
50 | fi
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/base/MAGEIA/README.md:
--------------------------------------------------------------------------------
1 | # Mageia
2 |
3 | Mageia is a Linux-based operating system, distributed as free and open source software. It is forked from the Mandriva Linux distribution.
4 |
5 | ## Using urpmi for Binary Package Management
6 |
7 | `urpmi` is a package management tool for Mageia.
8 |
9 | It is already installed in the standard. You do not have to do anything.
10 |
--------------------------------------------------------------------------------
/base/NETBSD/README.md:
--------------------------------------------------------------------------------
1 | # NetBSD
2 |
3 | ## Using pkg_add for Binary Package Management
4 |
5 | pkg_add is the NetBSD package management tool.
6 | More details can be found at https://www.netbsd.org/docs/pkgsrc/using.html#installing-binary-packages
7 |
--------------------------------------------------------------------------------
/base/OPENBSD/README.md:
--------------------------------------------------------------------------------
1 | # OpenBSD
2 |
3 | Bash is not included in the default installation. Instead, OpenBSD uses `ksh` as the default shell.
4 |
5 | So you have to install Bash.
6 |
7 | ## Using pkg_add for Binary Package Management
8 |
9 | pkg_add_ is the OpenBSD package management tool.
10 | More details can be found at http://man.openbsd.org/pkg_add
11 |
12 | ### Install bash
13 |
14 | # pkg_add -I bash
15 | # ln -s /usr/local/bin/bash /bin/bash
16 |
17 | ### Install curl
18 |
19 | # pkg_add -I curl
--------------------------------------------------------------------------------
/base/OPENBSD/after.sh:
--------------------------------------------------------------------------------
1 | #
2 | # after.sh for OPENBSD and all TYPEs
3 | #
4 |
5 |
6 | # Download and load new PF (Firewall) ruleset
7 | # PF is enabled by default. If you wish to disable it on boot, use the rcctl tool to do so:
8 | # rcctl disable pf
9 |
10 | cp "/etc/pf.conf" "/etc/pf.conf.$OPERATING_SYSTEM"
11 |
12 | # Download /etc/pf.conf
13 | echo_step " Download new PF (Firewall) ruleset"
14 | echo -e "\n $FETCHER $BASE/$OPERATING_SYSTEM/pf.conf -o /etc/pf.conf" >>"$INSTALL_LOG"
15 | $FETCHER "$BASE/$OPERATING_SYSTEM/pf.conf" -o "/etc/pf.conf"
16 | if [ "$?" -ne 0 ]; then
17 | echo_warning "Failed, will attempt to continue"
18 | else
19 | echo_success
20 | fi
21 |
22 | # Load new ruleset
23 | echo_step " Load the pf.conf file"
24 | echo -e "\n pfctl -f /etc/pf.conf" >>"$INSTALL_LOG"
25 | pfctl -f "/etc/pf.conf" >>"$INSTALL_LOG" 2>&1
26 | if [ "$?" -ne 0 ]; then
27 | echo_warning "Failed, will attempt to continue"
28 | else
29 | echo_success
30 | fi
31 |
32 |
33 | # Build htop from source
34 | # Check out the latest version at the project page
35 | # https://hisham.hm/htop/releases/
36 | HTOP_RELEASE="2.0.2"
37 |
38 | echo_step " Build htop from source"
39 | curl -sf "https://hisham.hm/htop/releases/$HTOP_RELEASE/htop-$HTOP_RELEASE.tar.gz" -o "/tmp/htop.tar.gz"
40 | if [ -f "/tmp/htop.tar.gz" ]; then
41 | {
42 | gunzip "/tmp/htop.tar.gz"
43 | mkdir "/tmp/htop"
44 | tar -xvf "/tmp/htop.tar" -C "/tmp/htop"
45 | cd /tmp/htop/htop*/ || return
46 | ./configure -q
47 | make
48 | make install
49 | cd ~- || return
50 | } >>"$INSTALL_LOG" 2>&1
51 | else
52 | echo_warning "Failed to download, will attempt to continue"
53 | fi
54 | if command_exists htop; then
55 | echo_success
56 | else
57 | echo_warning "Failed to build, will attempt to continue"
58 | fi
--------------------------------------------------------------------------------
/base/OPENBSD/before.sh:
--------------------------------------------------------------------------------
1 | #
2 | # before.sh for OPENBSD and all TYPEs
3 | #
4 |
5 | #
6 | # Search last screen version and remember for installation
7 | #
8 | # OpenBSD has two screen flavors:
9 | # static - Build with statically linked binaries.
10 | # shm - export screen as shared memory, useful for brltty.
11 | #
12 | # During the installation you have to specify the __exact__ version.
13 | #
14 | # I want the static version
15 | #
16 | echo_step " Search last screen version"
17 | if SCREEN_VERSION=$(curl -fs "http://ftp.eu.openbsd.org/pub/OpenBSD/$(uname -r)/packages/$(uname -p)/" | sed -En 's/.*>(screen-.*[0-9]).tgz.*/\1/p'); then
18 | echo_step_info "$SCREEN_VERSION"
19 | echo "$SCREEN_VERSION" >> $PACKAGES_LIST
20 | echo_success
21 | else
22 | echo_warning "Failed, will attempt to continue"
23 | fi
24 |
25 | #
26 | # Search last mutt version without flavor and remember for installation
27 | #
28 | echo_step " Search last mutt version"
29 | if MUTT_VERSION=$(curl -fs "http://ftp.eu.openbsd.org/pub/OpenBSD/$(uname -r)/packages/$(uname -p)/" | sed -En 's/.*>(mutt-.*[0-9]).tgz.*/\1/p'); then
30 | echo_step_info "$MUTT_VERSION"
31 | echo "$MUTT_VERSION" >> $PACKAGES_LIST
32 | echo_success
33 | else
34 | echo_warning "Failed, will attempt to continue"
35 | fi
--------------------------------------------------------------------------------
/base/OPENBSD/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for OPENBSD and all TYPEs
3 | #
4 | # One package per line
5 | nano
6 | git
7 |
--------------------------------------------------------------------------------
/base/OPENBSD/pf.conf:
--------------------------------------------------------------------------------
1 | # /etc/pf.conf
2 | # https://www.openbsd.org/faq/pf/example1.html
3 |
4 | # pfctl -f /etc/pf.conf Load the pf.conf file
5 | # pfctl -nf /etc/pf.conf Parse the file, but don't load it
6 |
7 | # pfctl -d Diable the packet filter
8 | # pfctl -e Enable the packet filter
9 | # Note that it doesn't actually load a ruleset, however. The ruleset must be loaded separately
10 |
11 | # pfctl -s state Report on the currently running state table (very useful).
12 | # pfctl -sr Show the current ruleset
13 | # pfctl -ss Show the current state table
14 | # pfctl -si Show filter stats and counters
15 | # pfctl -sa Show EVERYTHING it can show
16 |
17 | ## FILTER RULES
18 |
19 | set block-policy drop
20 | # The egress keyword automatically chooses the interface that holds the default route, or the em0 WAN interface in our example
21 | set loginterface egress
22 | set skip on lo0
23 |
24 | # Block everything (inbound AND outbound on ALL interfaces) by default (catch-all)
25 | block all
26 |
27 | pass out quick inet
28 |
29 | # SSH
30 | pass in on egress inet proto tcp from any to (egress) port { 22 222 }
31 |
32 | # Ping
33 | pass in on egress inet proto icmp all icmp-type 8 code 0 keep state
34 |
--------------------------------------------------------------------------------
/base/OPENWRT/README.md:
--------------------------------------------------------------------------------
1 | # OpenWRT
2 |
3 | ## Using opkg for Binary Package Management
4 |
5 | opkg is the OpenWRT package management tool.
6 | More details can be found at https://wiki.openwrt.org/doc/packages
7 |
--------------------------------------------------------------------------------
/base/PUPPY/README.md:
--------------------------------------------------------------------------------
1 | # Puppy Linux
2 |
3 | Puppy Linux is an operating system and family of light-weight Linux distributions that focus on ease of use and minimal memory footprint.
4 |
5 | ## Using Package Management
6 |
7 | `pkg` is a package management tool for Puppy Linux.
8 | You must install this package manager.
9 | More details can be found at https://gitlab.com/sc0ttj/Pkg
10 |
--------------------------------------------------------------------------------
/base/PUPPY/before.sh:
--------------------------------------------------------------------------------
1 | #
2 | # before.sh for PUPPY and ALL types
3 | #
4 |
5 | # Add user's .ssh directory
6 | echo_step " Make user's .ssh"
7 | mkdir -p "$(getent passwd "$MY_USERNAME" | cut -d: -f6)/.ssh"
8 | if [ "$?" -ne 0 ]; then
9 | echo_warning "Failed to create, will attempt to continue"
10 | else
11 | echo_success
12 | fi
13 |
--------------------------------------------------------------------------------
/base/REDHAT/README.md:
--------------------------------------------------------------------------------
1 | # Red Hat
2 |
3 | CentOS and Fedora also belong to this category.
4 |
5 | ## Using DNF for Binary Package Management
6 |
7 | `dnf` is a package management tool for Red Hat and other Linux distributions.
8 |
9 | It is already installed in the standard. You do not have to do anything.
10 |
11 | ## Using Yum for Binary Package Management
12 |
13 | `yum` is a package management tool for Red Hat and other Linux distributions.
14 |
15 | It is already installed in the standard. You do not have to do anything.
--------------------------------------------------------------------------------
/base/REDHAT/after.sh:
--------------------------------------------------------------------------------
1 | #
2 | # after.sh for REDHAT and ALL types
3 | #
4 |
5 |
6 | #
7 | # Set the swappiness
8 | # https://en.wikipedia.org/wiki/Swappiness
9 | #
10 |
11 | echo_step " Set the swappiness (vm.swappiness=10)"
12 | echo "vm.swappiness=10" >> "/etc/sysctl.conf"
13 | echo_success
14 |
--------------------------------------------------------------------------------
/base/REDHAT/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for REDHAT and all TYPEs
3 | #
4 | # One package per line
5 | net-tools
6 | screen
7 | nano
8 |
--------------------------------------------------------------------------------
/base/REDHAT/server/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for REDHAT and TYPE=server
3 | #
4 | # One package per line
5 | openssh-server
6 |
--------------------------------------------------------------------------------
/base/REDHAT/workstation/before.sh:
--------------------------------------------------------------------------------
1 | #
2 | # before.sh for REDHAT and TYPE=workstation
3 | #
4 |
5 | # Add RPMFusion for ffmpeg-libs
6 | echo_step " Installing RPM Fusion free and nonfree repositories"
7 | $MY_INSTALLER $MY_INSTALL "https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm" \
8 | "https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm" >>"$INSTALL_LOG" 2>&1
9 | if [ "$?" -ne 0 ]; then
10 | echo_warning "Failed to install repositories, will attempt to continue"
11 | else
12 | echo_success
13 | fi
14 |
15 | # Add negativo17.org for spotify-client
16 | echo_step " Installing negativo17.org repositories for Spotify"
17 |
18 | dnf config-manager --add-repo="https://negativo17.org/repos/fedora-spotify.repo" >>"$INSTALL_LOG" 2>&1
19 | if [ "$?" -ne 0 ]; then
20 | echo_warning "Failed to install repositories, will attempt to continue"
21 | else
22 | echo_success
23 | fi
--------------------------------------------------------------------------------
/base/REDHAT/workstation/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for REDHAT and TYPE=workstation
3 | #
4 | # One package per line
5 | ImageMagick
6 | jhead
7 | vlc
8 | fuse-exfat
9 | gvfs-smb
10 | firefox
11 | filezilla
12 | keepassx
13 | gedit
14 | xpdf
15 | nmap
16 | ffmpeg-libs
17 | spotify-client
--------------------------------------------------------------------------------
/base/SLACKWARE/README.md:
--------------------------------------------------------------------------------
1 | # Slackware
2 |
3 | Slackware is the oldest Linux distribution that is still maintained.
4 |
5 | ## slackpkg
6 |
7 | `slackpkg` is a for installing or upgrading packages for Slackware.
8 |
--------------------------------------------------------------------------------
/base/SLACKWARE/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for SLACKWARE and all TYPEs
3 | #
4 | # One package per line
5 | ncurses
6 |
--------------------------------------------------------------------------------
/base/SUSE/README.md:
--------------------------------------------------------------------------------
1 | # SUSE
2 |
3 | The openSUSE Linux distribution also belong to this category.
4 |
5 | ## Using ZYpp for Binary Package Management
6 |
7 | `zypper` is a package management tool for SUSE and other Linux distributions.
8 |
9 | It is already installed in the standard. You do not have to do anything.
--------------------------------------------------------------------------------
/base/SUSE/after.sh:
--------------------------------------------------------------------------------
1 | #
2 | # after.sh for SUSE and ALL types
3 | #
4 |
5 |
6 | #
7 | # Set the swappiness
8 | # https://en.wikipedia.org/wiki/Swappiness
9 | #
10 |
11 | echo_step " Set the swappiness (vm.swappiness=10)"
12 | echo "vm.swappiness=10" >> "/etc/sysctl.conf"
13 | echo_success
14 |
--------------------------------------------------------------------------------
/base/SUSE/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for SUSE and all TYPEs
3 | #
4 | # One package per line
5 | screen
6 | nano
7 | git
8 |
--------------------------------------------------------------------------------
/base/TERMUX/README.md:
--------------------------------------------------------------------------------
1 | # Termux
2 |
3 | Termux is an Android terminal app and Linux environment.
4 |
5 | ## Using Package Management
6 |
7 | Termux uses `apt` and `dpkg` for package management, similar to Ubuntu or Debian.
8 |
9 | More details can be found at https://wiki.termux.com/wiki/Package_Management
10 |
11 | ### Installing packages
12 |
13 | Make sure the local package index cache is up-to-date by running:
14 |
15 | `apt update`
16 |
17 | To install apache2 web server:
18 |
19 | `apt install apache2`
20 |
21 | Or you can use pkg wrapper, which updates the package cache before installing:
22 |
23 | `pkg install apache2`
24 |
25 | Manually downloaded .deb files can be installed using:
26 |
27 | `apt install ./apache2_2.4.26_arm.deb`
28 |
29 | or directly using dpkg:
30 |
31 | `dpkg -i ./apache2_2.4.26_arm.deb`
--------------------------------------------------------------------------------
/base/TERMUX/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for TERMUX and all TYPEs
3 | #
4 | # One package per line
5 | nano
6 | screen
7 | openssh
--------------------------------------------------------------------------------
/base/after.sh:
--------------------------------------------------------------------------------
1 | #
2 | # after.sh for all OPERATING_SYSTEMs and TYPEs
3 | #
4 |
5 |
6 | #
7 | # User Configuration
8 | #
9 |
10 | # Variable $MY_USERNAME is defined in /before.sh
11 |
12 | # Create private SSH key
13 | echo_step " Creating private SSH key"
14 | echo_step_info "~$MY_USERNAME/.ssh/id_rsa"
15 | {
16 | echo -e "\n test dir /Users/$MY_USERNAME"
17 | echo -e "\n test dir /data/data/com.termux/files/home"
18 | echo -e "\n test dir /boot/home"
19 | echo -e "\n test dir /home/$MY_USERNAME"
20 | echo -e "\n test file ~$MY_USERNAME/.ssh/id_rsa"
21 | echo -e "\n test dir ~$MY_USERNAME"
22 | } >>"$INSTALL_LOG"
23 | # macOS
24 | if [ -d "/Users/$MY_USERNAME" ]; then
25 | export HOMEDIR="/Users/$MY_USERNAME"
26 | # Termux
27 | elif [ -d "/data/data/com.termux/files/home" ]; then
28 | export HOMEDIR="/data/data/com.termux/files/home"
29 | # Haiku
30 | elif [ "$OPERATING_SYSTEM" = "HAIKU" ]; then
31 | export HOMEDIR="/boot/home"
32 | # *nix
33 | else
34 | export HOMEDIR="/home/$MY_USERNAME"
35 | fi
36 | if [ -f "$HOMEDIR/.ssh/id_rsa" ]; then
37 | echo_warning "'SSH key already exists, will not generate new ones'"
38 | elif [ -d "$HOMEDIR" ]; then
39 | {
40 | echo -e "\n mkdir $HOMEDIR/.ssh"
41 | mkdir "$HOMEDIR/.ssh"
42 | echo -e "\n ssh-keygen" >>"$INSTALL_LOG"
43 | echo -e 'y\n'|ssh-keygen -q -t rsa -b 4096 -f "$HOMEDIR/.ssh/id_rsa" -N ""
44 | } >>"$INSTALL_LOG" 2>&1
45 | if [ "$?" -ne 0 ]; then
46 | echo_warning "Failed, will attempt to continue"
47 | else
48 | {
49 | echo -e "\n chown -R $MY_USERNAME:$MY_PRIMARY_GROUP $HOMEDIR/.ssh"
50 | chown -R "$MY_USERNAME":"$MY_PRIMARY_GROUP" "$HOMEDIR/.ssh"
51 | echo -e "\n chmod 700 $HOMEDIR/.ssh"
52 | chmod 700 "$HOMEDIR/.ssh"
53 | echo -e "\n chmod 600 $HOMEDIR/.ssh/id_rsa"
54 | chmod 600 "$HOMEDIR/.ssh/id_rsa "
55 | } >>"$INSTALL_LOG" 2>&1
56 | echo_success
57 | fi
58 | else
59 | echo_warning "Failed, will attempt to continue"
60 | fi
61 |
62 |
63 | #
64 | # bashrc for root
65 | #
66 |
67 | if [ -d "/root" ]; then
68 | echo_step " Set .bashrc for root"
69 | if [ -w "/root" ]; then
70 | if [ -f "/root/.bashrc" ]; then
71 | cp "/root/.bashrc" "/root/.bashrc.$OPERATING_SYSTEM"
72 | fi
73 | cat >> "/root/.bashrc" << EOF
74 |
75 | # Set RED prompt
76 | PS1='\[\033[01;31m\]\u@\h \[\033[01;34m\]\W # \[\033[00m\]'; export PS1
77 |
78 | # Define nano as our default EDITOR
79 | export EDITOR='nano'
80 |
81 | export LC_CTYPE='en_US.UTF-8'
82 | export LC_ALL='en_US.UTF-8'
83 |
84 | EOF
85 | echo_success
86 | else
87 | echo_warning "Can not write to /root, will attempt to continue"
88 | fi
89 | fi
--------------------------------------------------------------------------------
/base/before.sh:
--------------------------------------------------------------------------------
1 | #
2 | # before.sh for all OPERATING_SYSTEMs and TYPEs
3 | #
4 |
5 |
6 | #
7 | # User Configuration
8 | #
9 |
10 | # My default username
11 | export MY_USERNAME='nils'
12 | export MY_USERNAME_COMMENT='Nils K.'
13 |
14 | # Override the username when the script runs under...
15 | # Termux (Android)
16 | if [ "$OPERATING_SYSTEM" = "TERMUX" ]; then
17 | MY_USERNAME=$(whoami)
18 | echo -e "\nTermux username $MY_USERNAME" >>"$INSTALL_LOG"
19 | fi
20 | # Haiku
21 | if [ "$OPERATING_SYSTEM" = "HAIKU" ]; then
22 | MY_USERNAME=$(whoami)
23 | echo -e "\Haiku username $MY_USERNAME" >>"$INSTALL_LOG"
24 | fi
25 |
26 | # Check if user exists, if not create user and add to group wheel (for sudo)
27 | if id -u "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1; then
28 | echo -e "\nuser $MY_USERNAME found" >>"$INSTALL_LOG"
29 | else
30 | echo -e "\ncreate new user $MY_USERNAME" >>"$INSTALL_LOG"
31 | echo_step " Create user and add to group 'wheel'"
32 | echo_step_info "$MY_USERNAME"
33 | case $OPERATING_SYSTEM in
34 | ARCH)
35 | if command_exists useradd; then
36 | if useradd --shell "/bin/bash" --password "paqemd8ny15g2" --comment "$MY_USERNAME_COMMENT" --create-home --user-group "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1; then
37 | if grep "wheel" /etc/group >> "$INSTALL_LOG" 2>&1; then
38 | usermod -a -G wheel "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1
39 | fi
40 | echo_success
41 | else
42 | echo_warning "User '$MY_USERNAME' could not be created, will attempt to continue"
43 | fi
44 | else
45 | echo_warning "Command 'useradd' not found, will attempt to continue"
46 | fi
47 | ;;
48 | DEBIAN)
49 | if command_exists adduser; then
50 | if adduser --shell "/bin/bash" --disabled-password --gecos "$MY_USERNAME_COMMENT" --quiet "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1; then
51 | if grep "wheel" /etc/group >> "$INSTALL_LOG" 2>&1; then
52 | usermod -a -G wheel "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1
53 | fi
54 | echo_success
55 | else
56 | echo_warning "User '$MY_USERNAME' could not be created, will attempt to continue"
57 | fi
58 | else
59 | echo_warning "Command 'adduser' not found, will attempt to continue"
60 | fi
61 | ;;
62 | REDHAT)
63 | if command_exists adduser; then
64 | if adduser --shell "/bin/bash" --password "paqemd8ny15g2" --comment "$MY_USERNAME_COMMENT" --create-home --user-group "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1; then
65 | if grep "wheel" /etc/group >> "$INSTALL_LOG" 2>&1; then
66 | usermod -a -G wheel "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1
67 | fi
68 | echo_success
69 | else
70 | echo_warning "User '$MY_USERNAME' could not be created, will attempt to continue"
71 | fi
72 | else
73 | echo_warning "Command 'adduser' not found, will attempt to continue"
74 | fi
75 | ;;
76 | SUSE)
77 | if command_exists useradd; then
78 | if useradd --shell "/bin/bash" --password "paqemd8ny15g2" --comment "$MY_USERNAME_COMMENT" --create-home --user-group "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1; then
79 | if grep "wheel" /etc/group >> "$INSTALL_LOG" 2>&1; then
80 | usermod -a -G wheel "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1
81 | fi
82 | echo_success
83 | else
84 | echo_warning "User '$MY_USERNAME' could not be created, will attempt to continue"
85 | fi
86 | else
87 | echo_warning "Command 'useradd' not found, will attempt to continue"
88 | fi
89 | ;;
90 | FREEBSD)
91 | if command_exists pw; then
92 | if pw user add "$MY_USERNAME" -s "/usr/local/bin/bash" -m -c "$MY_USERNAME_COMMENT" -q >> "$INSTALL_LOG" 2>&1; then
93 | if grep "wheel" /etc/group >> "$INSTALL_LOG" 2>&1; then
94 | pw groupmod wheel -m "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1
95 | fi
96 | echo_success
97 | else
98 | echo_warning "User '$MY_USERNAME' could not be created, will attempt to continue"
99 | fi
100 | else
101 | echo_warning "Command 'pw' not found, will attempt to continue"
102 | fi
103 | ;;
104 | *)
105 | echo -e "\n No USERADD option for OS '$OPERATING_SYSTEM'" >>"$INSTALL_LOG"
106 | echo_warning "User '$MY_USERNAME' could not be created, will attempt to continue"
107 | ;;
108 | esac
109 |
110 | # Change password
111 | if id -u "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1; then
112 | if [ -z "$CI" ]; then
113 | echo_step " Change password"
114 | echo
115 | echo
116 | echo -e "\n passwd $MY_USERNAME" >>"$INSTALL_LOG"
117 | passwd "$MY_USERNAME"
118 | echo
119 | else
120 | echo "!!! CI detected. No password change !!!" >>"$INSTALL_LOG"
121 | fi
122 | fi
123 | fi
124 |
125 | # Get primary user group from user
126 | echo_step " Get primary user group from user"
127 | echo_step_info "$MY_USERNAME"
128 | echo -e "\nid -gn $MY_USERNAME" >>"$INSTALL_LOG"
129 | if id -gn "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1; then
130 | MY_PRIMARY_GROUP=$(id -gn "$MY_USERNAME" >> "$INSTALL_LOG" 2>&1)
131 | export MY_PRIMARY_GROUP
132 | echo "primary user group from user $MY_USERNAME is $MY_PRIMARY_GROUP" >>"$INSTALL_LOG"
133 | echo_success
134 | else
135 | echo_warning "User '$MY_USERNAME' does not exist, will attempt to continue"
136 | fi
--------------------------------------------------------------------------------
/base/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for all OPERATING_SYSTEMs and TYPEs
3 | #
4 | # One package per line
5 | htop
6 | tmux
7 |
--------------------------------------------------------------------------------
/base/server/after.sh:
--------------------------------------------------------------------------------
1 | #
2 | # after.sh for all OPERATING_SYSTEMs and TYPE=server
3 | #
4 |
5 | #
6 | # Generate new SSH Daemon Keys
7 | #
8 |
9 | # SSH Daemon Configuration Directory, without / at the end
10 | SSHD_KEY_DIR="/etc/ssh"
11 | # Specifies the types of keys to create
12 | SSHD_KEY_TYPES=("ed25519" "rsa")
13 |
14 | if [ -d "$SSHD_KEY_DIR" ]; then
15 | echo_step " Generating new SSH Daemon Keys in $SSHD_KEY_DIR (please wait)"; echo
16 |
17 | # Delete old keys
18 | echo -e "\n rm $SSHD_KEY_DIR/ssh_host_*" >>"$INSTALL_LOG"
19 | rm "$SSHD_KEY_DIR"/ssh_host_* >> "$INSTALL_LOG" 2>&1
20 |
21 | for SSHD_KEY_TYPE in ${SSHD_KEY_TYPES[*]}; do
22 | echo_step " $SSHD_KEY_TYPE"
23 | echo -e "\nsshd key type $SSHD_KEY_TYPE" >>"$INSTALL_LOG"
24 | if [ "$SSHD_KEY_TYPE" == "rsa1" ]; then
25 | SSHD_KEY_FILE="ssh_host_key"
26 | else
27 | SSHD_KEY_FILE="ssh_host_"
28 | SSHD_KEY_FILE+="$SSHD_KEY_TYPE"
29 | SSHD_KEY_FILE+="_key"
30 | fi
31 | # Be advised that using keys stronger than 8192 bits with certificates will cause some versions of OpenSSH to ignore keys and fail.
32 | # Some older versions may even be limited to 4096 bits.
33 | echo -e 'y\n'|ssh-keygen -q -b 8192 -t "$SSHD_KEY_TYPE" -f "$SSHD_KEY_DIR/$SSHD_KEY_FILE" -N "" >>"$INSTALL_LOG" 2>&1
34 | if [ "$?" -ne 0 ]; then
35 | echo_warning "Failed, will attempt to continue"
36 | else
37 | echo_success
38 | fi
39 | done
40 | fi
41 |
42 |
43 | #
44 | # SSH Daemon Configuration
45 | #
46 |
47 | SSHD_CONF_FILE="/etc/ssh/sshd_config"
48 | SSHD_CONF_PORT="222"
49 |
50 | if [ -f "$SSHD_CONF_FILE" ]; then
51 | echo_step " Modifying SSH Daemon Configuration File at $SSHD_CONF_FILE"; echo
52 |
53 | cp "$SSHD_CONF_FILE" "$SSHD_CONF_FILE.$OPERATING_SYSTEM"
54 |
55 | # Reconfigure SSH Daemon Port
56 | echo_step " Port $SSHD_CONF_PORT"
57 | if grep -q ^#Port "$SSHD_CONF_FILE"; then
58 | # Remove comment (#) and change port
59 | perl -i -pe "s,^#Port.*,Port $SSHD_CONF_PORT,g" "$SSHD_CONF_FILE"
60 | fi
61 | if grep -q ^Port "$SSHD_CONF_FILE"; then
62 | # Change port
63 | perl -i -pe "s,^Port.*,Port $SSHD_CONF_PORT,g" "$SSHD_CONF_FILE"
64 | else
65 | # Add port
66 | echo "Port $SSHD_CONF_PORT" >> "$SSHD_CONF_FILE"
67 | fi
68 | if [ "$?" -ne 0 ]; then
69 | echo_warning "Failed, will attempt to continue"
70 | else
71 | echo_success
72 | fi
73 |
74 | echo_step " Protocol 2"
75 | if grep -q ^#Protocol "$SSHD_CONF_FILE"; then
76 | perl -i -pe "s,^#Protocol.*,Protocol 2,g" "$SSHD_CONF_FILE"
77 | else
78 | perl -i -pe "s,^Protocol.*,Protocol 2,g" "$SSHD_CONF_FILE"
79 | fi
80 | if [ "$?" -ne 0 ]; then
81 | echo_warning "Failed, will attempt to continue"
82 | else
83 | echo_success
84 | fi
85 |
86 | echo_step " PermitRootLogin no"
87 | if grep -q ^#PermitRootLogin "$SSHD_CONF_FILE"; then
88 | perl -i -pe "s,^#PermitRootLogin.*,PermitRootLogin no,g" "$SSHD_CONF_FILE"
89 | else
90 | perl -i -pe "s,^PermitRootLogin.*,PermitRootLogin no,g" "$SSHD_CONF_FILE"
91 | fi
92 | if [ "$?" -ne 0 ]; then
93 | echo_warning "Failed, will attempt to continue"
94 | else
95 | echo_success
96 | fi
97 | fi
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/base/workstation/packages.list:
--------------------------------------------------------------------------------
1 | #
2 | # packages.list for all OPERATING_SYSTEMs and TYPE=workstation
3 | #
4 | # One package per line
5 | git
6 |
--------------------------------------------------------------------------------
/img/WSL_Screenshot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cyclenerd/postinstall/e73f5fa345eb1e71114a4700814de37930473959/img/WSL_Screenshot.jpg
--------------------------------------------------------------------------------
/postinstall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #shellcheck disable=SC2181
3 |
4 | # postinstall.sh
5 | # Author: Nils Knieling - https://github.com/Cyclenerd/postinstall
6 | # Inspired by: Wavefront - https://github.com/wavefrontHQ/install
7 |
8 | # Bash Script to automate post-installation steps. Helps to
9 | # install packages
10 | # on different operating systems.
11 |
12 | ################################################################################
13 | #### Configuration Section
14 | ################################################################################
15 |
16 | # Where is the default base url or dir. Without / at the end
17 | # Filesystem directory: BASE="/Users/nils/Scripts/postinstall/base"
18 | # Web: BASE="https://raw.githubusercontent.com/Cyclenerd/postinstall/master/base"
19 | # Can be overwritten with -b at runtime
20 | BASE="https://raw.githubusercontent.com/Cyclenerd/postinstall/master/base"
21 |
22 | # Default type of installation
23 | # Can be overwritten with -t at runtime
24 | TYPE="server"
25 |
26 | ################################################################################
27 | #### END Configuration Section
28 | ################################################################################
29 |
30 | ME=$(basename "$0")
31 | DATETIME=$(date "+%Y-%m-%d-%H-%M-%S")
32 | MY_INSTALL="install"
33 |
34 | if [[ ! $LC_CTYPE ]]; then
35 | export LC_CTYPE='en_US.UTF-8'
36 | fi
37 | if [[ ! $LC_ALL ]]; then
38 | export LC_ALL='en_US.UTF-8'
39 | fi
40 |
41 |
42 | ################################################################################
43 | # Usage
44 | ################################################################################
45 |
46 | function usage {
47 | returnCode="$1"
48 | echo -e "Usage: $ME [-t ] [-b ] [-h]:
49 | [-t ]\t sets the type of installation (default: $TYPE)
50 | [-b ]\t sets the base url or dir (default: $BASE)
51 | [-h]\t\t displays help (this message)"
52 | exit "$returnCode"
53 | }
54 |
55 | ################################################################################
56 | # Terminal output helpers
57 | ################################################################################
58 |
59 | # echo_equals() outputs a line with =
60 | # seq does not exist under OpenBSD
61 | function echo_equals() {
62 | COUNTER=0
63 | while [ $COUNTER -lt "$1" ]; do
64 | printf '='
65 | (( COUNTER=COUNTER+1 ))
66 | done
67 | }
68 |
69 | # echo_title() outputs a title padded by =, in yellow.
70 | function echo_title() {
71 | TITLE=$1
72 | NCOLS=$(tput cols)
73 | NEQUALS=$(((NCOLS-${#TITLE})/2-1))
74 | tput setaf 3 0 0 # 3 = yellow
75 | echo_equals "$NEQUALS"
76 | printf " %s " "$TITLE"
77 | echo_equals "$NEQUALS"
78 | tput sgr0 # reset terminal
79 | echo
80 | }
81 |
82 | # echo_step() outputs a step collored in cyan, without outputing a newline.
83 | function echo_step() {
84 | tput setaf 6 0 0 # 6 = cyan
85 | echo -n "$1"
86 | tput sgr0 # reset terminal
87 | }
88 |
89 | # echo_step_info() outputs additional step info in cyan, without a newline.
90 | function echo_step_info() {
91 | tput setaf 6 0 0 # 6 = cyan
92 | echo -n " ($1)"
93 | tput sgr0 # reset terminal
94 | }
95 |
96 | # echo_right() outputs a string at the rightmost side of the screen.
97 | function echo_right() {
98 | TEXT=$1
99 | echo
100 | tput cuu1
101 | tput cuf "$(tput cols)"
102 | tput cub ${#TEXT}
103 | echo "$TEXT"
104 | }
105 |
106 | # echo_failure() outputs [ FAILED ] in red, at the rightmost side of the screen.
107 | function echo_failure() {
108 | tput setaf 1 0 0 # 1 = red
109 | echo_right "[ FAILED ]"
110 | tput sgr0 # reset terminal
111 | }
112 |
113 | # echo_success() outputs [ OK ] in green, at the rightmost side of the screen.
114 | function echo_success() {
115 | tput setaf 2 0 0 # 2 = green
116 | echo_right "[ OK ]"
117 | tput sgr0 # reset terminal
118 | }
119 |
120 | # echo_warning() outputs a message and [ WARNING ] in yellow, at the rightmost side of the screen.
121 | function echo_warning() {
122 | tput setaf 3 0 0 # 3 = yellow
123 | echo_right "[ WARNING ]"
124 | tput sgr0 # reset terminal
125 | echo " ($1)"
126 | }
127 |
128 | # exit_with_message() outputs and logs a message before exiting the script.
129 | function exit_with_message() {
130 | echo
131 | echo "$1"
132 | echo -e "\n$1" >>"$INSTALL_LOG"
133 | if [[ $INSTALL_LOG && "$2" -eq 1 ]]; then
134 | echo "For additional information, check the install log: $INSTALL_LOG"
135 | fi
136 | echo
137 | debug_variables
138 | echo
139 | exit 1
140 | }
141 |
142 | # exit_with_failure() calls echo_failure() and exit_with_message().
143 | function exit_with_failure() {
144 | echo_failure
145 | exit_with_message "FAILURE: $1" 1
146 | }
147 |
148 |
149 | ################################################################################
150 | # Other helpers
151 | ################################################################################
152 |
153 | # debug_variables() print all script global variables to ease debugging
154 | debug_variables() {
155 | echo "USERNAME: $USERNAME"
156 | echo "SHELL: $SHELL"
157 | echo "BASH_VERSION: $BASH_VERSION"
158 | echo
159 | echo "BASE: $BASE"
160 | echo "TYPE: $TYPE"
161 | echo "HOSTNAME_FQDN: $HOSTNAME_FQDN"
162 | echo "OPERATING_SYSTEM: $OPERATING_SYSTEM"
163 | echo "OPERATING_SYSTEM_TYPE: $OPERATING_SYSTEM_TYPE"
164 | echo "ARCHITECTURE: $ARCHITECTURE"
165 | echo "INSTALL_LOG: $INSTALL_LOG"
166 | echo "MY_INSTALLER: $MY_INSTALLER"
167 | echo "MY_INSTALL: $MY_INSTALL"
168 | echo "PACKAGES_LIST: $PACKAGES_LIST"
169 | echo "BEFORE_SCRIPT: $BEFORE_SCRIPT"
170 | echo "AFTER_SCRIPT: $AFTER_SCRIPT"
171 | echo "FETCHER: $FETCHER"
172 | echo "ASSUME_ALWAYS_YES: $ASSUME_ALWAYS_YES"
173 | echo "SUDO_USER: $SUDO_USER"
174 | }
175 |
176 | # command_exists() tells if a given command exists.
177 | function command_exists() {
178 | command -v "$1" >/dev/null 2>&1
179 | }
180 |
181 | # check if the hostname can be resolved locally
182 | function detect_hostname_fqdn() {
183 | echo_step "Detecting FQDN"
184 | if hostname -f &>/dev/null; then
185 | echo -e "\nhostname -f" >>"$INSTALL_LOG"
186 | HOSTNAME_FQDN=$(hostname -f)
187 | echo_step_info "$HOSTNAME_FQDN"
188 | echo_success
189 | elif hostname &>/dev/null; then
190 | echo -e "\nhostname" >>"$INSTALL_LOG"
191 | HOSTNAME_FQDN=$(hostname)
192 | echo_step_info "$HOSTNAME_FQDN"
193 | echo_success
194 | else
195 | echo -e "\nhostname could not be determined" >>"$INSTALL_LOG"
196 | HOSTNAME_FQDN="foo.bar"
197 | echo_step_info "$HOSTNAME_FQDN"
198 | echo_warning "Hostname could not be determined, will attempt to continue"
199 | fi
200 | export HOSTNAME_FQDN
201 | }
202 |
203 | # check_if_root_or_die() verifies if the script is being run as root and exits
204 | # otherwise (i.e. die).
205 | function check_if_root_or_die() {
206 | echo_step "Checking installation privileges"
207 | echo -e "\nid -u" >>"$INSTALL_LOG"
208 | SCRIPT_UID=$(id -u)
209 | if [ "$OPERATING_SYSTEM" = "CYGWIN" ]; then
210 | # Administrator really isn't equivalent to POSIX root.
211 | echo_step_info "Cygwin, no need for root"
212 | elif [ "$OPERATING_SYSTEM" = "TERMUX" ]; then
213 | # Termux does nor supply tools for rooting.
214 | echo_step_info "Termux, no need for root"
215 | elif [ "$OPERATING_SYSTEM" = "HAIKU" ]; then
216 | # Haiku is a single-user system
217 | echo_step_info "Haiku, no need for root"
218 | elif [ "$SCRIPT_UID" != 0 ]; then
219 | exit_with_failure "$ME should be run as root"
220 | fi
221 | echo_success
222 | }
223 |
224 | # check_bash() check if current shell is bash
225 | function check_bash() {
226 | echo_step "Checking if current shell is bash"
227 | if [[ "$0" == *"bash" ]]; then
228 | exit_with_failure "Failed, your current shell is $0"
229 | fi
230 | echo_success
231 | }
232 |
233 | # check_fetcher() check if curl is installed
234 | function check_fetcher() {
235 | echo_step " Checking if curl is installed"
236 | if command_exists curl; then
237 | # -f = Fail silently (no output at all) on server errors (404, 301, ...).
238 | export FETCHER="curl -fs"
239 | else
240 | echo_step_info "Try to install curl"
241 | echo -e "\n$MY_INSTALLER $INSTALL curl" >>"$INSTALL_LOG"
242 | if $MY_INSTALLER $MY_INSTALL "curl" >>"$INSTALL_LOG" 2>&1; then
243 | export FETCHER="curl -fs"
244 | else
245 | exit_with_failure "'curl' is needed. Please install 'curl'. More details can be found at https://curl.haxx.se/"
246 | fi
247 | fi
248 | echo_success
249 | }
250 |
251 | # detect_architecture() obtains the system architecture
252 | function detect_architecture() {
253 | echo_step "Detecting architecture"
254 | echo -e "\nuname -m" >>"$INSTALL_LOG"
255 | ARCHITECTURE=$(uname -m)
256 | export ARCHITECTURE
257 | echo_step_info "$ARCHITECTURE"
258 | echo_success
259 | }
260 |
261 | # detect_operating_system() obtains the operating system and exits if it's not
262 | # one of: Debian, Ubuntu, Fedora, RedHat, CentOS, SuSE, macOS, FreeBSD or Cycwin
263 | function detect_operating_system() {
264 | echo_step "Detecting operating system"
265 | echo -e "\nuname" >>"$INSTALL_LOG"
266 | # https://en.wikipedia.org/wiki/Uname
267 | # Within the bash shell, the environment variable OSTYPE contains a value similar (but not identical) to the value of uname (-o)
268 | # macOS = uname -o: illegal option -- o
269 | OPERATING_SYSTEM_TYPE=$(uname)
270 | export OPERATING_SYSTEM_TYPE
271 | if [ -f /etc/debian_version ]; then
272 | echo -e "\ntest -f /etc/debian_version" >>"$INSTALL_LOG"
273 | echo_step_info "Debian/Ubuntu"
274 | OPERATING_SYSTEM="DEBIAN"
275 | elif [ -f /etc/arch-release ]; then
276 | echo -e "\ntest -f /etc/arch-release" >>"$INSTALL_LOG"
277 | echo_step_info "Arch Linux"
278 | OPERATING_SYSTEM="ARCH"
279 | elif [ -f /etc/slackware-version ]; then
280 | echo -e "\ntest -f /etc/slackware-version" >>"$INSTALL_LOG"
281 | echo_step_info "Slackware"
282 | OPERATING_SYSTEM="SLACKWARE"
283 | elif [ -f /etc/redhat-release ] || [ -f /etc/system-release-cpe ]; then
284 | echo -e "\ntest -f /etc/redhat-release || test -f /etc/system-release-cpe" >>"$INSTALL_LOG"
285 | echo_step_info "Red Hat / Fedora / CentOS"
286 | OPERATING_SYSTEM="REDHAT"
287 | elif [ -f /etc/SUSE-brand ] || [ -f /etc/SuSE-brand ] || [ -f /etc/SuSE-release ] || [ -d /etc/susehelp.d ]; then
288 | echo -e "\ntest -f /etc/SUSE-brand || test -f /etc/SuSE-brand || test -f /etc/SuSE-release || test -d /etc/susehelp.d" >>"$INSTALL_LOG"
289 | echo_step_info "SuSE"
290 | OPERATING_SYSTEM="SUSE"
291 | elif [ -f /System/Library/CoreServices/SystemVersion.plist ]; then
292 | echo -e "\ntest -f /System/Library/CoreServices/SystemVersion.plist" >>"$INSTALL_LOG"
293 | echo_step_info "macOS"
294 | OPERATING_SYSTEM="MACOS"
295 | elif [ "$OPERATING_SYSTEM_TYPE" = "FreeBSD" ]; then
296 | echo -e "\ntest OPERATING_SYSTEM_TYPE" >>"$INSTALL_LOG"
297 | echo_step_info "FreeBSD"
298 | OPERATING_SYSTEM="FREEBSD"
299 | # FreeBSD pkg automatically assume "yes"
300 | export ASSUME_ALWAYS_YES="yes"
301 | elif [ "$OPERATING_SYSTEM_TYPE" = "OpenBSD" ]; then
302 | echo -e "\ntest OPERATING_SYSTEM_TYPE" >>"$INSTALL_LOG"
303 | echo_step_info "OpenBSD"
304 | OPERATING_SYSTEM="OPENBSD"
305 | elif [ "$OPERATING_SYSTEM_TYPE" = "NetBSD" ]; then
306 | echo -e "\ntest OPERATING_SYSTEM_TYPE" >>"$INSTALL_LOG"
307 | echo_step_info "NetBSD"
308 | OPERATING_SYSTEM="NETBSD"
309 | elif [ "$OPERATING_SYSTEM_TYPE" = "OpenWRT" ]; then
310 | echo -e "\ntest OPERATING_SYSTEM_TYPE" >>"$INSTALL_LOG"
311 | echo_step_info "OpenWRT"
312 | OPERATING_SYSTEM="OPENWRT"
313 | elif [ "$OPERATING_SYSTEM_TYPE" = "Cygwin" ]; then
314 | echo -e "\ntest OPERATING_SYSTEM_TYPE" >>"$INSTALL_LOG"
315 | echo_step_info "Cygwin"
316 | OPERATING_SYSTEM="CYGWIN"
317 | elif [ "$OPERATING_SYSTEM_TYPE" = "Haiku" ]; then
318 | echo -e "\ntest OPERATING_SYSTEM_TYPE" >>"$INSTALL_LOG"
319 | echo_step_info "Haiku"
320 | OPERATING_SYSTEM="HAIKU"
321 | elif [ -d /data/data/com.termux/files/home ]; then
322 | echo -e "\ntest -d /data/data/com.termux/files/home" >>"$INSTALL_LOG"
323 | echo_step_info "Termux"
324 | OPERATING_SYSTEM="TERMUX"
325 | elif [ -f /etc/alpine-release ]; then
326 | echo -e "\ntest -f /etc/alpine-release " >>"$INSTALL_LOG"
327 | echo_step_info "Alpine Linux"
328 | OPERATING_SYSTEM="ALPINE"
329 | elif grep -lqs ^Mageia$ /etc/release; then
330 | echo -e "\ntest -f /etc/release " >>"$INSTALL_LOG"
331 | echo_step_info "Mageia"
332 | OPERATING_SYSTEM="MAGEIA"
333 | elif grep -lqs Puppy /etc/os-release; then
334 | echo -e "\ntest -f /etc/os-release " >>"$INSTALL_LOG"
335 | echo_step_info "Puppy"
336 | OPERATING_SYSTEM="PUPPY"
337 | else
338 | {
339 | echo -e "\ntest -f /etc/debian_version"
340 | echo -e "\ntest -f /etc/arch-release"
341 | echo -e "\ntest -f /etc/redhat-release || test -f /etc/system-release-cpe"
342 | echo -e "\ntest -f /etc/SUSE-brand || test -f /etc/SuSE-brand || test -f /etc/SuSE-release"
343 | echo -e "\ntest -f /System/Library/CoreServices/SystemVersion.plist"
344 | echo -e "\ntest OPERATING_SYSTEM_TYPE"
345 | echo -e "\ntest -d /data/data/com.termux/files/home"
346 |
347 | } >>"$INSTALL_LOG"
348 | exit_with_failure "Unsupported operating system"
349 | fi
350 | echo_success
351 | export OPERATING_SYSTEM
352 | }
353 |
354 | # detect_installer() obtains the operating system package management software and exits if it's not installed
355 | function detect_installer() {
356 | echo_step " Checking installation tools"
357 | case $OPERATING_SYSTEM in
358 | ARCH)
359 | if command_exists pacman; then
360 | echo -e "\npacman found" >>"$INSTALL_LOG"
361 | export MY_INSTALLER="pacman"
362 | export MY_INSTALL="-S --noconfirm"
363 | else
364 | exit_with_failure "Command 'pacman' not found"
365 | fi
366 | ;;
367 | DEBIAN)
368 | if command_exists apt-get; then
369 | echo -e "\napt-get found" >>"$INSTALL_LOG"
370 | export MY_INSTALLER="apt-get"
371 | export MY_INSTALL="-qq install"
372 | else
373 | exit_with_failure "Command 'apt-get' not found"
374 | fi
375 | ;;
376 | REDHAT)
377 | # https://fedoraproject.org/wiki/Dnf
378 | if command_exists dnf; then
379 | echo -e "\ndnf found" >>"$INSTALL_LOG"
380 | export MY_INSTALLER="dnf"
381 | export MY_INSTALL="-y install"
382 | # https://fedoraproject.org/wiki/Yum
383 | # As of Fedora 22, yum has been replaced with dnf.
384 | elif command_exists yum; then
385 | echo -e "\nyum found" >>"$INSTALL_LOG"
386 | export MY_INSTALLER="yum"
387 | export MY_INSTALL="-y install"
388 | else
389 | exit_with_failure "Either 'dnf' or 'yum' are needed"
390 | fi
391 | # RPM
392 | if command_exists rpm; then
393 | echo -e "\nrpm found" >>"$INSTALL_LOG"
394 | else
395 | exit_with_failure "Command 'rpm' not found"
396 | fi
397 | ;;
398 | SUSE)
399 | # https://en.opensuse.org/Zypper
400 | if command_exists zypper; then
401 | echo -e "\nzypper found" >>"$INSTALL_LOG"
402 | export MY_INSTALLER="zypper"
403 | export MY_INSTALL="install -y"
404 | else
405 | exit_with_failure "Command 'zypper' not found"
406 | fi
407 | ;;
408 | SLACKWARE)
409 | if command_exists slackpkg; then
410 | echo -e "\nslackpkg found" >>"$INSTALL_LOG"
411 | export MY_INSTALLER="slackpkg"
412 | export MY_INSTALL="install"
413 | else
414 | exit_with_failure "Command 'slackpkg' not found"
415 | fi
416 | ;;
417 | FREEBSD)
418 | # https://www.freebsd.org/doc/handbook/pkgng-intro.html
419 | if command_exists pkg; then
420 | echo -e "\npkg found" >>"$INSTALL_LOG"
421 | # pkg activation status check
422 | if [[ $(pkg -N) -ne 0 ]]; then
423 | exit_with_failure "pkg is not installed. Please run '/usr/sbin/pkg'"
424 | fi
425 | export MY_INSTALLER="pkg"
426 | export MY_INSTALL="install"
427 | else
428 | exit_with_failure "Command 'pkg' not found"
429 | fi
430 | ;;
431 | OPENBSD)
432 | # http://man.openbsd.org/pkg_add
433 | if command_exists pkg_add; then
434 | echo -e "\npkg_add found" >>"$INSTALL_LOG"
435 | export MY_INSTALLER="pkg_add"
436 | export MY_INSTALL="-I"
437 | else
438 | exit_with_failure "Command 'pkg_add' not found"
439 | fi
440 | ;;
441 | NETBSD)
442 | # https://www.netbsd.org/docs/pkgsrc/using.html#installing-binary-packages
443 | if command_exists pkg_add; then
444 | echo -e "\npkg_add found" >>"$INSTALL_LOG"
445 | export MY_INSTALLER="pkg_add"
446 | export MY_INSTALL="-I"
447 | else
448 | exit_with_failure "Command 'pkg_add' not found"
449 | fi
450 | ;;
451 | OPENWRT)
452 | # https://wiki.openwrt.org/doc/packages
453 | if command_exists opkg; then
454 | echo -e "\nopkg found" >>"$INSTALL_LOG"
455 | export MY_INSTALLER="opkg"
456 | export MY_INSTALL="install"
457 | else
458 | exit_with_failure "Command 'opkg' not found"
459 | fi
460 | ;;
461 | HAIKU)
462 | # https://www.haiku-os.org/guides/daily-tasks/updating-system/
463 | if command_exists pkgman; then
464 | echo -e "\npkgman found" >>"$INSTALL_LOG"
465 | export MY_INSTALLER="pkgman"
466 | export MY_INSTALL="install -y"
467 | else
468 | exit_with_failure "Command 'pkgman' not found"
469 | fi
470 | ;;
471 | TERMUX)
472 | # https://wiki.termux.com/wiki/Package_Management
473 | # https://github.com/termux/termux-packages/blob/master/packages/termux-tools/pkg
474 | if command_exists pkg; then
475 | echo -e "\npkg found" >>"$INSTALL_LOG"
476 | export MY_INSTALLER="pkg"
477 | export MY_INSTALL="install -y"
478 | else
479 | exit_with_failure "Command 'pkg' not found"
480 | fi
481 | ;;
482 | ALPINE)
483 | # https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management
484 | if command_exists apk; then
485 | echo -e "\apk found" >>"$INSTALL_LOG"
486 | export MY_INSTALLER="apk"
487 | export MY_INSTALL="add"
488 | else
489 | exit_with_failure "Command 'apk' not found"
490 | fi
491 | ;;
492 | CYGWIN)
493 | # https://github.com/transcode-open/apt-cyg
494 | if command_exists apt-cyg; then
495 | echo -e "\napt-cyg found" >>"$INSTALL_LOG"
496 | if command_exists wget; then
497 | echo -e "\wget found" >>"$INSTALL_LOG"
498 | else
499 | exit_with_failure "Command 'wget' not found. 'apt-cyg' requires 'wget'."
500 |
501 | fi
502 | export MY_INSTALLER="apt-cyg"
503 | export MY_INSTALL="install"
504 | else
505 | {
506 | echo
507 | echo "apt-cyg is a simple script. To install:"
508 | echo " curl -L -k rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg"
509 | echo " install apt-cyg /bin"
510 | echo
511 | } >>"$INSTALL_LOG"
512 | exit_with_failure "Command 'apt-cyg' not found. More details can be found at https://github.com/transcode-open/apt-cyg#quick-start"
513 | fi
514 | ;;
515 | MACOS)
516 | # https://www.macports.org/
517 | if command_exists port; then
518 | echo -e "\nport found" >>"$INSTALL_LOG"
519 | export MY_INSTALLER="port"
520 | export MY_INSTALL="-q install"
521 | # http://brew.sh/
522 | elif command_exists brew; then
523 | echo -e "\nbrew found" >>"$INSTALL_LOG"
524 | # Running Homebrew as root is extremely dangerous and no longer supported
525 | # Use SUDO_USER for Homebrew
526 | export MY_INSTALLER="sudo -u $SUDO_USER brew"
527 | export MY_INSTALL="install"
528 | else
529 | exit_with_failure "Either 'port' or 'brew' are needed. More details can be found at https://www.macports.org/install.php"
530 | fi
531 | # XCode and accept the end user license agreement
532 | if command_exists xcodebuild; then
533 | xcodebuild -license accept >>"$INSTALL_LOG" 2>&1
534 | else
535 | exit_with_failure "XCode not found. Install the latest XCode from the AppStore."
536 | fi
537 | ;;
538 | MAGEIA)
539 | # https://wiki.mageia.org/en/Installing_and_removing_software
540 | if command_exists urpmi; then
541 | echo -e "\nurpmi found" >>"$INSTALL_LOG"
542 | export MY_INSTALLER="urpmi"
543 | export MY_INSTALL="--force"
544 | else
545 | exit_with_failure "Command 'urpmi' not found"
546 | fi
547 | ;;
548 | PUPPY)
549 | # https://gitlab.com/sc0ttj/Pkg
550 | if command_exists pkg; then
551 | echo -e "\npkg found" >>"$INSTALL_LOG"
552 | export MY_INSTALLER="pkg"
553 | export MY_INSTALL="-f add"
554 | else
555 | exit_with_failure "Command 'pkg' not found"
556 | fi
557 | ;;
558 | esac
559 | echo_success
560 | }
561 |
562 | # resync_installer() re-synchronize the package index and install the newest versions of all packages currently installed
563 | function resync_installer() {
564 | echo_step " Re-sync. the package index and install the newest versions (please wait, sometimes takes a little longer...)"
565 | case $MY_INSTALLER in
566 | apt-get)
567 | $MY_INSTALLER update >>"$INSTALL_LOG" 2>&1
568 | if [ "$?" -ne 0 ]; then
569 | exit_with_failure "Failed to do $MY_INSTALLER update"
570 | fi
571 | ;;
572 | dnf|yum)
573 | $MY_INSTALLER -y update >>"$INSTALL_LOG" 2>&1
574 | if [ "$?" -ne 0 ]; then
575 | exit_with_failure "Failed to do $MY_INSTALLER update"
576 | fi
577 | ;;
578 | zypper)
579 | $MY_INSTALLER update -y >>"$INSTALL_LOG" 2>&1
580 | if [ "$?" -ne 0 ]; then
581 | exit_with_failure "Failed to do $MY_INSTALLER update"
582 | fi
583 | ;;
584 | pacman)
585 | $MY_INSTALLER -Syu --noconfirm >>"$INSTALL_LOG" 2>&1
586 | if [ "$?" -ne 0 ]; then
587 | exit_with_failure "Failed to do $MY_INSTALLER upgrade"
588 | fi
589 | ;;
590 | slackpkg)
591 | SLACKPKG_MIRROR=$(tail -n 1 /etc/slackpkg/mirrors)
592 | # Check mirror
593 | if [ "$SLACKPKG_MIRROR" = "http://mirrors.slackware.com/slackware/slackware64-current/" ]; then
594 | echo "found slackware64-current mirror" >> "$INSTALL_LOG"
595 | elif [ "$SLACKPKG_MIRROR" = "http://mirrors.slackware.com/slackware/slackware-current/" ]; then
596 | echo "found slackware-current mirror" >> "$INSTALL_LOG"
597 | else
598 | # add mirror
599 | if [ "$ARCHITECTURE" = "x86_64" ]; then
600 | echo "http://mirrors.slackware.com/slackware/slackware64-current/" >> "/etc/slackpkg/mirrors"
601 | else
602 | echo "http://mirrors.slackware.com/slackware/slackware-current/" >> "/etc/slackpkg/mirrors"
603 | fi
604 | fi
605 | # update not silent :-(
606 | $MY_INSTALLER update
607 | if [ "$?" -ne 0 ]; then
608 | exit_with_failure "Failed to do $MY_INSTALLER update"
609 | fi
610 | ;;
611 | pkg)
612 | if [ "$OPERATING_SYSTEM" = "PUPPY" ]; then
613 | $MY_INSTALLER update-sources >>"$INSTALL_LOG" 2>&1
614 | if [ "$?" -ne 0 ]; then
615 | exit_with_failure "Failed to do $MY_INSTALLER repo-update"
616 | fi
617 | else
618 | $MY_INSTALLER upgrade >>"$INSTALL_LOG" 2>&1
619 | if [ "$?" -ne 0 ]; then
620 | exit_with_failure "Failed to do $MY_INSTALLER upgrade"
621 | fi
622 | fi
623 | ;;
624 | pkgman)
625 | $MY_INSTALLER update >>"$INSTALL_LOG" 2>&1
626 | if [ "$?" -ne 0 ]; then
627 | exit_with_failure "Failed to do $MY_INSTALLER update"
628 | fi
629 | ;;
630 | apt-cyg)
631 | $MY_INSTALLER update >>"$INSTALL_LOG" 2>&1
632 | if [ "$?" -ne 0 ]; then
633 | exit_with_failure "Failed to do $MY_INSTALLER update"
634 | fi
635 | ;;
636 | brew)
637 | $MY_INSTALLER update | sudo tee -a "$INSTALL_LOG" 2>&1
638 | if [ "$?" -ne 0 ]; then
639 | exit_with_failure "Failed to do $MY_INSTALLER update"
640 | fi
641 | $MY_INSTALLER upgrade | sudo tee -a "$INSTALL_LOG" 2>&1
642 | if [ "$?" -ne 0 ]; then
643 | exit_with_failure "Failed to do $MY_INSTALLER upgrade"
644 | fi
645 | ;;
646 | port)
647 | $MY_INSTALLER -q selfupdate >>"$INSTALL_LOG" 2>&1
648 | if [ "$?" -ne 0 ]; then
649 | exit_with_failure "Failed to do $MY_INSTALLER selfupdate"
650 | fi
651 | $MY_INSTALLER -q upgrade outdated >>"$INSTALL_LOG" 2>&1
652 | # 0 = OK
653 | # 1 = nothing to upgrade
654 | if [ "$?" -gt 1 ]; then
655 | exit_with_failure "Failed to do $MY_INSTALLER upgrade outdated"
656 | fi
657 | ;;
658 | pkg_add)
659 | $MY_INSTALLER -UuI >>"$INSTALL_LOG" 2>&1
660 | if [ "$?" -ne 0 ]; then
661 | exit_with_failure "Failed to do $MY_INSTALLER update"
662 | fi
663 | ;;
664 | apk)
665 | $MY_INSTALLER update >>"$INSTALL_LOG" 2>&1
666 | if [ "$?" -ne 0 ]; then
667 | exit_with_failure "Failed to do $MY_INSTALLER update"
668 | fi
669 | $MY_INSTALLER upgrade >>"$INSTALL_LOG" 2>&1
670 | if [ "$?" -ne 0 ]; then
671 | exit_with_failure "Failed to do $MY_INSTALLER upgrade"
672 | fi
673 | ;;
674 | urpmi)
675 | $MY_INSTALLER --auto-update --force >>"$INSTALL_LOG" 2>&1
676 | if [ "$?" -ne 0 ]; then
677 | exit_with_failure "Failed to do $MY_INSTALLER upgrade"
678 | fi
679 | ;;
680 | esac
681 | echo_success
682 | }
683 |
684 | # use the given INSTALL_LOG or set it to a random file in /tmp
685 | function set_install_log() {
686 | if [[ ! $INSTALL_LOG ]]; then
687 | # Termux
688 | if [ -d "$PREFIX/tmp" ]; then
689 | export INSTALL_LOG="$PREFIX/tmp/install_$DATETIME.log"
690 | # Normal
691 | else
692 | export INSTALL_LOG="/tmp/install_$DATETIME.log"
693 | fi
694 | fi
695 | if [ -e "$INSTALL_LOG" ]; then
696 | exit_with_failure "$INSTALL_LOG already exists"
697 | fi
698 | }
699 |
700 | # use the given PACKAGES_LIST or set it to a random file in /tmp
701 | function set_packages_list() {
702 | if [[ ! $PACKAGES_LIST ]]; then
703 | # Termux
704 | if [ -d "$PREFIX/tmp" ]; then
705 | export PACKAGES_LIST="$PREFIX/tmp/packages_$DATETIME.list"
706 | # Normal
707 | else
708 | export PACKAGES_LIST="/tmp/packages_$DATETIME.list"
709 | fi
710 | fi
711 | if [ -e "$PACKAGES_LIST" ]; then
712 | exit_with_failure "$PACKAGES_LIST already exists"
713 | fi
714 | }
715 |
716 | # use the given BEFORE_SCRIPT or set it to a random file in /tmp
717 | function set_before_script() {
718 | if [[ ! $BEFORE_SCRIPT ]]; then
719 | # Termux
720 | if [ -d "$PREFIX/tmp" ]; then
721 | export BEFORE_SCRIPT="$PREFIX/tmp/before_$DATETIME.sh"
722 | # Normal
723 | else
724 | export BEFORE_SCRIPT="/tmp/before_$DATETIME.sh"
725 | fi
726 | fi
727 | if [ -e "$BEFORE_SCRIPT" ]; then
728 | exit_with_failure "$BEFORE_SCRIPT already exists"
729 | fi
730 | }
731 |
732 | # use the given AFTER_SCRIPT or set it to a random file in /tmp
733 | function set_after_script() {
734 | if [[ ! $AFTER_SCRIPT ]]; then
735 | # Termux
736 | if [ -d "$PREFIX/tmp" ]; then
737 | export AFTER_SCRIPT="$PREFIX/tmp/after_$DATETIME.sh"
738 | # Normal
739 | else
740 | export AFTER_SCRIPT="/tmp/after_$DATETIME.sh"
741 | fi
742 | fi
743 | if [ -e "$AFTER_SCRIPT" ]; then
744 | exit_with_failure "$AFTER_SCRIPT already exists"
745 | fi
746 | }
747 |
748 | function build_script() {
749 | INPUT_ARRAY_NAME=("$@")
750 | ((last_idx=${#INPUT_ARRAY_NAME[@]} - 1))
751 | OUTPUT_NAME=${INPUT_ARRAY_NAME[last_idx]}
752 | unset "INPUT_ARRAY_NAME[last_idx]"
753 |
754 | echo_step " '$OUTPUT_NAME'"
755 |
756 | echo '#/bin/bash' > "$OUTPUT_NAME"
757 |
758 | if [[ "$BASE" == "http"* ]]; then
759 | for INPUT_NAME in "${INPUT_ARRAY_NAME[@]}"; do
760 | echo -e "\nchecking $INPUT_NAME" >>"$INSTALL_LOG"
761 | echo -e "\n\n#$INPUT_NAME\n" >> "$OUTPUT_NAME"
762 | echo -e "\n$FETCHER $INPUT_NAME >> $OUTPUT_NAME" >>"$INSTALL_LOG"
763 | $FETCHER -H 'Cache-Control: no-cache' "$INPUT_NAME" >> "$OUTPUT_NAME"
764 | echo >> "$OUTPUT_NAME"
765 | done
766 | else
767 | for INPUT_NAME in "${INPUT_ARRAY_NAME[@]}"; do
768 | echo -e "\nchecking $INPUT_NAME" >>"$INSTALL_LOG"
769 | echo -e "\n\n#$INPUT_NAME\n" >> "$OUTPUT_NAME"
770 | if [ -f "$INPUT_NAME" ]; then
771 | echo -e "\ncat $INPUT_NAME >> $OUTPUT_NAME" >>"$INSTALL_LOG"
772 | cat "$INPUT_NAME" >> "$OUTPUT_NAME"
773 | if [ "$?" -ne 0 ]; then
774 | exit_with_failure "Failed to append $INPUT_NAME to $OUTPUT_NAME"
775 | fi
776 | echo >> "$INPUT_NAME"
777 | fi
778 | done
779 | fi
780 | echo_success
781 | }
782 |
783 | ################################################################################
784 | # MAIN
785 | ################################################################################
786 |
787 | while getopts ":b:t:h" opt; do
788 | case $opt in
789 | b)
790 | BASE="$OPTARG"
791 | ;;
792 | t)
793 | TYPE="$OPTARG"
794 | ;;
795 | h)
796 | usage 0
797 | ;;
798 | *)
799 | echo "Invalid option: -$OPTARG"
800 | usage 1
801 | ;;
802 | esac
803 | done
804 |
805 | if ! command_exists tput; then
806 | echo "'tput' is needed. Please install 'tput' ('ncurses')."
807 | exit 9
808 | fi
809 |
810 | echo
811 | echo
812 | echo_title "Check Prerequisites"
813 |
814 | check_bash
815 | set_install_log
816 | set_before_script
817 | set_after_script
818 | set_packages_list
819 | detect_hostname_fqdn
820 | detect_operating_system
821 | detect_architecture
822 | check_if_root_or_die
823 |
824 | echo_step "Preparing to Install"; echo
825 |
826 | # Detect package manager
827 | detect_installer
828 |
829 | # Re-sync package index
830 | resync_installer
831 |
832 | # Checking if curl is installed
833 | # If not try to install curl
834 | check_fetcher
835 |
836 |
837 | echo_step "Creating scripts from base '$BASE'"; echo
838 |
839 | # Set script sources
840 | PACKAGE_SOURCES=(
841 | "$BASE/packages.list"
842 | "$BASE/$HOSTNAME_FQDN/packages.list"
843 | "$BASE/$TYPE/packages.list"
844 | "$BASE/$OPERATING_SYSTEM/packages.list"
845 | "$BASE/$OPERATING_SYSTEM/$TYPE/packages.list"
846 | )
847 |
848 | BEFORE_SOURCES=(
849 | "$BASE/before.sh"
850 | "$BASE/$HOSTNAME_FQDN/before.sh"
851 | "$BASE/$TYPE/before.sh"
852 | "$BASE/$OPERATING_SYSTEM/before.sh"
853 | "$BASE/$OPERATING_SYSTEM/$TYPE/before.sh"
854 | )
855 |
856 | AFTER_SOURCES=(
857 | "$BASE/after.sh"
858 | "$BASE/$HOSTNAME_FQDN/after.sh"
859 | "$BASE/$TYPE/after.sh"
860 | "$BASE/$OPERATING_SYSTEM/after.sh"
861 | "$BASE/$OPERATING_SYSTEM/$TYPE/after.sh"
862 | )
863 |
864 | # Create the script that runs BEFORE the installation.
865 | build_script "${BEFORE_SOURCES[@]}" "$BEFORE_SCRIPT"
866 |
867 | # Create the script that runs AFTER the installation.
868 | build_script "${AFTER_SOURCES[@]}" "$AFTER_SCRIPT"
869 |
870 | # Create a list of packages to install
871 | build_script "${PACKAGE_SOURCES[@]}" "$PACKAGES_LIST"
872 |
873 | echo_title "Install"
874 |
875 | # macOS: Install the latest command line tools from XCode.
876 | if command_exists xcode-select; then
877 | echo_step "Install the latest command line tools from XCode"
878 | xcode-select --install >>"$INSTALL_LOG" 2>&1
879 | # 0 = OK
880 | # 1 = command line tools are already installed
881 | if [ "$?" -gt 1 ]; then
882 | echo_warning "Failed to do xcode-select --install, will attempt to continue"
883 | else
884 | echo_success
885 | fi
886 | fi
887 |
888 | # Run BEFORE_SCRIPT
889 | echo_step "Running BEFORE script"; echo
890 | if [ -f "$BEFORE_SCRIPT" ]; then
891 | echo -e "\nsource $BEFORE_SCRIPT" >>"$INSTALL_LOG"
892 | # https://github.com/koalaman/shellcheck/wiki/SC1090
893 | # shellcheck source=/dev/null
894 | source "$BEFORE_SCRIPT"
895 | else
896 | exit_with_failure "'$BEFORE_SCRIPT' not found."
897 | fi
898 |
899 | # Install all packages from PACKAGES_LIST
900 | echo_step "Installing Packages"; echo
901 | if [ -f "$PACKAGES_LIST" ]; then
902 | echo -e "\npackages list $PACKAGES_LIST" >>"$INSTALL_LOG"
903 | # IFS='' (or IFS=) prevents leading/trailing whitespace from being trimmed.
904 | # -r prevents backslash escapes from being interpreted.
905 | # || [[ -n $line ]] prevents the last line from being ignored if it doesn't end with a \n (since read returns a non-zero exit code when it encounters EOF).
906 | while IFS='' read -r PACKAGE || [[ -n "$PACKAGE" ]]; do
907 | if [[ "$PACKAGE" == [a-z]* ]] || [[ "$PACKAGE" == [A-Z]* ]]; then
908 | echo_step " $PACKAGE"
909 | echo -e "\n$MY_INSTALLER $INSTALL $PACKAGE" >>"$INSTALL_LOG"
910 | if [[ $MY_INSTALLER == "brew" ]]; then
911 | $MY_INSTALLER "$MY_INSTALL" "$PACKAGE" | sudo tee -a "$INSTALL_LOG" 2>&1
912 | elif [[ $MY_INSTALLER == "slackpkg" ]]; then
913 | # not silent
914 | $MY_INSTALLER "$MY_INSTALL" "$PACKAGE"
915 | else
916 | $MY_INSTALLER "$MY_INSTALL" "$PACKAGE" >>"$INSTALL_LOG" 2>&1
917 | fi
918 | if [ "$?" -ne 0 ]; then
919 | echo_warning "Failed to install, will attempt to continue"
920 | else
921 | echo_success
922 | fi
923 | fi
924 | done < "$PACKAGES_LIST"
925 | else
926 | exit_with_failure "'$PACKAGES_LIST' not found."
927 | fi
928 |
929 | # Run AFTER_SCRIPT
930 | echo_step "Running AFTER script"; echo
931 | if [ -f "$AFTER_SCRIPT" ]; then
932 | echo -e "\nsource $AFTER_SCRIPT" >>"$INSTALL_LOG"
933 | # shellcheck source=/dev/null
934 | source "$AFTER_SCRIPT"
935 | else
936 | exit_with_failure "'$AFTER_SCRIPT' not found."
937 | fi
938 |
939 | echo_title "Done"
940 |
941 | echo
942 | echo
943 | { echo; debug_variables; } >>"$INSTALL_LOG"
944 |
--------------------------------------------------------------------------------