From b10405938f02cbf322c8dea290f4ab0eb829ecb1 Mon Sep 17 00:00:00 2001 From: Jerome Sagnole Date: Tue, 21 Nov 2017 22:10:28 +0100 Subject: [PATCH] adding script to build & generate docker image --- .dockerignore | 1 + .gitignore | 9 + Dockerfile | 3 - LICENSE | 661 ++++++++++++++++++ README.md | 65 ++ build_all.sh | 179 +++++ builder/common/squish-limit.patch | 24 + builder/debian/jessie/i686/Dockerfile | 101 +++ .../debian/jessie/i686/build-under-docker.sh | 70 ++ builder/debian/jessie/i686/build.sh | 300 ++++++++ builder/debian/jessie/x86_64/Dockerfile | 102 +++ .../jessie/x86_64/build-under-docker.sh | 69 ++ builder/debian/jessie/x86_64/build.sh | 300 ++++++++ builder/debian/stretch/x86_64/Dockerfile | 107 +++ .../stretch/x86_64/build-under-docker.sh | 69 ++ builder/debian/stretch/x86_64/build.sh | 281 ++++++++ server/debian/common/khaganat.cfg | 246 +++++++ .../servercontainer_configure_apache.sh | 113 +++ .../common/servercontainer_configure_auto.sh | 30 + .../servercontainer_configure_khanat.sh | 152 ++++ .../servercontainer_configure_launcher.sh | 87 +++ .../common/servercontainer_configure_link.sh | 188 +++++ .../common/servercontainer_configure_mysql.sh | 144 ++++ .../common/servercontainer_configure_patch.sh | 375 ++++++++++ .../common/servercontainer_configure_world.sh | 280 ++++++++ .../debian/common/servercontainer_function.sh | 235 +++++++ .../common/servercontainer_init_apache.sh | 221 ++++++ .../servercontainer_init_configure_envi.sh | 231 ++++++ .../servercontainer_init_create_account.sh | 82 +++ .../common/servercontainer_init_mysql.sh | 90 +++ .../common/servercontainer_init_package.sh | 65 ++ .../common/servercontainer_launch_auto.sh | 320 +++++++++ .../common/servercontainer_launch_service.sh | 167 +++++ .../common/servercontainer_launch_status.sh | 174 +++++ .../common/servercontainer_update_auto.sh | 27 + server/debian/common/serverimage_autostart.sh | 45 ++ .../common/serverimage_configure_apache.sh | 155 ++++ .../common/serverimage_configure_database.sh | 133 ++++ .../serverimage_configure_environment.sh | 63 ++ .../debian/common/serverimage_init_basic.sh | 325 +++++++++ .../debian/common/serverimage_init_khanat.sh | 44 ++ .../serverimage_initialize_khanat_server.sh | 103 +++ .../serverimage_initialize_patch_server.sh | 217 ++++++ .../common/serverimage_install_package.sh | 104 +++ .../serverimage_install_package_static.sh | 35 + .../common/serverimage_launch_services.sh | 99 +++ .../serverimage_prepare_khanat_client.sh | 92 +++ .../serverimage_prepare_start_server.sh | 57 ++ server/debian/jessie/i686/Dockerfile | 34 + .../jessie/i686/Dockerfile.khanat.container | 33 + .../jessie/i686/Dockerfile.khanat.image | 33 + server/debian/jessie/i686/server-container.sh | 537 ++++++++++++++ server/debian/jessie/i686/server-image.sh | 443 ++++++++++++ server/debian/jessie/x86_64/Dockerfile | 34 + .../jessie/x86_64/Dockerfile.khanat.container | 33 + .../jessie/x86_64/Dockerfile.khanat.image | 33 + .../debian/jessie/x86_64/server-container.sh | 537 ++++++++++++++ server/debian/jessie/x86_64/server-image.sh | 441 ++++++++++++ 58 files changed, 9195 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitignore delete mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100755 build_all.sh create mode 100644 builder/common/squish-limit.patch create mode 100644 builder/debian/jessie/i686/Dockerfile create mode 100755 builder/debian/jessie/i686/build-under-docker.sh create mode 100755 builder/debian/jessie/i686/build.sh create mode 100644 builder/debian/jessie/x86_64/Dockerfile create mode 100755 builder/debian/jessie/x86_64/build-under-docker.sh create mode 100755 builder/debian/jessie/x86_64/build.sh create mode 100644 builder/debian/stretch/x86_64/Dockerfile create mode 100755 builder/debian/stretch/x86_64/build-under-docker.sh create mode 100755 builder/debian/stretch/x86_64/build.sh create mode 100644 server/debian/common/khaganat.cfg create mode 100755 server/debian/common/servercontainer_configure_apache.sh create mode 100755 server/debian/common/servercontainer_configure_auto.sh create mode 100755 server/debian/common/servercontainer_configure_khanat.sh create mode 100755 server/debian/common/servercontainer_configure_launcher.sh create mode 100755 server/debian/common/servercontainer_configure_link.sh create mode 100755 server/debian/common/servercontainer_configure_mysql.sh create mode 100755 server/debian/common/servercontainer_configure_patch.sh create mode 100755 server/debian/common/servercontainer_configure_world.sh create mode 100755 server/debian/common/servercontainer_function.sh create mode 100755 server/debian/common/servercontainer_init_apache.sh create mode 100755 server/debian/common/servercontainer_init_configure_envi.sh create mode 100755 server/debian/common/servercontainer_init_create_account.sh create mode 100755 server/debian/common/servercontainer_init_mysql.sh create mode 100755 server/debian/common/servercontainer_init_package.sh create mode 100755 server/debian/common/servercontainer_launch_auto.sh create mode 100755 server/debian/common/servercontainer_launch_service.sh create mode 100755 server/debian/common/servercontainer_launch_status.sh create mode 100755 server/debian/common/servercontainer_update_auto.sh create mode 100755 server/debian/common/serverimage_autostart.sh create mode 100755 server/debian/common/serverimage_configure_apache.sh create mode 100755 server/debian/common/serverimage_configure_database.sh create mode 100755 server/debian/common/serverimage_configure_environment.sh create mode 100755 server/debian/common/serverimage_init_basic.sh create mode 100755 server/debian/common/serverimage_init_khanat.sh create mode 100755 server/debian/common/serverimage_initialize_khanat_server.sh create mode 100755 server/debian/common/serverimage_initialize_patch_server.sh create mode 100755 server/debian/common/serverimage_install_package.sh create mode 100755 server/debian/common/serverimage_install_package_static.sh create mode 100755 server/debian/common/serverimage_launch_services.sh create mode 100755 server/debian/common/serverimage_prepare_khanat_client.sh create mode 100755 server/debian/common/serverimage_prepare_start_server.sh create mode 100644 server/debian/jessie/i686/Dockerfile create mode 100644 server/debian/jessie/i686/Dockerfile.khanat.container create mode 100644 server/debian/jessie/i686/Dockerfile.khanat.image create mode 100755 server/debian/jessie/i686/server-container.sh create mode 100755 server/debian/jessie/i686/server-image.sh create mode 100644 server/debian/jessie/x86_64/Dockerfile create mode 100644 server/debian/jessie/x86_64/Dockerfile.khanat.container create mode 100644 server/debian/jessie/x86_64/Dockerfile.khanat.image create mode 100755 server/debian/jessie/x86_64/server-container.sh create mode 100755 server/debian/jessie/x86_64/server-image.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +build/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc60914 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Ignore build directory +build/ + +# output build/test with docker +output/ + +# ignore temporary file +todelete.sh + diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index b22ab73..0000000 --- a/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM centos:7 - -MAINTAINER egeorget@dremor.info diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0c2a91a --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + Khanat + Copyright (C) 2016 Khaganat + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9781b97 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# khanat server docker + +Khanat Server Docker is tool to build 'khanat-opennel-code' and emulate server side. + +Khanat Server Docker is open source and released under the terms of the GNU Affero General Public License 3.0 (GNU/AGPLv3) for the source code and the Creative Commons Attributions-ShareAlike 3.0 (CC-BY-SA) for the art assets. Which means you can create your own game using Ryzom Core, for more information on doing so check out Creating Your Own Game Using Ryzom Core. + +Modification par la Team Khaganat + +## Install docker + +Depend on your environment. + + docker version + docker info + docker search debian + + + +## Clone repo + + git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git + git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-client-data.git + git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-ressources.git + git clone https://git.khaganat.net/khaganat/mmorpg_khanat/opennel-pymanager.git + +## BUILD +(use docker) + + +### archi x64_86: + +command : + +./builder/debian/jessie/x86_64/build.sh -c -r -j 4 -a '-DWITH_SYMBOLS=ON' -m '-m 20g' -d + +result: + + package : ./code/build/builder_khanat_debian_jessie_x86_64/ryzomcore-*.tar.gz + + log build : ./code/build/builder_khanat_debian_jessie_x86_64/build.log + + all file generated on build : ./code/build/builder_khanat_debian_jessie_x86_64/ + + + +## COMPIL SERVER and START + +Compil server : + + (prepare server / initialize khanat / database / patch) + +./dist/docker/server/debian/jessie/x86_64/server.sh -b -t -q -z -k -n + + +Start server : + + (You need tape Enter when application ask to start server) + +./dist/docker/server/debian/jessie/x86_64/server.sh + + +Connect server with ssh (only if server is started) + +./dist/docker/server/debian/jessie/x86_64/server.sh --ssh + diff --git a/build_all.sh b/build_all.sh new file mode 100755 index 0000000..e0287a1 --- /dev/null +++ b/build_all.sh @@ -0,0 +1,179 @@ +#!/bin/bash +# +# Program to build all and generate all image server (i686 & x86_64) +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +declare -i AUTO=1 +declare -i BUILD_i686=0 +declare -i GENERATE_CONTAINER_i686=0 +declare -i GENERATE_IMAGE_i686=0 +declare -i BUILD_x86_64=0 +declare -i GENERATE_CONTAINER_x86_64=0 +declare -i GENERATE_IMAGE_x86_64=0 +declare -i CLEAN=0 + +calldir="$(dirname $0)" +basedir=$(cd $calldir; pwd) + +usage() +{ +cat << EOF +usage:$0 [options] + script to build all environment + +options: + -h, --help : Show this help + -d, --debug : Show debug message + --build-i686 : Build server and client i686 + --generate-container-i686 : Generate container docker for i686 (share data with host) + --generate-image-i686 : Generate image docker for i686 (image have all opennel) + --build-x86_64 : Build server and client x86_64 + --generate-container-x86_64 : Generate container docker for x86_64 (share data with host) + --generate-image-x86_64 : Generate image docker for x86_64 (image have all opennel) + --clean : remove build & server data +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + msg="$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" + echo "$msg" + echo "$msg" >> ${basedir}/build/state.log +} + +function msg_error() +{ + msg="$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" + echo "$msg" + echo "$msg" >> ${basedir}/build/state.log + exit 2 +} + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + --build-i686) + AUTO=0 + BUILD_i686=1 + shift + ;; + --generate-container-i686) + AUTO=0 + GENERATE_CONTAINER_i686=1 + shift + ;; + --generate-image-i686) + AUTO=0 + GENERATE_IMAGE_i686=1 + shift + ;; + --build-x86_64) + AUTO=0 + BUILD_x86_64=1 + shift + ;; + --generate-container-x86_64) + AUTO=0 + GENERATE_CONTAINER_x86_64=1 + shift + ;; + --generate-image-x86_64) + AUTO=0 + GENERATE_IMAGE_x86_64=1 + shift + ;; + --clean) + CLEAN=1 + shift + ;; + *) + usage + msg_error "options '$1' not recognize" + ;; + esac +done + +mkdir -p "${basedir}/build" +msg_info "BEGIN" +if [[ $AUTO ]] +then + BUILD_i686=1 + GENERATE_CONTAINER_i686=1 + GENERATE_IMAGE_i686=1 + BUILD_x86_64=1 + GENERATE_CONTAINER_x86_64=1 + GENERATE_IMAGE_x86_64=1 +fi + +if [[ $CLEAN -ne 0 ]] +then + msg_debug "CLEAN" + rm -rf $basedir/build $basedir/output || msg_error "CLEAN" +fi + +if [[ $BUILD_i686 -ne 0 ]] +then + msg_debug "BUILD DEBIAN JESSIE i686" + builder/debian/jessie/i686/build.sh -c -j 12 -a '-DWITH_SSE2=OFF' -a '-DWITH_SYMBOLS=ON' -m '-m 20g' -d || msg_error "BUILD DEBIAN JESSIE i686" +fi + +if [[ $GENERATE_CONTAINER_i686 -ne 0 ]] +then + msg_debug "GENERATE SERVER CONTAINER DEBIAN JESSIE i686" + server/debian/jessie/i686/server-container.sh -r -b -k -w -c -n || msg_error "GENERATE SERVER CONTAINER DEBIAN JESSIE i686" +fi + +if [[ $GENERATE_IMAGE_i686 -ne 0 ]] +then + msg_debug "GENERATE SERVER IMAGE DEBIAN JESSIE i686" + server/debian/jessie/i686/server-image.sh -b -k -w -c -n || msg_error "GENERATE SERVER IMAGE DEBIAN JESSIE i686" +fi + +if [[ $BUILD_x86_64 -ne 0 ]] +then + msg_debug "BUILD DEBIAN JESSIE x86_64" + builder/debian/jessie/x86_64/build.sh -c -j 12 -a '-DWITH_SYMBOLS=ON' -m '-m 20g' -d || msg_error "BUILD DEBIAN JESSIE x86_64" +fi + +if [[ $GENERATE_CONTAINER_x86_64 -ne 0 ]] +then + msg_debug "GENERATE SERVER CONTAINER DEBIAN JESSIE x86_64" + server/debian/jessie/x86_64/server-container.sh -r -b -k -g -w -c -n || msg_error "GENERATE SERVER CONTAINER DEBIAN JESSIE x86_64" +fi + +if [[ $GENERATE_IMAGE_x86_64 -ne 0 ]] +then + msg_debug "GENERATE SERVER IMAGE DEBIAN JESSIE x86_64" + server/debian/jessie/x86_64/server-image.sh -b -k -w -c -n || msg_error "GENERATE SERVER IMAGE DEBIAN JESSIE x86_64" +fi + +msg_info "END" diff --git a/builder/common/squish-limit.patch b/builder/common/squish-limit.patch new file mode 100644 index 0000000..3bdc6c5 --- /dev/null +++ b/builder/common/squish-limit.patch @@ -0,0 +1,24 @@ +--- alpha.cpp.origin 2017-08-01 15:02:13.627989355 +0000 ++++ alpha.cpp 2017-08-01 15:03:07.591990587 +0000 +@@ -22,7 +22,7 @@ + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ +- ++#include + #include "alpha.h" + #include + + +--- singlecolourfit.cpp.origin 2017-08-01 15:03:27.175991034 +0000 ++++ singlecolourfit.cpp 2017-08-01 15:03:42.527991384 +0000 +@@ -22,7 +22,7 @@ + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ +- ++#include + #include "singlecolourfit.h" + #include "colourset.h" + #include "colourblock.h" + diff --git a/builder/debian/jessie/i686/Dockerfile b/builder/debian/jessie/i686/Dockerfile new file mode 100644 index 0000000..0eea5f3 --- /dev/null +++ b/builder/debian/jessie/i686/Dockerfile @@ -0,0 +1,101 @@ +# Dockerfile - Build environment to compile khanat server +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +FROM i386/debian:8 +MAINTAINER AleaJactaEst + +ENV HOSTNAME builder + +RUN apt-get update ; \ + apt-get dist-upgrade -y ; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server ; \ + apt-get install -y apache2 \ + php5 \ + libapache2-mod-php5 \ + php5-mysql \ + apache2-utils \ + php5-gd \ + php5-imagick \ + git \ + libcurl4-openssl-dev \ + libluabind-dev \ + libfreetype6-dev \ + libx11-dev \ + libgl1-mesa-dev \ + libxxf86vm-dev \ + libxrandr-dev \ + libxrender-dev \ + libopenal-dev \ + libogg-dev \ + libvorbis-dev \ + libxml2-dev \ + cmake \ + build-essential \ + libpng12-dev \ + libjpeg62-turbo-dev \ + rrdtool \ + bison \ + libxmu-dev \ + autoconf \ + automake \ + libmysqlclient-dev \ + libgif-dev \ + cpputest \ + libssl-dev \ + liblzma-dev \ + unzip \ + zlib1g-dev \ + libssh-dev \ + libboost-all-dev \ + libopenal-dev \ + libgl1-mesa-dev \ + libogg-dev \ + mercurial \ + wget \ + python3 \ + python3-setuptools + +## Build & Install cpptest +# Impossible to build release 1.1.0, 1.1.1, 1.1.2 +RUN apt-get install -y wget autogen autoconf automake libtool libtool-bin +RUN mkdir -p /opt/src +RUN wget -q https://github.com/cpptest/cpptest/archive/1.0.5.tar.gz -O /opt/src/cpptest.tar.gz +RUN rm -rf /opt/src/cpptest +RUN tar xvf /opt/src/cpptest.tar.gz -C /opt/src --strip 1 +RUN cd /opt/src/cpptest && ./autogen.sh && ./configure && make && make install + +## Build & Install squish +RUN mkdir -p /opt/src +RUN cd /opt/src; wget -c https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libsquish/squish-1.11.zip +RUN cd /opt/src; unzip squish-1.11.zip +COPY builder/common/squish-limit.patch /opt/squish-limit.patch +RUN cd /opt/src/squish-1.11; patch -i /opt/squish-limit.patch +RUN cd /opt/src/squish-1.11; make +RUN cd /opt/src/squish-1.11; make install + +## Build & Install CURL - 7.46.0 +#RUN hg clone http://hg.kervala.net/packaging/ +#RUN mkdir -p packaging/curl/build +#RUN cd packaging/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DBUILD_CURL_TESTS=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a .. +#RUN cd packaging/curl/build; make +#RUN cd packaging/curl/build; make install +RUN wget -q https://curl.haxx.se/download/curl-7.46.0.tar.gz -O /opt/src/curl.tar.gz +RUN mkdir -p /opt/src/curl/build +RUN tar xvf /opt/src/curl.tar.gz -C /opt/src/curl --strip 1 +RUN cd /opt/src/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DBUILD_CURL_TESTS=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a .. +RUN cd /opt/src/curl/build; make +RUN cd /opt/src/curl/build; make install diff --git a/builder/debian/jessie/i686/build-under-docker.sh b/builder/debian/jessie/i686/build-under-docker.sh new file mode 100755 index 0000000..51254c4 --- /dev/null +++ b/builder/debian/jessie/i686/build-under-docker.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# Script to build Khaganat binary (executed in docker) +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +declare DIRBUILD="/opt/build/" +if [[ -n "$1" ]] +then + DIRBUILD="$1" +fi +declare LOGFILE="${DIRBUILD}/build.log" + +function chrashed() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - BUILD FAILED (code:$?)" >> $LOGFILE + exit 2 +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $1" + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $1" >> $LOGFILE +} + +trap chrashed EXIT + +msg_info "CREATE BUILD DIRECTORY" +mkdir -p ${DIRBUILD}/ || exit 2 + +if [[ -f ${DIRBUILD}/envi.sh ]] +then + msg_info "LOAD ENVIRONMENT" + source ${DIRBUILD}/envi.sh +fi + +msg_info "PREPARE BUILD" +# on 32bit, we need add option '-DWITH_SSE2=OFF' +cd ${DIRBUILD}; cmake -DWITH_NEL=ON \ + -DWITH_STATIC=ON \ + -DWITH_STATIC_DRIVERS=ON \ + -DWITH_STATIC_EXTERNAL=ON \ + -DWITH_SYMBOLS=ON \ + -DWITH_LUA52=ON \ + -DWITH_RYZOM_PATCH=ON \ + -DWITH_RYZOM_CUSTOM_PATCH_SERVER=ON \ + ${CMAKEOPTS} \ + /opt/code 1>>$LOGFILE 2>&1 || exit 2 + +msg_info "BUILD START" +cd ${DIRBUILD}; make $MAKEOPTS 1>>$LOGFILE 2>&1 || exit 2 + +msg_info "GENERATE PACKAGE" +cd ${DIRBUILD}; make package 1>>$LOGFILE 2>&1 || exit 2 + +trap '' EXIT +msg_info "BUILD END" diff --git a/builder/debian/jessie/i686/build.sh b/builder/debian/jessie/i686/build.sh new file mode 100755 index 0000000..09ed6d9 --- /dev/null +++ b/builder/debian/jessie/i686/build.sh @@ -0,0 +1,300 @@ +#!/bin/bash +# +# Script to build khaganat server +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +declare -i REMOVE=0 +declare -i IMAGE=0 +declare -i BUILD=1 +declare -i PACKAGE=0 +declare -i DEBUG=0 +declare JOBS="" +declare CMAKEOPTS="" +declare DOCKEROPTS="" +declare DIRBUILD="" +declare CLEANDOCKER=0 +declare -i CLEANIMAGENONE=0 +declare -i AUTODETEC=1 +declare DOCKERBUILDOPT="" + +declare IMAGEDOCKER="opennel/builder_debian_jessie_i686" +declare LOCALBUILDDIR="build/$IMAGEDOCKER" +declare LOCALSRC="debian/jessie/i686" +declare DIRPACKAGE="output/OpenNel_debian_jessie_i686/package" +declare PACKAGEBIN="$DIRPACKAGE/ryzomcore_jessie_i686.tar.gz" +declare PACKAGEREF="$DIRPACKAGE/khanat-ref-ressources.tar.gz" + + +usage() +{ +cat << EOF +usage:$0 [options] + script to build under docker + + Step: + 1) clean old build directory + 2) create image builder + 3) launch build under docker (launch script build-under-docker.sh) + 4) remove docker container with state exited and clean docker images NONE + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -r, --remove : Remove old build repository + -f, --force-create-image : force to create docker image (use to build khanat) - default autodetec. + -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg. + -a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build) + -c, --clean-container : remove all container in state Exited + -w, --clean-images-none : Remove images docker (with name 'none') + -m OPTS, --add-opts-docker=OPTS : Adding options on docker command (when build) + --only-build-server : adding option to build only server + -p, --package : generate package + --code-source=[DIR] : localization source OpenNel code + +Example : + cd [root Khanat directory] + ./build.sh -c -r -m '-m 20g' + ./build.sh -c -r -j 4 -a '-DWITH_SYMBOLS=ON' -a '-DWITH_RYZOM_TOOLS=OFF' -a '-DWITH_NEL_TOOLS=OFF' -m '-m 20g' -d + +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +# +# MAIN +# + +calldir="$(dirname $0)" +basedir=$(cd $calldir; pwd) +rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))" +codesource="$(dirname ${rootdir})/khanat-opennel-code" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + -c|--clean-container) + CLEANDOCKER=1 + shift + ;; + -r|--remove) + REMOVE=1 + shift + ;; + -f|--force-create-image) + IMAGE=1 + shift + ;; + -p|--package) + PACKAGE=1 + shift + ;; + -j) + shift + # search next argument is value or new argument + if [[ ${1:0:1} == "-" ]] + then + JOBS="-j" + else + JOBS="-j $1" + shift + fi + ;; + --jobs*) + if [[ ${1#*=} == "" ]] + then + JOBS="-j" + else + JOBS="-j ${1#*=}" + fi + shift + ;; + -a) + shift + CMAKEOPTS="$CMAKEOPTS $1" + shift + ;; + --add-opts-cmake=*) + CMAKEOPTS="$CMAKEOPTS ${1#*=}" + shift + ;; + -m) + shift + DOCKEROPTS="$DOCKEROPTS $1" + shift + ;; + --add-opts-docker=*) + DOCKEROPTS="$DOCKEROPTS ${1#*=}" + shift + ;; + --only-build-server) + CMAKEOPTS="$CMAKEOPTS -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=OFF -DWITH_DRIVER_OPENGL=OFF -DWITH_DRIVER_OPENAL=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=OFF" + shift + ;; + -w|--clean-images-none) + CLEANIMAGENONE=1 + shift + ;; + --code-source=*) + codesource="${1#*=}" + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +function chrashed() +{ + msg_error "BUILD FAILED (code:$?)" + exit 2 +} + +trap chrashed EXIT + +msg_debug "prg: $0" + +docker -v 1>/dev/null +if [[ $? -ne 0 ]] +then + echo "*** ERROR docker not installed" + exit 2 +fi + +if [[ $AUTODETEC -ne 0 ]] +then + if [[ $(docker images -f "reference=$IMAGEDOCKER" | wc -l) -lt 2 ]] + then + IMAGE=1 + fi +fi + +DIRBUILD="${rootdir}/${LOCALBUILDDIR}" + +msg_debug "calldir: $calldir" +msg_debug "basedir: $basedir" +msg_debug "rootdir: $rootdir" +msg_debug "codesource: $codesource" +msg_debug "JOBS: '$JOBS'" +msg_debug "CMAKEOPTS: '$CMAKEOPTS'" +msg_debug "DOCKEROPTS: '$DOCKEROPTS'" + +if [ ! -d "${codesource}/code" ] +then + msg_error "Missing OpenNel source (${codesource})" + exit 2 +fi + +mkdir -p "${DIRBUILD}" +if [[ $REMOVE -ne 0 ]] +then + msg_info "REMOVE OLD BUILD" + rm -rf ${DIRBUILD}/* || exit 2 +fi + +echo "$(date "+%Y/%m/%d %H:%M:%S") LAUNCH BUILD" > ${DIRBUILD}/build.log + +cat << EOF > ${DIRBUILD}/envi.sh +#!/bin/bash +export MAKEOPTS="$JOBS" +export CMAKEOPTS="$CMAKEOPTS" +EOF + +if [[ $IMAGE -ne 0 ]] +then + echo "$(date "+%Y/%m/%d %H:%M:%S") GENERATE DOCKER IMAGE" > ${DIRBUILD}/build.log + msg_info "GENERATE DOCKER IMAGE" + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t "${IMAGEDOCKER}" \ + --file "${basedir}/Dockerfile" || exit 2 +fi + +if [[ $BUILD -ne 0 ]] +then + msg_info "BUILD" + cd $rootdir; docker run -it \ + --hostname=builder \ + -u "$(id -u $USERNAME):$(id -g $USERNAME)" \ + -v ${rootdir}/builder:/opt/builder:ro \ + -v ${codesource}/code:/opt/code:ro \ + -v ${rootdir}/build:/opt/build \ + -v /etc/localtime:/etc/localtime:ro \ + ${DOCKEROPTS} \ + ${IMAGEDOCKER} \ + /opt/builder/${LOCALSRC}/build-under-docker.sh "/opt/${LOCALBUILDDIR}" || exit 2 +fi + +if [[ $PACKAGE -ne 0 ]] +then + msg_info "COPY PACKAGES" + mkdir -p "$rootdir/$DIRPACKAGE" + cd ${rootdir}; tar czf ${PACKAGEREF} \ + ${codesource}/code/ryzom/server/shard.screen.rc \ + ${codesource}/code/ryzom/common/* \ + ${codesource}/code/ryzom/client/* \ + ${codesource}/code/ryzom/server/* \ + ${codesource}/code/web/* || exit 2 + cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${PACKAGEBIN} || exit 2 +fi + +if [[ $CLEANDOCKER -ne 0 ]] +then + msg_info "CLEAN CONTAINER" + docker rm --force `docker ps -qf 'status=exited' -f "ancestor=${IMAGEDOCKER}"` || exit 2 +fi + +if [[ $CLEANIMAGENONE -ne 0 ]] +then + msg_info "CLEAN IMAGE DOCKER 'NONE'" + listimages=( $(docker images | awk '{if ($1=="")print $3}') ) + + msg_debug "IMAGES NONE : ${listimages[@]}" + if [[ -n "${listimages[@]}" ]] + then + docker rmi --force "${listimages[@]}" || exit 2 + fi +fi + +trap '' EXIT +msg_info "END" diff --git a/builder/debian/jessie/x86_64/Dockerfile b/builder/debian/jessie/x86_64/Dockerfile new file mode 100644 index 0000000..c9ebe12 --- /dev/null +++ b/builder/debian/jessie/x86_64/Dockerfile @@ -0,0 +1,102 @@ +# Dockerfile - Build environment to compile khanat server +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM amd64/debian:8 +MAINTAINER AleaJactaEst + +ENV HOSTNAME builder + +RUN apt-get update ; \ + apt-get dist-upgrade -y ; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server ; \ + apt-get install -y apache2 \ + php5 \ + libapache2-mod-php5 \ + php5-mysql \ + apache2-utils \ + php5-gd \ + php5-imagick \ + git \ + libcurl4-openssl-dev \ + libluabind-dev \ + libfreetype6-dev \ + libx11-dev \ + libgl1-mesa-dev \ + libxxf86vm-dev \ + libxrandr-dev \ + libxrender-dev \ + libopenal-dev \ + libogg-dev \ + libvorbis-dev \ + libxml2-dev \ + cmake \ + build-essential \ + libpng12-dev \ + libjpeg62-turbo-dev \ + rrdtool \ + bison \ + libxmu-dev \ + autoconf \ + automake \ + libmysqlclient-dev \ + libgif-dev \ + cpputest \ + libssl-dev \ + liblzma-dev \ + unzip \ + zlib1g-dev \ + libssh-dev \ + libboost-all-dev \ + libopenal-dev \ + libgl1-mesa-dev \ + libogg-dev \ + mercurial \ + wget \ + python3 \ + python3-setuptools + +## Build & Install cpptest +# Impossible to build release 1.1.0, 1.1.1, 1.1.2 +RUN apt-get install -y wget autogen autoconf automake libtool libtool-bin +RUN mkdir -p /opt/src +RUN wget -q https://github.com/cpptest/cpptest/archive/1.0.5.tar.gz -O /opt/src/cpptest.tar.gz +RUN rm -rf /opt/src/cpptest +RUN tar xvf /opt/src/cpptest.tar.gz -C /opt/src --strip 1 +RUN cd /opt/src/cpptest && ./autogen.sh && ./configure && make && make install + +## Build & Install squish +RUN mkdir -p /opt/src +RUN cd /opt/src; wget -c https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libsquish/squish-1.11.zip +RUN cd /opt/src; unzip squish-1.11.zip +COPY builder/common/squish-limit.patch /opt/squish-limit.patch +RUN cd /opt/src/squish-1.11; patch -i /opt/squish-limit.patch +RUN cd /opt/src/squish-1.11; make +RUN cd /opt/src/squish-1.11; make install + +## Build & Install CURL - 7.46.0 +#RUN hg clone http://hg.kervala.net/packaging/ +#RUN mkdir -p packaging/curl/build +#RUN cd packaging/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DBUILD_CURL_TESTS=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a .. +#RUN cd packaging/curl/build; make +#RUN cd packaging/curl/build; make install +RUN wget -q https://curl.haxx.se/download/curl-7.46.0.tar.gz -O /opt/src/curl.tar.gz +RUN mkdir -p /opt/src/curl/build +RUN tar xvf /opt/src/curl.tar.gz -C /opt/src/curl --strip 1 +RUN cd /opt/src/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DBUILD_CURL_TESTS=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a .. +RUN cd /opt/src/curl/build; make +RUN cd /opt/src/curl/build; make install diff --git a/builder/debian/jessie/x86_64/build-under-docker.sh b/builder/debian/jessie/x86_64/build-under-docker.sh new file mode 100755 index 0000000..20b3929 --- /dev/null +++ b/builder/debian/jessie/x86_64/build-under-docker.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# Script to build Khaganat binary (executed in docker) +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +declare DIRBUILD="/opt/build/" +if [[ -n "$1" ]] +then + DIRBUILD="$1" +fi +declare LOGFILE="${DIRBUILD}/build.log" + +function chrashed() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - BUILD FAILED (code:$?)" >> $LOGFILE + exit 2 +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $1" + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $1" >> $LOGFILE +} + +trap chrashed EXIT + +msg_info "CREATE BUILD DIRECTORY" +mkdir -p ${DIRBUILD}/ || exit 2 + +if [[ -f ${DIRBUILD}/envi.sh ]] +then + msg_info "LOAD ENVIRONMENT" + source ${DIRBUILD}/envi.sh +fi + +msg_info "PREPARE BUILD" +cd ${DIRBUILD}; cmake -DWITH_NEL=ON \ + -DWITH_STATIC=ON \ + -DWITH_STATIC_DRIVERS=ON \ + -DWITH_STATIC_EXTERNAL=ON \ + -DWITH_SYMBOLS=ON \ + -DWITH_LUA52=ON \ + -DWITH_RYZOM_PATCH=ON \ + -DWITH_RYZOM_CUSTOM_PATCH_SERVER=ON \ + ${CMAKEOPTS} \ + /opt/code 1>>$LOGFILE 2>&1 || exit 2 + +msg_info "BUILD START" +cd ${DIRBUILD}; make $MAKEOPTS 1>>$LOGFILE 2>&1 || exit 2 + +msg_info "GENERATE PACKAGE" +cd ${DIRBUILD}; make package 1>>$LOGFILE 2>&1 || exit 2 + +trap '' EXIT +msg_info "BUILD END" diff --git a/builder/debian/jessie/x86_64/build.sh b/builder/debian/jessie/x86_64/build.sh new file mode 100755 index 0000000..dfd7135 --- /dev/null +++ b/builder/debian/jessie/x86_64/build.sh @@ -0,0 +1,300 @@ +#!/bin/bash +# +# Script to build khaganat server +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +declare -i REMOVE=0 +declare -i IMAGE=0 +declare -i BUILD=1 +declare -i PACKAGE=0 +declare -i DEBUG=0 +declare JOBS="" +declare CMAKEOPTS="" +declare DOCKEROPTS="" +declare DIRBUILD="" +declare CLEANDOCKER=0 +declare -i CLEANIMAGENONE=0 +declare -i AUTODETEC=1 +declare DOCKERBUILDOPT="" + +declare IMAGEDOCKER="opennel/builder_debian_jessie_x86_64" +declare LOCALBUILDDIR="build/$IMAGEDOCKER" +declare LOCALSRC="debian/jessie/x86_64" +declare DIRPACKAGE="output/OpenNel_debian_jessie_x86_64/package" +declare PACKAGEBIN="$DIRPACKAGE/ryzomcore_jessie_x86_64.tar.gz" +declare PACKAGEREF="$DIRPACKAGE/khanat-ref-ressources.tar.gz" + + +usage() +{ +cat << EOF +usage:$0 [options] + script to build under docker + + Step: + 1) clean old build directory + 2) create image builder + 3) launch build under docker (launch script build-under-docker.sh) + 4) remove docker container with state exited and clean docker images NONE + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -r, --remove : Remove old build repository + -f, --force-create-image : force to create docker image (use to build khanat) - default autodetec. + -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg. + -a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build) + -c, --clean-container : remove all container in state Exited + -w, --clean-images-none : Remove images docker (with name 'none') + -m OPTS, --add-opts-docker=OPTS : Adding options on docker command (when build) + --only-build-server : adding option to build only server + -p, --package : generate package + --code-source=[DIR] : localization source OpenNel code + +Example : + cd [root Khanat directory] + ./build.sh -c -r -m '-m 20g' + ./build.sh -c -r -j 4 -a '-DWITH_SYMBOLS=ON' -a '-DWITH_RYZOM_TOOLS=OFF' -a '-DWITH_NEL_TOOLS=OFF' -m '-m 20g' -d + +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +# +# MAIN +# + +calldir="$(dirname $0)" +basedir=$(cd $calldir; pwd) +rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))" +codesource="$(dirname ${rootdir})/khanat-opennel-code" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + -c|--clean-container) + CLEANDOCKER=1 + shift + ;; + -r|--remove) + REMOVE=1 + shift + ;; + -f|--force-create-image) + IMAGE=1 + shift + ;; + -p|--package) + PACKAGE=1 + shift + ;; + -j) + shift + # search next argument is value or new argument + if [[ ${1:0:1} == "-" ]] + then + JOBS="-j" + else + JOBS="-j $1" + shift + fi + ;; + --jobs*) + if [[ ${1#*=} == "" ]] + then + JOBS="-j" + else + JOBS="-j ${1#*=}" + fi + shift + ;; + -a) + shift + CMAKEOPTS="$CMAKEOPTS $1" + shift + ;; + --add-opts-cmake=*) + CMAKEOPTS="$CMAKEOPTS ${1#*=}" + shift + ;; + -m) + shift + DOCKEROPTS="$DOCKEROPTS $1" + shift + ;; + --add-opts-docker=*) + DOCKEROPTS="$DOCKEROPTS ${1#*=}" + shift + ;; + --only-build-server) + CMAKEOPTS="$CMAKEOPTS -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=OFF -DWITH_DRIVER_OPENGL=OFF -DWITH_DRIVER_OPENAL=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=OFF" + shift + ;; + -w|--clean-images-none) + CLEANIMAGENONE=1 + shift + ;; + --code-source=*) + codesource="${1#*=}" + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +function chrashed() +{ + msg_error "BUILD FAILED (code:$?)" + exit 2 +} + +trap chrashed EXIT + +msg_debug "prg: $0" + +docker -v 1>/dev/null +if [[ $? -ne 0 ]] +then + echo "*** ERROR docker not installed" + exit 2 +fi + +if [[ $AUTODETEC -ne 0 ]] +then + if [[ $(docker images -f "reference=$IMAGEDOCKER" | wc -l) -lt 2 ]] + then + IMAGE=1 + fi +fi + +DIRBUILD="${rootdir}/${LOCALBUILDDIR}" + +msg_debug "calldir: $calldir" +msg_debug "basedir: $basedir" +msg_debug "rootdir: $rootdir" +msg_debug "codesource: $codesource" +msg_debug "JOBS: '$JOBS'" +msg_debug "CMAKEOPTS: '$CMAKEOPTS'" +msg_debug "DOCKEROPTS: '$DOCKEROPTS'" + +if [ ! -d "${codesource}/code" ] +then + msg_error "Missing OpenNel source (${codesource})" + exit 2 +fi + +mkdir -p "${DIRBUILD}" +if [[ $REMOVE -ne 0 ]] +then + msg_info "REMOVE OLD BUILD" + rm -rf ${DIRBUILD}/* || exit 2 +fi + +echo "$(date "+%Y/%m/%d %H:%M:%S") LAUNCH BUILD" > ${DIRBUILD}/build.log + +cat << EOF > ${DIRBUILD}/envi.sh +#!/bin/bash +export MAKEOPTS="$JOBS" +export CMAKEOPTS="$CMAKEOPTS" +EOF + +if [[ $IMAGE -ne 0 ]] +then + echo "$(date "+%Y/%m/%d %H:%M:%S") GENERATE DOCKER IMAGE" > ${DIRBUILD}/build.log + msg_info "GENERATE DOCKER IMAGE" + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t "${IMAGEDOCKER}" \ + --file "${basedir}/Dockerfile" || exit 2 +fi + +if [[ $BUILD -ne 0 ]] +then + msg_info "BUILD" + cd $rootdir; docker run -it \ + --hostname=builder \ + -u "$(id -u $USERNAME):$(id -g $USERNAME)" \ + -v ${rootdir}/builder:/opt/builder:ro \ + -v ${codesource}/code:/opt/code:ro \ + -v ${rootdir}/build:/opt/build \ + -v /etc/localtime:/etc/localtime:ro \ + ${DOCKEROPTS} \ + ${IMAGEDOCKER} \ + /opt/builder/${LOCALSRC}/build-under-docker.sh "/opt/${LOCALBUILDDIR}" || exit 2 +fi + +if [[ $PACKAGE -ne 0 ]] +then + msg_info "COPY PACKAGES" + mkdir -p "$rootdir/$DIRPACKAGE" + cd ${rootdir}; tar czf ${PACKAGEREF} \ + ${codesource}/code/ryzom/server/shard.screen.rc \ + ${codesource}/code/ryzom/common/* \ + ${codesource}/code/ryzom/client/* \ + ${codesource}/code/ryzom/server/* \ + ${codesource}/code/web/* || exit 2 + cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${PACKAGEBIN} || exit 2 +fi + +if [[ $CLEANDOCKER -ne 0 ]] +then + msg_info "CLEAN CONTAINER" + docker rm --force `docker ps -qf 'status=exited' -f "ancestor=${IMAGEDOCKER}"` || exit 2 +fi + +if [[ $CLEANIMAGENONE -ne 0 ]] +then + msg_info "CLEAN IMAGE DOCKER 'NONE'" + listimages=( $(docker images | awk '{if ($1=="")print $3}') ) + + msg_debug "IMAGES NONE : ${listimages[@]}" + if [[ -n "${listimages[@]}" ]] + then + docker rmi --force "${listimages[@]}" || exit 2 + fi +fi + +trap '' EXIT +msg_info "END" diff --git a/builder/debian/stretch/x86_64/Dockerfile b/builder/debian/stretch/x86_64/Dockerfile new file mode 100644 index 0000000..a48c03f --- /dev/null +++ b/builder/debian/stretch/x86_64/Dockerfile @@ -0,0 +1,107 @@ +# Dockerfile - Build environment to compile khanat server +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +# to build : +# $ docker build . -t builder_khanat_jessie_x86_64 --file dist/docker/builder/debian-8-amd64/Dockerfile + +# to use this image : +# (on root) +# $ docker run -it --hostname=builder -v $PWD/dist:/opt/dist -v $PWD/code:/opt/code builder_khanat_jessie_x86_64 /bin/bash +# (with your account) +# $ docker run -it --hostname=builder -u "$(id -u $USERNAME):$(id -g $USERNAME)" -v $PWD/dist:/opt/dist -v $PWD/code:/opt/code builder_khanat_jessie_x86_64 /bin/bash + +FROM amd64/debian:9 +MAINTAINER AleaJactaEst + +ENV HOSTNAME builder + +RUN apt-get update ; \ + apt-get dist-upgrade -y ; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server ; \ + apt-get install -y apache2 \ + php \ + libapache2-mod-php \ + php-mysql \ + apache2-utils \ + php-gd \ + php-imagick ; \ + apt-get install -y git \ + libcurl4-openssl-dev \ + libluabind-dev \ + libfreetype6-dev \ + libx11-dev \ + libgl1-mesa-dev \ + libxxf86vm-dev \ + libxrandr-dev \ + libxrender-dev \ + libopenal-dev \ + libogg-dev \ + libvorbis-dev \ + libxml2-dev \ + cmake \ + build-essential \ + libpng-dev \ + libjpeg62-turbo-dev \ + rrdtool \ + bison \ + libxmu-dev \ + autoconf \ + automake \ + default-libmysqlclient-dev \ + libgif-dev \ + cpputest \ + libssl-dev \ + liblzma-dev \ + unzip \ + zlib1g-dev \ + libssh2-1-dev \ + libboost-all-dev \ + libopenal-dev \ + libgl1-mesa-dev \ + libogg-dev \ + mercurial \ + wget \ + autogen \ + libtool \ + libtool-bin + +## Build & Install cpptest +# Impossible to build release 1.1.0, 1.1.1, 1.1.2 +RUN mkdir -p /opt/src +RUN wget -q https://github.com/cpptest/cpptest/archive/1.0.5.tar.gz -O /opt/src/cpptest.tar.gz || exit 2 +RUN rm -rf /opt/src/cpptest +RUN tar xvf /opt/src/cpptest.tar.gz -C /opt/src --strip 1 || exit 2 +RUN cd /opt/src/cpptest && ./autogen.sh && ./configure && make && make install || exit 2 + +## Build & Install squish +RUN mkdir -p /opt/src +RUN cd /opt/src; wget -c https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libsquish/squish-1.11.zip +RUN cd /opt/src; unzip squish-1.11.zip +COPY dist/docker/builder/common/squish-limit.patch /opt/squish-limit.patch +RUN cd /opt/src/squish-1.11; patch -i /opt/squish-limit.patch || exit 2 +RUN cd /opt/src/squish-1.11; make || exit 2 +RUN cd /opt/src/squish-1.11; make install || exit 2 + +## Build & Install CURL - 7.46.0 +RUN wget -q https://curl.haxx.se/download/curl-7.55.1.tar.gz -O /opt/src/curl.tar.gz +RUN mkdir -p /opt/src/curl/build +RUN tar xvf /opt/src/curl.tar.gz -C /opt/src/curl --strip 1 || exit 2 +RUN cd /opt/src/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a .. || exit 2 +RUN cd /opt/src/curl/build; make || exit 2 +RUN cd /opt/src/curl/build; make install || exit 2 + diff --git a/builder/debian/stretch/x86_64/build-under-docker.sh b/builder/debian/stretch/x86_64/build-under-docker.sh new file mode 100755 index 0000000..7bbc9c2 --- /dev/null +++ b/builder/debian/stretch/x86_64/build-under-docker.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# Script to build Khaganat binary (executed in docker) +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +declare DIRBUILD="/opt/build/" +if [[ -n "$1" ]] +then + DIRBUILD="$1" +fi +declare LOGFILE="${DIRBUILD}/build.log" + +function chrashed() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - BUILD FAILED (code:$?)" >> $LOGFILE + exit 2 +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $1" + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $1" >> $LOGFILE +} + +trap chrashed EXIT + +msg_info "CREATE BUILD DIRECTORY" +mkdir -p ${DIRBUILD}/ || exit 2 + +if [[ -f ${DIRBUILD}/envi.sh ]] +then + msg_info "LOAD ENVIRONMENT" + source ${DIRBUILD}/envi.sh +fi + +msg_info "PREPARE BUILD" +cd ${DIRBUILD}; cmake -DWITH_NEL=ON \ + -DWITH_STATIC=ON \ + -DWITH_STATIC_DRIVERS=ON \ + -DWITH_STATIC_EXTERNAL=ON \ + -DWITH_SYMBOLS=ON \ + -DWITH_LUA52=ON \ + -DWITH_RYZOM_PATCH=ON \ + -DWITH_RYZOM_CUSTOM_PATCH_SERVER=ON \ + ${CMAKEOPTS} \ + ../../code 1>>$LOGFILE 2>&1 || exit 2 + +msg_info "BUILD START" +cd ${DIRBUILD}; make $MAKEOPTS 1>>$LOGFILE 2>&1 || exit 2 + +msg_info "GENERATE PACKAGE" +cd ${DIRBUILD}; make package 1>>$LOGFILE 2>&1 || exit 2 + +trap '' EXIT +msg_info "BUILD END" diff --git a/builder/debian/stretch/x86_64/build.sh b/builder/debian/stretch/x86_64/build.sh new file mode 100755 index 0000000..ee25480 --- /dev/null +++ b/builder/debian/stretch/x86_64/build.sh @@ -0,0 +1,281 @@ +#!/bin/bash +# +# Script to build khaganat server +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +declare -i REMOVE=0 +declare -i IMAGE=0 +declare -i BUILD=1 +declare -i DEBUG=0 +declare JOBS="" +declare CMAKEOPTS="" +declare DOCKEROPTS="" +declare DIRBUILD="" +declare CLEANDOCKER=0 +declare -i CLEANIMAGENONE=0 +declare -i AUTODETEC=1 +declare DOCKERBUILDOPT="" + +declare IMAGEDOCKER="builder_khanat_debian_stretch_x86_64" +declare LOCALBUILDDIR="build/$IMAGEDOCKER" +declare LOCALSRC="debian/stretch/x86_64" +declare DIRPACKAGE="output/khanat_debian_stretch_x86_64/package" +declare PACKAGEBIN="$DIRPACKAGE/ryzomcore_stretch_x86_64.tar.gz" +declare PACKAGEREF="$DIRPACKAGE/khanat-ref-ressources.tar.gz" + + +usage() +{ +cat << EOF +usage:$0 [options] + script to build under docker + + Step: + 1) clean old build directory + 2) create image builder + 3) launch build under docker (launch script build-under-docker.sh) + 4) remove docker container with state exited and clean docker images NONE + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -r, --remove : Remove old build repository + -f, --force-create-image : force to create docker image (use to build khanat) - default autodetec. + -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg. + -a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build) + -c, --clean-container : remove all container in state Exited + -w, --clean-images-none : Remove images docker (with name 'none') + -m OPTS, --add-opts-docker=OPTS : Adding options on docker command (when build) + --only-build-server : adding option to build only server + +Example : + cd [root Khanat directory] + ./build.sh -c -r -m '-m 20g' + ./build.sh -c -r -j 4 -a '-DWITH_SYMBOLS=ON' -a '-DWITH_RYZOM_TOOLS=OFF' -a '-DWITH_NEL_TOOLS=OFF' -m '-m 20g' -d + +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +# +# MAIN +# + +calldir="$(dirname $0)" +basedir=$(cd $calldir; pwd) +rootdir="$(dirname $(dirname $(dirname $(dirname $(dirname $(dirname ${basedir}))))))" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + -c|--clean-container) + CLEANDOCKER=1 + shift + ;; + -r|--remove) + REMOVE=1 + shift + ;; + -f|--force-create-image) + IMAGE=1 + DOCKERBUILDOPT="$DOCKERBUILDOPT --no-cache" + shift + ;; + -j) + shift + # search next argument is value or new argument + if [[ ${1:0:1} == "-" ]] + then + JOBS="-j" + else + JOBS="-j $1" + shift + fi + ;; + --jobs*) + if [[ ${1#*=} == "" ]] + then + JOBS="-j" + else + JOBS="-j ${1#*=}" + fi + shift + ;; + -a) + shift + CMAKEOPTS="$CMAKEOPTS $1" + shift + ;; + --add-opts-cmake=*) + CMAKEOPTS="$CMAKEOPTS ${1#*=}" + shift + ;; + -m) + shift + DOCKEROPTS="$DOCKEROPTS $1" + shift + ;; + --add-opts-docker=*) + DOCKEROPTS="$DOCKEROPTS ${1#*=}" + shift + ;; + --only-build-server) + CMAKEOPTS="$CMAKEOPTS -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=OFF -DWITH_DRIVER_OPENGL=OFF -DWITH_DRIVER_OPENAL=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=OFF" + shift + ;; + -w|--clean-images-none) + CLEANIMAGENONE=1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +function chrashed() +{ + msg_error "BUILD FAILED (code:$?)" + exit 2 +} + +trap chrashed EXIT + +msg_debug "prg: $0" + +docker -v 1>/dev/null +if [[ $? -ne 0 ]] +then + echo "*** ERROR docker not installed" + exit 2 +fi + +if [[ $AUTODETEC -ne 0 ]] +then + if [[ $(docker images -f "reference=$IMAGEDOCKER" | wc -l) -lt 2 ]] + then + IMAGE=1 + fi +fi + +DIRBUILD="${rootdir}/${LOCALBUILDDIR}" + +msg_debug "calldir: $calldir" +msg_debug "basedir: $basedir" +msg_debug "rootdir: $rootdir" +msg_debug "JOBS: '$JOBS'" +msg_debug "CMAKEOPTS: '$CMAKEOPTS'" +msg_debug "DOCKEROPTS: '$DOCKEROPTS'" + +mkdir -p "${DIRBUILD}" +if [[ $REMOVE -ne 0 ]] +then + msg_info "REMOVE OLD BUILD" + rm -rf ${DIRBUILD}/* || exit 2 +fi + +touch ${DIRBUILD}/build.log + +cat << EOF > ${DIRBUILD}/envi.sh +#!/bin/bash +export MAKEOPTS="$JOBS" +export CMAKEOPTS="$CMAKEOPTS" +EOF + +if [[ $IMAGE -ne 0 ]] +then + msg_info "GENERATE DOCKER IMAGE" + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEDOCKER} \ + --file "${basedir}/Dockerfile" || exit 2 +fi + +if [[ $BUILD -ne 0 ]] +then + msg_info "BUILD" + cd $rootdir; docker run -it \ + --hostname=builder \ + -u "$(id -u $USERNAME):$(id -g $USERNAME)" \ + -v $rootdir/dist:/opt/dist:ro \ + -v $rootdir/code:/opt/code:ro \ + -v $rootdir/build:/opt/build \ + -v /etc/localtime:/etc/localtime:ro \ + ${DOCKEROPTS} \ + ${IMAGEDOCKER} \ + /opt/dist/docker/builder/${LOCALSRC}/build-under-docker.sh "/opt/${LOCALBUILDDIR}" || exit 2 +fi + +if [[ $BUILD -ne 0 ]] +then + msg_info "COPY PACKAGES" + mkdir -p "$rootdir/$DIRPACKAGE" + cd ${rootdir}; tar czf ${PACKAGEREF} \ + code/ryzom/server/shard.screen.rc \ + code/ryzom/common/* \ + code/ryzom/client/* \ + code/ryzom/server/* \ + code/web/* || exit 2 + cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${PACKAGEBIN} || exit 2 +fi + +if [[ $CLEANDOCKER -ne 0 ]] +then + msg_info "CLEAN CONTAINER" + docker rm --force `docker ps -qf 'status=exited' -f "ancestor=${IMAGEDOCKER}"` || exit 2 +fi + +if [[ $CLEANIMAGENONE -ne 0 ]] +then + msg_info "CLEAN IMAGE DOCKER 'NONE'" + listimages=( $(docker images | awk '{if ($1=="")print $3}') ) + + msg_debug "IMAGES NONE : ${listimages[@]}" + if [[ -n "${listimages[@]}" ]] + then + docker rmi --force "${listimages[@]}" || exit 2 + fi +fi + +trap '' EXIT +msg_info "END" diff --git a/server/debian/common/khaganat.cfg b/server/debian/common/khaganat.cfg new file mode 100644 index 0000000..ebbc1a3 --- /dev/null +++ b/server/debian/common/khaganat.cfg @@ -0,0 +1,246 @@ +# +# Configuration process khaganat +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +############################## +############################## +# Global parameter +############################## +############################## +[config] +# Define port listen (default 8000) +port = 8000 + +# key +keyfile = /home/gameserver/ca/appli/private/serverkey.pem + +# certificate +certfile = /home/gameserver/ca/appli/certs/servercert.pem + +# certification to check signature +ca_cert = /home/gameserver/ca/appli/certs/cachaincert.pem + +# address listen (default all port) +address = + +############################## +############################## +# List all program we manage # +############################## +############################## + +############################## +# Admin Executor Service +############################## +[aes] +# command to launch the program +command = ryzom_admin_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --fulladminname=admin_executor_service --shortadminname=AES +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 +# buffer size (define value bufsize on subprocess.Popen, this buffer is use before read by manager) +bufsize = 100 + +############################## +# bms_master : backup_service +############################## +[bms_master] +# command to launch the program +command = ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid -P49990 +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +#[bms_pd_master] +# # command to launch the program +# command = ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid -P49992 +# # Path : where this program is launched +# path = /home/gameserver/khanat/server/ +# # size buffer log for each program launched (number line stdout) +# logsize = 1000 + +############################## +# egs : entities_game_service +############################## +[egs] +# command to launch the program +command = ryzom_entities_game_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# gpms : gpm_service +############################## +[gpms] +# command to launch the program +command = ryzom_gpm_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/gpms +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# ios : input_output_service +############################## +[ios] +# command to launch the program +command = ryzom_ios_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# rns : naming_service +############################## +[rns] +# command to launch the program +command = ryzom_naming_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# rws : welcome_service +############################## +[rws] +# command to launch the program +command = ryzom_welcome_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# ts : tick_service +############################## +[ts] +# command to launch the program +command = ryzom_tick_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# ms : mirror_service +############################## +[ms] +# command to launch the program +command = ryzom_mirror_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# ais_newbyland : ai_service +############################## +[ais_newbyland] +# command to launch the program +command = ryzom_ai_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid -mCommon:Newbieland:Post +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# mfs : mail_forum_service +############################## +[mfs] +# command to launch the program +command = ryzom_mail_forum_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# su : shard_unifier_service +############################## +[su] +# command to launch the program +command = ryzom_shard_unifier_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# fes : frontend_service +############################## +[fes] +# command to launch the program +command = ryzom_frontend_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# sbs : session_browser_server +############################## +[sbs] +# command to launch the program +command = ryzom_session_browser_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +############################## +# lgs : logger_service +############################## +[lgs] +# command to launch the program +command = ryzom_logger_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 + +# [mos] +# # command to launch the program +# command = ryzom_monitor_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# # Path : where this program is launched +# path = /home/gameserver/khanat/server/ +# # size buffer log for each program launched (number line stdout) +# logsize = 1000 + +# [pdss] +# # command to launch the program +# command = ryzom_pd_support_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# # Path : where this program is launched +# path = /home/gameserver/khanat/server/ +# # size buffer log for each program launched (number line stdout) +# logsize = 1000 + +############################## +# ras : admin_service +############################## +[ras] +# command to launch the program +command = ryzom_admin_service --fulladminname=admin_service --shortadminname=AS -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid +# Path : where this program is launched +path = /home/gameserver/khanat/server/ +# size buffer log for each program launched (number line stdout) +logsize = 1000 diff --git a/server/debian/common/servercontainer_configure_apache.sh b/server/debian/common/servercontainer_configure_apache.sh new file mode 100755 index 0000000..2920128 --- /dev/null +++ b/server/debian/common/servercontainer_configure_apache.sh @@ -0,0 +1,113 @@ +#!/bin/bash +# +# Configure Apache +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +usage() +{ +cat << EOF +usage:$0 [options] + prepare mysql (create directory, update configuration) + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + + +##################### +# MAIN +##################### +source /opt/ext/servercontainer_function.sh +msg_info "[$(basename $0):$LINENO] => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + + +##################### +# Install web service +##################### +msg_debug "Install web service" +# create_recursive_link '/home/gameserver/ext/khanatweb' "$KHANAT_PATH/khanatweb" +su -c "cp -r /home/gameserver/ext/khanatweb/* $KHANAT_PATH/khanatweb" gameserver + + +##################### +# Create apache log +##################### +msg_debug "Create apache log" +create_dir_gameserver '/home/gameserver/log/apache2' + +touch /home/gameserver/log/apache2/access.log || exit 2 +chown_gameserver '/home/gameserver/log/apache2/access.log' || exit 2 + +touch /home/gameserver/log/apache2/error.log || exit 2 +chown_gameserver '/home/gameserver/log/apache2/error.log' || exit 2 + +touch /home/gameserver/log/apache2/other_vhosts_access.log || exit 2 +chown_gameserver '/home/gameserver/log/apache2/other_vhosts_access.log' || exit 2 + + +##################### +# Start & Stop apache2 +##################### +msg_debug "Stop/Start apache" +service apache2 start || exit 2 +service apache2 stop || exit 2 + + +##################### +# End +##################### +msg_info "[$(basename $0):$LINENO] => END" + diff --git a/server/debian/common/servercontainer_configure_auto.sh b/server/debian/common/servercontainer_configure_auto.sh new file mode 100755 index 0000000..66e1294 --- /dev/null +++ b/server/debian/common/servercontainer_configure_auto.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# Script to configure khanat server +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +/opt/ext/servercontainer_configure_link.sh || exit 2 +/opt/ext/servercontainer_configure_mysql.sh || exit 2 +sync +/opt/ext/servercontainer_configure_apache.sh || exit 2 +/opt/ext/servercontainer_configure_world.sh || exit 2 +su -c '/opt/ext/servercontainer_configure_khanat.sh' gameserver || exit 2 +su -c '/opt/ext/servercontainer_configure_patch.sh' gameserver || exit 2 +su -c '/opt/ext/servercontainer_configure_launcher.sh' gameserver || exit 2 +su -c 'touch /home/gameserver/khanat/step_configure.ok' gameserver || exit 2 +sync +exit 0 + diff --git a/server/debian/common/servercontainer_configure_khanat.sh b/server/debian/common/servercontainer_configure_khanat.sh new file mode 100755 index 0000000..aab9aab --- /dev/null +++ b/server/debian/common/servercontainer_configure_khanat.sh @@ -0,0 +1,152 @@ +#!/bin/bash +# +# Configure Khanat +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +declare DEBUG=0 + +usage() +{ +cat << EOF +usage:$0 [options] + Configure Khanat + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +##################### +# MAIN +##################### +source /opt/ext/servercontainer_function.sh +msg_info "[$(basename $0):$LINENO] => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "[$(basename $0):$LINENO] Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + msg_error "[$(basename $0):$LINENO] - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +if [[ ! -f /home/gameserver/.bashrc ]] +then + msg_error "[$(basename $0):$LINENO] - missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + +#################################### +# Copy configuration & update +#################################### +msg_debug "[$(basename $0):$LINENO] configure frontend service" +copy_link "$KHANAT_PATH/server/frontend_service.cfg" +sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "localhost";/g' $KHANAT_PATH/server/frontend_service.cfg || msg_critical "sed issue (file:frontend_service.cfg, update param FSListenHost) " + +msg_debug "[$(basename $0):$LINENO] configure database" +copy_link "$KHANAT_PATH/server/sql.cfg" +sed -i -r 's/(DBHost)(.*)(=)(.*)(;)/DBHost = "localhost";/g' $KHANAT_PATH/server/sql.cfg || msg_critical "sed issue (file:sql.cfg, update param DBHost) " +sed -i -r 's/(DBRingName)(.*)(=)(.*)(;)/ DBRingName = "ring_mini01";/g' $KHANAT_PATH/server/sql.cfg || msg_critical "sed issue (file:sql.cfg, update param DBRingName) " + +msg_debug "[$(basename $0):$LINENO] prepare sheet_id.bin" +copy_link "$KHANAT_PATH/server/leveldesign/game_elem/sheet_id.bin" +copy_link "$KHANAT_PATH/server/leveldesign/game_elem/sheets.txt" +cd /usr/local; /usr/local/bin/make_sheet_id \ + -o$KHANAT_PATH/server/leveldesign/game_elem/sheet_id.bin \ + $KHANAT_PATH/server/leveldesign/game_elem \ + $KHANAT_PATH/server/leveldesign/game_element \ + $KHANAT_PATH/server/leveldesign/world \ + $KHANAT_PATH/server/leveldesign/ecosystems \ + $KHANAT_PATH/server/sound \ + $KHANAT_PATH/server/mirror_sheets 2>$KHANAT_HOME/log/configure/make_sheet_id.err 1>$KHANAT_HOME/log/configure/make_sheet_id.out || msg_critical "make_sheet_id issue" + +msg_debug "prepare sheets_packer" +cat << EOF > $KHANAT_PATH/sheets_packer.cfg +///////////////////////////////// +///////////////////////////////// +/// SHEETS PACKER CONFIG FILE /// +///////////////////////////////// +///////////////////////////////// +DataPath = { "$KHANAT_PATH/server/common/data_leveldesign", + "$KHANAT_PATH/server/common/data_common", + "$KHANAT_PATH/server/client/data", + "$KHANAT_PATH/server/common", + "$KHANAT_PATH/server/leveldesign", + "$KHANAT_PATH/server/primitives" }; +WorldSheet = "ryzom.world"; +PrimitivesPath = "$KHANAT_PATH/server/primitives"; +OutputDataPath = "$KHANAT_PATH/server/client/data"; +LigoPrimitiveClass = "world_editor_classes.xml"; +DumpVisualSlotsIndex = 1; +EOF +chown $UIDGAMESERVER:$GIDGAMESERVER $KHANAT_PATH/sheets_packer.cfg || msg_critical "chown issue (sheets_packer.cfg)" +cd $KHANAT_PATH; sheets_packer 2>$KHANAT_HOME/log/configure/sheets_packer.err 1>$KHANAT_HOME/log/configure/sheets_packer.out || msg_critical "sheets_packer issue" + +rm -f $KHANAT_PATH/server/common/data_common/visual_slot.tab +cp $KHANAT_PATH/visual_slot.tab $KHANAT_PATH/server/common/data_common/visual_slot.tab || msg_critical "copy issue (visual_slot.tab -> common)" +cp $KHANAT_PATH/visual_slot.tab $KHANAT_PATH/server/client/data/visual_slot.tab || msg_critical "copy issue (visual_slot.tab -> client)" + +# link translation +#for var in $KHANAT_PATH/server/translation/translated/*_en.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_en/_de}; done +#for var in $KHANAT_PATH/server/translation/translated/*_en.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_en/_es}; done +#for var in $KHANAT_PATH/server/translation/translated/*_wk.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_wk/_ru}; done + +for var in $KHANAT_PATH/server/translation/translated/*_en.txt; do nomfic=${var##*/}; target="${var%/*}/${nomfic/_en/_de}"; rm -f $target; ln -s $nomfic $target; done +for var in $KHANAT_PATH/server/translation/translated/*_en.txt; do nomfic=${var##*/}; target="${var%/*}/${nomfic/_en/_es}"; rm -f $target; ln -s $nomfic $target; done +for var in $KHANAT_PATH/server/translation/translated/*_wk.txt; do nomfic=${var##*/}; target="${var%/*}/${nomfic/_wk/_ru}"; rm -f $target; ln -s $nomfic $target; done + + +#################################### +# Copy screen configuration +#################################### +msg_debug "[$(basename $0):$LINENO] screen configuration" +# Copy default screen configuration +cp $KHANAT_HOME/ext/ryzom-ressources/server/shard.screen.rc $KHANAT_PATH/server/shard.screen.rc || msg_critical "copy issue (file:shard.screen.rc)" +sed -i -r 's/\$RYZOM_PATH\/\.\.\/build\/bin\///g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, RYZOM_PATH)" +sed -i -r 's/[-]A[.]/ /g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, param -A)" +sed -i -r 's/[-]C[.]/ -A\/home\/gameserver\/khanat\/server -C\/home\/gameserver\/khanat\/server /g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, param -C)" +sed -i -r 's/[-]L[.]/ -L\/home\/gameserver\/log\/khanat /g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, param -L)" +sed -i -r 's/[.][.]\/tools\/scripts\/linux\//\/home\/gameserver\/khanat\/tools\/scripts\/linux\//g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, tools/script/linux)" + +#################################### +# End +#################################### +msg_info "[$(basename $0):$LINENO] => END" + diff --git a/server/debian/common/servercontainer_configure_launcher.sh b/server/debian/common/servercontainer_configure_launcher.sh new file mode 100755 index 0000000..b0a5697 --- /dev/null +++ b/server/debian/common/servercontainer_configure_launcher.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# +# Configure Launcher +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +usage() +{ +cat << EOF +usage:$0 [options] + Configure Launcher (certificate) + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +##################### +# MAIN +##################### +source /opt/ext/servercontainer_function.sh +msg_info "[$(basename $0):$LINENO] => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + +#################################### +# Create new certificat +#################################### +openssl req -nodes -x509 -newkey rsa:2048 \ + -keyout "$KHANAT_PATH/key.pem" \ + -out "$KHANAT_PATH/cert.pem" \ + -days 365 \ + -subj "/C=FR/ST=France/L=Paris/O=khaganat/CN=khaganat.org" || exit 2 + +#################################### +# End +#################################### +msg_info "[$(basename $0):$LINENO] => END" + diff --git a/server/debian/common/servercontainer_configure_link.sh b/server/debian/common/servercontainer_configure_link.sh new file mode 100755 index 0000000..dc58474 --- /dev/null +++ b/server/debian/common/servercontainer_configure_link.sh @@ -0,0 +1,188 @@ +#!/bin/bash +# +# Configure Link (link package, ...) +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +usage() +{ +cat << EOF +usage:$0 [options] + Configure Link + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +##################### +# MAIN +##################### +source /opt/ext/servercontainer_function.sh +msg_info "[$(basename $0):$LINENO] => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + +#################################### +# Create directory target +#################################### +msg_debug "create directory target" +create_dir_gameserver "$KHANAT_PATH" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/collisions" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/leveldesign" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/primitives" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/translation" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/continents" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/common" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/data_shard" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/sound" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/client" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/save_shard" || exit 2 +create_dir_gameserver "$KHANAT_PATH/server/save_shard/rrd_graphs" || exit 2 +create_dir_gameserver "$KHANAT_PATH/patch_service" || exit 2 +create_dir_gameserver "$KHANAT_HOME/log/configure" || exit 2 + +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/kh_server" || exit 2 +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver" || exit 2 +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/patch_game" || exit 2 +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/patch_game/bnp" || exit 2 +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver" || exit 2 +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/data" || exit 2 +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/data/kh" || exit 2 +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/data/kh_shard" || exit 2 +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/data/ryz" || exit 2 +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/client" || exit 2 +create_dir_gameserver "$KHANAT_HOME/khanat/prepare_client" || exit 2 +create_dir_gameserver "$HOME_PREPARE_CLIENT" || exit 2 +create_dir_gameserver "$HOME_PREPARE_CLIENT/data" || exit 2 +create_dir_gameserver "$HOME_PREPARE_CLIENT/cfg" || exit 2 +create_dir_gameserver "$HOME_PREPARE_CLIENT/save" || exit 2 +create_dir_gameserver "$HOME_PREPARE_CLIENT/user" || exit 2 +create_dir_gameserver "$HOME_PREPARE_CLIENT/cache" || exit 2 +create_dir_gameserver "$HOME_CLIENT" || exit 2 + +create_dir_gameserver "$KHANAT_PATH/patch_service" || exit 2 +create_dir_gameserver "$KHANAT_PATH/patch_service/patch_game" || exit 2 +create_dir_gameserver "$KHANAT_PATH/patch_service/patch_game/patch" || exit 2 +create_dir_gameserver "$KHANAT_PATH/khanatweb" || exit 2 + +msg_debug "Configure Log" +create_dir_gameserver '/home/gameserver/log/apache2' || exit 2 +create_file_gameserver '/home/gameserver/log/apache2/access.log' || exit 2 +create_file_gameserver '/home/gameserver/log/apache2/error.log' || exit 2 +create_file_gameserver '/home/gameserver/log/apache2/other_vhosts_access.log' || exit 2 + +#################################### +# Create link (like copy) +#################################### +msg_debug "create link from ryzom-ressources" +create_recursive_link '/home/gameserver/ext/ryzom-ressources/server/data_shard' "$KHANAT_PATH/server/data_shard" || exit 2 + +create_recursive_link '/home/gameserver/ext/ryzom-ressources/common' "$KHANAT_PATH/server/common" || exit 2 +#create_dir_gameserver "$KHANAT_PATH/server/common" || exit 2 +#create_link_2nd_level "/home/gameserver/ext/ryzom-ressources/common/*" "$KHANAT_PATH/server/common/" || exit 2 + +create_recursive_link '/home/gameserver/ext/ryzom-ressources/client' "$KHANAT_PATH/server/client" || exit 2 +#create_link '/home/gameserver/ext/ryzom-ressources/client' "$KHANAT_PATH/server/client" || exit 2 + +msg_debug "create link from khanat-ressources" +#create_recursive_link '/home/gameserver/ext/khanat-ressources/collisions' "$KHANAT_PATH/server/collisions" || exit 2 +create_recursive_link '/home/gameserver/ext/khanat-ressources/leveldesign' "$KHANAT_PATH/server/leveldesign" || exit 2 +#create_recursive_link '/home/gameserver/ext/khanat-ressources/primitives' "$KHANAT_PATH/server/primitives" || exit 2 +create_recursive_link '/home/gameserver/ext/khanat-ressources/translation' "$KHANAT_PATH/server/translation" || exit 2 +#create_recursive_link '/home/gameserver/ext/khanat-ressources/continents' "$KHANAT_PATH/server/continents" || exit 2 +create_link '/home/gameserver/ext/khanat-ressources/collisions' "$KHANAT_PATH/server/collisions" || exit 2 +#create_link '/home/gameserver/ext/khanat-ressources/leveldesign' "$KHANAT_PATH/server/leveldesign" || exit 2 +create_link '/home/gameserver/ext/khanat-ressources/primitives' "$KHANAT_PATH/server/primitives" || exit 2 +#create_link '/home/gameserver/ext/khanat-ressources/translation' "$KHANAT_PATH/server/translation" || exit 2 +create_link '/home/gameserver/ext/khanat-ressources/continents' "$KHANAT_PATH/server/continents" || exit 2 + +create_recursive_link '/home/gameserver/ext/khanat-ressources/common' "$KHANAT_PATH/server/common" || exit 2 +#create_link_2nd_level "/home/gameserver/ext/khanat-ressources/common/*" "$KHANAT_PATH/server/common/" || exit 2 + +create_link '/home/gameserver/ext/khanat-ressources/shard/su/dev_gm_names.xml' "$KHANAT_PATH/server/data_shard" || exit 2 +create_link '/home/gameserver/ext/khanat-ressources/shard/su/invalid_entity_names.txt' "$KHANAT_PATH/server/data_shard" || exit 2 +create_link '/home/gameserver/ext/khanat-ressources/shard/su/reserved_names.xml' "$KHANAT_PATH/server/data_shard" || exit 2 +create_link '/home/gameserver/ext/khanat-ressources/shard/egs/game_event.txt' "$KHANAT_PATH/server/data_shard" || exit 2 +create_link '/home/gameserver/ext/khanat-ressources/shard/egs/mission_queues.txt' "$KHANAT_PATH/server/data_shard" || exit 2 +create_link '/home/gameserver/ext/khanat-ressources/shard/egs/named_items.txt' "$KHANAT_PATH/server/data_shard" || exit 2 + + +#################################### +# Link configuration +#################################### +msg_debug "create link configuration" +create_link_2nd_level "/home/gameserver/ext/ryzom-ressources/server/*.cfg" "$KHANAT_PATH/server" || exit 2 +#for file in /home/gameserver/ext/ryzom-ressources/server/*.cfg +#do +# create_link "$file" "$KHANAT_PATH/server" || exit 2 +#done + +#################################### +# Link tools script (shard) +#################################### +msg_debug "create link (tools)" +create_dir_gameserver "$KHANAT_PATH/tools" || exit 2 +create_dir_gameserver "$KHANAT_PATH/tools/scripts" || exit 2 +create_dir_gameserver "$KHANAT_PATH/tools/scripts/linux" || exit 2 +create_recursive_link '/home/gameserver/ext/ryzom-ressources/tools/scripts/linux' "$KHANAT_PATH/tools/scripts/linux" || exit 2 + + +#################################### +# Link tools khaganat +#################################### +create_link '/opt/ext/khaganat.cfg' "$KHANAT_PATH" + +#################################### +# End +#################################### +msg_info "[$(basename $0):$LINENO] => END" diff --git a/server/debian/common/servercontainer_configure_mysql.sh b/server/debian/common/servercontainer_configure_mysql.sh new file mode 100755 index 0000000..05b43a1 --- /dev/null +++ b/server/debian/common/servercontainer_configure_mysql.sh @@ -0,0 +1,144 @@ +#!/bin/bash +# +# Configure MySQL +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +declare DEBUG=0 + +usage() +{ +cat << EOF +usage:$0 [options] + prepare mysql (create directory, update configuration) + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +##################### +# MAIN +##################### +source /opt/ext/servercontainer_function.sh +msg_info "[$(basename $0):$LINENO] => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +#################################### +# Configure Log MySQL +#################################### +msg_debug "Configure Log" +mkdir -p /home/gameserver/log/mysql || exit 2 +chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2 + + +#################################### +# Install Database +#################################### +msg_debug "Install Database" +/usr/bin/mysql_install_db --user=gameserver --skip-name-resolve || exit 2 + + +#################################### +# Start Database +#################################### +# Start the MySQL daemon in the background. +msg_debug "Start database" +/usr/sbin/mysqld & +mysql_pid=$! + +# Wait mysql start +msg_info "Check database is started" +sleep 1 +until sudo /usr/bin/mysqladmin ping >/dev/null 2>&1 +do + echo -n "." + sleep 1 +done +echo "" +sleep 1 + +#################################### +# Update root password (mysql) +#################################### +# Initialize password root (to empty) +msg_debug "configure password root for database" +/usr/bin/mysqladmin -u root password '' || exit 2 + +mysql -u root -e "GRANT ALL PRIVILEGES on *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '"$(awk '{if($1 == "password"){print $3;exit 0}}' /etc/mysql/debian.cnf)"' WITH GRANT OPTION; FLUSH PRIVILEGES;" || exit 2 + +#################################### +# Stop Database +#################################### +# Stop MySQL +msg_debug "Stop database" +/usr/bin/mysqladmin shutdown + +# Wait MySQL stop +wait $mysql_pid + +#################################### +# End +#################################### +msg_info "[$(basename $0):$LINENO] => END" + diff --git a/server/debian/common/servercontainer_configure_patch.sh b/server/debian/common/servercontainer_configure_patch.sh new file mode 100755 index 0000000..d424e5c --- /dev/null +++ b/server/debian/common/servercontainer_configure_patch.sh @@ -0,0 +1,375 @@ +#!/bin/bash +# +# Configure Patch Server +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#declare DIRCLIENT="Khanat_Linux64" +#declare PREPARE_CLIENT_DIR="khanat/prepare_client/$DIRCLIENT" +#declare CLIENT_DIR="khanat/client_service" + +usage() +{ +cat << EOF +usage:$0 [options] + Configure Patch Server + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + + +##################### +# MAIN +##################### +source /opt/ext/servercontainer_function.sh +msg_info "[$(basename $0):$LINENO] => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + *) + msg_error "[$(basename $0):$LINENO] options '$1' not recognize" + usage + exit 1 + ;; + esac +done + + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + msg_error "[$(basename $0):$LINENO] Missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +if [[ ! -f /home/gameserver/.bashrc ]] +then + msg_error "[$(basename $0):$LINENO] Missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + +#declare HOME_PREPARE_CLIENT="$KHANAT_HOME/$PREPARE_CLIENT_DIR" +#declare HOME_CLIENT="$KHANAT_HOME/$CLIENT_DIR" + +#################################### +# Prepare language directory +#################################### +msg_info "[$(basename $0):$LINENO] Create language directory" +listlang=$(ls $KHANAT_PATH/server/translation/translated | cut -f 1 -d '.' | sed 's/^.*\(.\{2\}\)$/\1/' | sort | uniq | tr '\n' ' ') +msg_info "[$(basename $0):$LINENO] LIST LANG : ${listlang[@]}" + +create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver" +for lang in $listlang +do + create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/kh_translate_$lang" || exit 2 +done + + +#################################### +# Create link with data +#################################### +msg_info "[$(basename $0):$LINENO] COPY DATA TO GENERATE PATCH" +create_link "$KHANAT_PATH/server/common/data_common/database.xml" "$PATCH_CLIENT_SYSTEM/kh_server" +create_link "$KHANAT_PATH/server/common/data_common/msg.xml" "$PATCH_CLIENT_SYSTEM/kh_server" +for file in $KHANAT_PATH/server/client/data/*.packed_sheets +do + create_link "$file" "$PATCH_CLIENT_SYSTEM/kh_server" +done + +for file in $KHANAT_PATH/server/client/data/*.packed +do + create_link "$file" "$PATCH_CLIENT_SYSTEM/kh_server" +done + +create_link "$KHANAT_PATH/visual_slot.tab" "$PATCH_CLIENT_SYSTEM/kh_server/" || exit 2 +create_link "$KHANAT_PATH/server/leveldesign/game_elem/sheet_id.bin" "$PATCH_CLIENT_SYSTEM/kh_server/" || exit 2 +# create_link "$KHANAT_HOME/ext/khanat-client-data/data" "$PATCH_CLIENT_SYSTEM/dataserver" || exit 2 +#create_recursive_link "$KHANAT_HOME/ext/khanat-client-data/data" "$PATCH_CLIENT_SYSTEM/dataserver/data" || exit 2 + + +#################################### +# Copy Language +#################################### +msg_info "[$(basename $0):$LINENO] Create other directory" +# language : copy to client (to generate client patch) +for lang in $listlang +do + # cp $KHANAT_PATH/server/translation/translated/*$lang.* $PATCH_CLIENT_SYSTEM/dataserver/kh_translate_$lang/ || exit 2 + for file in $KHANAT_PATH/server/translation/translated/*$lang.* + do + create_link "$file" "$PATCH_CLIENT_SYSTEM/dataserver/kh_translate_$lang/" || exit 2 + done +done + + +#################################### +# prepare package languages +#################################### +msg_info "[$(basename $0):$LINENO] Prepare package languages" +init_job +for lang in $listlang +do + comment[${#comment[@]}]="$lang" + launch_job "(cd $PATCH_CLIENT_SYSTEM/dataserver/; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/kh_translate_$lang -p kh_translate_$lang 2>$KHANAT_HOME/log/configure/patch_kh_translate_$lang.err 1>$KHANAT_HOME/log/configure/patch_kh_translate_$lang.out)" "kh_translate_$lang" +done +wait_all_job || exit 2 + + +#################################### +# prepare package fonts +#################################### +msg_info "[$(basename $0):$LINENO] Prepare package fonts" +init_job +#launch_job "(cd $PATCH_CLIENT_SYSTEM/dataserver/; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/fonts -p fonts 2>$KHANAT_HOME/log/configure/patch_fonts.err 1>$KHANAT_HOME/log/configure/patch_fonts.out)" "fonts" +launch_job "(cd $KHANAT_HOME/ext/khanat-client-data/data; bnp_make -o$HOME_PREPARE_CLIENT/data -p fonts 2>$KHANAT_HOME/log/configure/patch_fonts.err 1>$KHANAT_HOME/log/configure/patch_fonts.out)" "fonts" +wait_all_job || exit 2 + + +#################################### +# prepare package kh +#################################### +msg_info "[$(basename $0):$LINENO] Prepare package kh" +init_job +#for dir in $PATCH_CLIENT_SYSTEM/dataserver/data/kh/* +#do +# filename=$(basename "$dir") +# msg_info "filename:$filename" +# launch_job "(cd $dir/..; bnp_make -p $filename 2>$KHANAT_HOME/log/configure/dataserver_data_$filename.err 1>$KHANAT_HOME/log/configure/dataserver_data_$filename.out)" "dataserver_data_$filename" +#done +for dir in $KHANAT_HOME/ext/khanat-client-data/data/kh/* +do + filename=$(basename "$dir") + msg_debug "filename:$filename" + launch_job "(cd $KHANAT_HOME/ext/khanat-client-data/data/kh; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/$filename -p $filename 2>$KHANAT_HOME/log/configure/dataserver_data_$filename.err 1>$KHANAT_HOME/log/configure/patch_kh_$filename.out)" "patch_kh_$filename" +done +wait_all_job || exit 2 + + +#################################### +# prepare package kh_shard +#################################### +msg_info "[$(basename $0):$LINENO] Prepare package kh_shard" +init_job +for dir in $KHANAT_HOME/ext/khanat-client-data/data/kh_shard/* +do + filename=$(basename "$dir") + msg_debug "filename:$filename" + launch_job "(cd $KHANAT_HOME/ext/khanat-client-data/data/kh_shard; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/$filename -p $filename 2>$KHANAT_HOME/log/configure/patch_kh_shard_$filename.err 1>$KHANAT_HOME/log/configure/patch_kh_shard_$filename.out)" "patch_kh_shard_$filename" +done +wait_all_job || exit 2 + + +#################################### +# prepare package ryz +#################################### +msg_info "[$(basename $0):$LINENO] Prepare package ryz" +init_job +for dir in $KHANAT_HOME/ext/khanat-client-data/data/ryz/* +do + filename=$(basename "$dir") + msg_debug "filename:$filename" + launch_job "(cd $KHANAT_HOME/ext/khanat-client-data/data/ryz; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/$filename -p $filename 2>$KHANAT_HOME/log/configure/patch_ryz_$filename.err 1>$KHANAT_HOME/log/configure/patch_ryz_$filename.out)" "patch_ryz_$filename" +done +wait_all_job || exit 2 + + +#################################### +# prepare package client +#################################### +## TODO - check how generate '.ref' files +msg_info "[$(basename $0):$LINENO] Prepare package patch_client" +init_job +for dir in $KHANAT_HOME/ext/khanat-client-data/client/* +do + filename=$(basename "$dir") + msg_debug "filename:$filename" + launch_job "(cd $KHANAT_HOME/ext/khanat-client-data/client; bnp_make -o$KHANAT_HOME/khanat/patch_service/dataserver/client/$filename -p $filename 2>$KHANAT_HOME/log/configure/patch_client_$filename.err 1>$KHANAT_HOME/log/configure/patch_client_$filename.out)" "patch_client_$filename" +done +wait_all_job || exit 2 + +for file in $KHANAT_HOME/khanat/patch_service/dataserver/client/*.bnp +do + filename="$(basename ${file%.bnp})_.ref" + mv "$file" "$PATCH_CLIENT_SYSTEM/patch_game/bnp/$filename" || exit 2 +done + + +#################################### +# prepare package kh_server +#################################### +msg_info "[$(basename $0):$LINENO] Prepare package kh_server" +init_job +launch_job "(cd $PATCH_CLIENT_SYSTEM/; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/kh_server -p kh_server 2>$KHANAT_HOME/log/configure/patch_kh_server.err 1>$KHANAT_HOME/log/configure/patch_kh_server.out)" "kh_server" +wait_all_job || exit 2 + + +#################################### +# prepare patch +#################################### +msg_info "[$(basename $0):$LINENO] Prepare Patch" + +cd $PATCH_CLIENT_SYSTEM;patch_gen createNewProduct patch_game/ryzom.xml 2>$KHANAT_HOME/log/configure/patch_createNewProduct.err 1>$KHANAT_HOME/log/configure/patch_createNewProduct.out || exit 2 +cd $PATCH_CLIENT_SYSTEM;touch patch_game/Lirria.version || exit 2 +sed -i -r 's/value="main"/value="khanat_lirria"/g' $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml || exit 2 +sed -i -r 's/_NextVersionFile type="STRING" value=""/_NextVersionFile type="STRING" value="patch_game\/Lirria.version"/g' $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml || exit 2 + + +# Edit RYZOM file +# search all ref files +ADDREF="" +for file in $PATCH_CLIENT_SYSTEM/patch_game/bnp/*.ref +do + ADDREF="$ADDREF"'<_Files type=\"STRING\" value=\"'$(basename $file)'\"/>' +done + +cp $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml.ref || exit 2 +awk 'BEGIN{found=0}{ + if(found==0 && $1 == "<_Category>") { + found = 1; + } else if(found == 1 && $1 == "") { + found = 2; + print "'"$ADDREF"'"; + print $0; + } else if(found == 2 && $1 == "") { + found = 3; + } + if ( found != 2 ) { + print $0 + } +}' $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml.ref > $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml || exit 2 + +if [[ -f $PATCH_CLIENT_SYSTEM/patch_game/Lirria.version ]] +then + export KHANAT_CLIENT_VERSION=$(cat $PATCH_CLIENT_SYSTEM/patch_game/Lirria.version) +else + if [[ -z "$KHANAT_CLIENT_VERSION" ]] + then + KHANAT_CLIENT_VERSION=1 + fi +fi + +msg_info "[$(basename $0):$LINENO] CLIENT VERSION: $KHANAT_CLIENT_VERSION" +echo -n "$KHANAT_CLIENT_VERSION" > $PATCH_CLIENT_SYSTEM/patch_game/Lirria.version + +#################################### +# prepare patch +#################################### +msg_info "[$(basename $0):$LINENO] Generate patch" +cd $PATCH_CLIENT_SYSTEM; patch_gen updateProduct patch_game/ryzom.xml 2>$KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.err 1>$KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.out || exit 2 + +#################################### +# Edit release note +#################################### +msg_info "[$(basename $0):$LINENO] Edit release note" + +# Added files for version +REALVERSION=$(awk '{if($0 ~ /patch_gen_common.cpp 330 addVersion : Added files for version:/){print $12}}' $KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.out) + +msg_info "CLIENT VERSION: $REALVERSION" +cat << EOF > $PATCH_CLIENT_SYSTEM/patch_game/patch/index.php + + + + + +

New test data - Release $REALVERSION

+

An update will now be performed to your client(the /user directory to be exact). + Please help us test the deployment of our free MMORPG server!! + + +EOF + + +# TODO - Strange, we need update patch - to be check +cat << EOF > $PATCH_CLIENT_SYSTEM/patch_game/patch/Lirria.version +$REALVERSION $REALVERSION +EOF + +#################################### +# Prepare client package +#################################### +if [[ ! -f $HOME_CLIENT/${PACKAGECLIENT}.tar.gz ]] +then + msg_info "[$(basename $0):$LINENO] Prepare client package" + cp /usr/local/bin/khanat_client $HOME_PREPARE_CLIENT/. || exit 2 + cp /home/gameserver/ext/ryzom-ressources/client/client_default.cfg $HOME_PREPARE_CLIENT/. || exit 2 + sed -i -r 's/PatchWanted = 0;/PatchWanted = 1;/g' $HOME_PREPARE_CLIENT/client_default.cfg || exit 2 + + cp $PATCH_CLIENT_SYSTEM/patch_game/bnp/kh_translate_{wk,fr,en}.bnp $HOME_PREPARE_CLIENT/data/. || exit 2 + cp $KHANAT_HOME/ext/khanat-client-data/client/exedll_linux64/khanat.png $HOME_PREPARE_CLIENT/data/. || exit 2 + # cp $PATCH_CLIENT_SYSTEM/dataserver/data/fonts.bnp $HOME_PREPARE_CLIENT/data/. || exit 2 + cp $PATCH_CLIENT_SYSTEM/patch_game/bnp/kh_interfaces.bnp $HOME_PREPARE_CLIENT/data/. || exit 2 + cp $PATCH_CLIENT_SYSTEM/patch_game/bnp/ryz_zzz_bazaar.bnp $HOME_PREPARE_CLIENT/data/. || exit 2 + cp $KHANAT_HOME/ext/ryzom-ressources/client/cfg/* $HOME_PREPARE_CLIENT/cfg/. || exit 2 + + # TODO - we need search where are define some files + # .DS_Store : function ? + # khanat_install_desktop_menu.sh : script to install khanat on desktop + # khanat.desktop.in : config desktop for khanat + # khanat_install_desktop_menu.sh : script to uninstall khanat on desktop +fi + +#################################### +# Generate client package +#################################### +# Generate package +msg_info "[$(basename $0):$LINENO] Generate client package" +if [[ ! -f $HOME_CLIENT/$PACKAGECLIENT.tar.gz ]] +then + msg_info "[$(basename $0):$LINENO] Generate package" + (cd $HOME_PREPARE_CLIENT/..; tar cfz $HOME_CLIENT/$PACKAGECLIENT.tar.gz $DIRCLIENT) +fi + +#################################### +# Create web page to present this package +#################################### +msg_info "[$(basename $0):$LINENO] create index.html for client" +cat << EOF > $HOME_CLIENT/index.html + + + +KHANAT CLIENT + + + +

You can download khanat client - release $KHANAT_CLIENT_VERSION

+khanat client + + + +EOF + +#################################### +# End +#################################### +msg_info "[$(basename $0):$LINENO] => END" + diff --git a/server/debian/common/servercontainer_configure_world.sh b/server/debian/common/servercontainer_configure_world.sh new file mode 100755 index 0000000..b6b50b5 --- /dev/null +++ b/server/debian/common/servercontainer_configure_world.sh @@ -0,0 +1,280 @@ +#!/bin/bash +# +# Configure MySQL +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +declare DEBUG=0 + +usage() +{ +cat << EOF +usage:$0 [options] + prepare mysql (create directory, update configuration) + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +##################### +# MAIN +##################### +source /opt/ext/servercontainer_function.sh +msg_info "$(basename $0) => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +if [[ ! -f /home/gameserver/.bashrc ]] +then + msg_error "Missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + + +#################################### +# Start mysql & apache +#################################### +msg_debug "Start mysql" +# start/restart service mysql & apache +sudo service mysql start || exit 2 + +# Wait mysql start +msg_info "Check database is started" +sleep 1 +until sudo /usr/bin/mysqladmin ping >/dev/null 2>&1 +do + echo -n "." + sleep 1 +done +echo "" +sleep 1 + +msg_debug "start apache" +sudo service apache2 start || exit 2 + + +#################################### +# Create account +#################################### +msg_debug "Create account" +# Create account shard on MySQL +mysql -u root -e "CREATE USER 'shard'@'localhost' IDENTIFIED BY '';" || exit 2 +mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'shard'@'localhost' WITH GRANT OPTION;" || exit 2 + + +#################################### +# launch web configuration for khanat +#################################### +msg_debug "launch web configuration for khanat" +curl 'http://localhost:40916/setup/install.php' \ + -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ + -H 'Accept-Language: en-US' \ + -H 'Connection: keep-alive' \ + -H 'Cookie: PHPSESSID=9jr1ssig58929bp777nrj2fa92' \ + -H 'DNT: 1' \ + -H 'Host: localhost:40916' \ + -H 'Referer: http://localhost:40916/setup/install.php' \ + -H 'Upgrade-Insecure-Requests: 1' \ + -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0' \ + -H 'Content-Type: application/x-www-form-urlencoded' \ + --data 'roleService=on'\ +'&roleSupport=on'\ +'&roleDomain=on'\ +'&privatePhpDirectory=..%2Fprivate_php%2F'\ +'&nelSetupPassword=admin'\ +'&nelSqlHostname=localhost'\ +'&nelSqlUsername=root'\ +'&nelSqlPassword='\ +'&nelDatabase=nel'\ +'&toolDatabase=nel_tool'\ +'&toolsAdminUsername=admin'\ +'&toolsAdminPassword=admin'\ +'&amsSqlHostname=localhost'\ +'&amsSqlUsername=root'\ +'&amsSqlPassword='\ +'&amsDatabase=nel_ams'\ +'&amsLibDatabase=nel_ams_lib'\ +'&amsAdminUsername=admin'\ +'&amsAdminPassword=admin'\ +'&nelDomainName=Lirria'\ +'&domainDatabase=ring_mini01'\ +'&submit=Configure' \ + -o $KHANAT_HOME/log/configure/world_setup.html || exit 2 + +chown_gameserver $KHANAT_HOME/log/configure/world_setup.html + +# Check account is create +grep "Domain role successfully installed" $KHANAT_HOME/log/configure/world_setup.html >/dev/null || exit 2 + + +#################################### +# Get IP ADDRESS +#################################### +msg_debug "Get IP ADDRESS" +tmp=$(hostname -I) +export addressip=${tmp//[[:blank:]]/} + + +#################################### +## Configure Domain +#################################### +msg_debug "Configure Domain" +mysql -u root -e "use nel; +INSERT INTO nel.domain (domain_id, domain_name, status, patch_version, backup_patch_url, patch_urls, login_address, session_manager_address, ring_db_name, web_host, web_host_php, description) VALUES ('12', 'Lirria', 'ds_open', '$KHANAT_CLIENT_VERSION', '$addressip:23001', '$addressip/patch', '$addressip:49998', '$addressip:49999', 'ring_mini01', '$addressip:30000', '$addressip:40916', NULL);" || exit 2 + + +#################################### +# Configure nel.shard +#################################### +msg_debug "Configure nel.shard" +mysql -u root -e "use nel; +INSERT INTO nel.shard (ShardId, domain_id, WsAddr, NbPlayers, Name, Online, Version, FixedSessionId, State, MOTD) VALUES ('302', '12', '$addressip:', '0', 'Lirria shard', '0', '', '0', 'ds_open', '');" || exit 2 + +#################################### +# Configure nel_tool.neltool_domains +#################################### +msg_debug "Configure nel_tool.neltool_domains" +mysql -u root -e "use nel; +INSERT INTO nel_tool.neltool_domains (domain_id, domain_name, domain_as_host, domain_as_port, domain_rrd_path, domain_las_admin_path, domain_las_local_path, domain_application, domain_sql_string, domain_hd_check, domain_mfs_web, domain_cs_sql_string) VALUES ('12', 'Lirria', '$addressip', '46700', '/home/gameserver/khanat/server/save_shard/rrd_graphs', '', '', 'ryzom_open', '', '0', NULL, NULL);" || exit 2 + + +#################################### +# configure nel_tool.neltool_shards +#################################### +msg_debug "Configure nel_tool.neltool_shards" +mysql -u root -e "use nel; +INSERT INTO nel_tool.neltool_shards (shard_id, shard_name, shard_as_id, shard_domain_id, shard_lang, shard_restart) VALUES ('302', 'open', 'open', '12', 'fr', '0');" || exit 2 + + +#################################### +# configure nel_tool.neltool_user_domains +#################################### +msg_debug "Configure nel_tool.neltool_user_domains" +mysql -u root -e "use nel; +INSERT INTO nel_tool.neltool_user_domains (user_domain_id, user_domain_user_id, user_domain_domain_id) VALUES ('1', '1', '12');" || exit 2 + + +#################################### +# configure nel_tool.neltool_user_shards +#################################### +msg_debug "Configure nel_tool.neltool_user_shards" +mysql -u root -e "use nel; +INSERT INTO nel_tool.neltool_user_shards (user_shard_id, user_shard_user_id, user_shard_shard_id, user_shard_domain_id) VALUES ('1', '1', '302', '12');" || exit 2 + + +#################################### +# configure ring_mini01.sessions +#################################### +msg_debug "Configure ring_mini01.sessions" +mysql -u root -e "use ring_mini01; +INSERT INTO ring_mini01.sessions (session_id, session_type, title, owner, plan_date, start_date, description, orientation, level, rule_type, access_type, state, host_shard_id, subscription_slots, reserved_slots, free_slots, estimated_duration, final_duration, folder_id, lang, icone, anim_mode, race_filter, religion_filter, guild_filter, shard_filter, level_filter, subscription_closed, newcomer) VALUES ('302', 'st_mainland', '', '0', '2005-09-21 12:41:33.000000', '2005-08-31 00:00:00.000000', '', 'so_other', 'sl_a', 'rt_strict', 'at_private', 'ss_planned', '0', '0', '0', '0', 'et_short', '0', '0', '', '', 'am_dm', '', '', 'gf_only_my_guild', 'sf_shard00,sf_shard01,sf_shard02,sf_shard03,sf_shard04,sf_shard05,sf_shard06,sf_shard07,sf_shard08,sf_shard09,sf_shard10,sf_shard11,sf_shard12,sf_shard13,sf_shard14,sf_shard15,sf_shard16,sf_shard17,sf_shard18,sf_shard19,sf_shard20,sf_shard21,sf_shard22,sf_shard23,sf_shard24,sf_shard25,sf_shard26,sf_shard27,sf_shard28,sf_shard29,sf_shard30', 'lf_a,lf_b,lf_c,lf_d,lf_e,lf_f', '0', '0');" || exit 2 + + +#################################### +## Create one user 'tester' (password : tester) +#################################### +msg_debug "Create one user" +declare accountuser="tester" +declare passworduser="tester" +curl 'http://localhost:40916/ams/index.php' \ + -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ + -H 'Accept-Language: en-US' \ + -H 'Connection: keep-alive' \ + -H 'Cookie: PHPSESSID=lsoumn9f0ljgm3vo3hgjdead03' \ + -H 'DNT: 1' \ + -H 'Host: localhost:40916' \ + -H 'Referer: http://localhost:40916/ams/index.php?page=register' \ + -H 'Upgrade-Insecure-Requests: 1' \ + -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0' \ + -H 'Content-Type: application/x-www-form-urlencoded' \ + --data 'Username='"$accountuser"'&Password='"$passworduser"'&ConfirmPass=tester&Email=tester%40khaganat.net&TaC=on&function=add_user' \ + -o $KHANAT_HOME/log/configure/world_account_tester.log || exit 2 + + +#################################### +# configure nel.permission +#################################### +msg_debug "Create nel.permission" +mysql -u root -e "use nel; +UPDATE nel.permission SET AccessPrivilege = 'OPEN,DEV,RESTRICTED'; +" || exit 2 + + +#################################### +# Stop Database & apache +#################################### +msg_debug "Stop Database & apache" +# start/restart service mysql & apache +sudo service apache2 stop || exit 2 +sudo service mysql stop || exit 2 + +# Change right for file mysql +# TODO - remove creation of this file +chown_gameserver "$KHANAT_HOME/database/mysql_upgrade_info" + +#################################### +# End +#################################### +msg_info "$(basename $0) => END" + diff --git a/server/debian/common/servercontainer_function.sh b/server/debian/common/servercontainer_function.sh new file mode 100755 index 0000000..5584b0c --- /dev/null +++ b/server/debian/common/servercontainer_function.sh @@ -0,0 +1,235 @@ +#!/bin/bash +# +# Function use in preparation & configuration +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +###################### +# Write output +###################### +declare -i DEBUG=0 + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +function msg_critical() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") CRITICAL - $*" >&2 + exit 2 +} + +function set_debug() +{ + if [[ -n "$1" ]] + then + DEBUG=$1 + else + DEBUG=0 + fi +} + +###################### +# function to change owner for gameserver +###################### +function chown_gameserver() +{ + # gameserver:$(id -g -n gameserver) + chown $UIDGAMESERVER:$GIDGAMESERVER "$1" || exit 2 +} + +###################### +# function duplicate/link file +###################### +function copy_link() +{ + if [[ -z "$1" ]] + then + msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)" + exit 2 + fi + + if [ ! -f "$1" ] + then + msg_error "[$(basename $0):$LINENO] Missing source : '$1'" + exit 2 + fi + mv "$1" "$1.old" || exit 2 + cp "$1.old" "$1" || exit 2 + chown_gameserver "$1" || exit 2 +} + +function create_link() +{ + if [[ -z "$1" ]] + then + msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)" + exit 2 + fi + if [[ -z "$2" ]] + then + msg_error "[$(basename $0):$LINENO] Missing 2nd argument (destination)" + exit 2 + fi + + filename_l=$(basename "$1") + + msg_debug "[$(basename $0):$LINENO] create link $2/$filename_l" + if [ -e "$2/$filename_l" ] + then + rm "$2/$filename_l" || exit 2 + elif [ -h "$2/$filename_l" ] + then + rm "$2/$filename_l" || exit 2 + fi + if [[ (! -e "$1") && (! -h "$1") ]] + then + msg_error "[$(basename $0):$LINENO] Missing source : '$1'" + exit 2 + fi + ln -s "$1" "$2/$filename_l" || exit 2 + chown --no-dereference $UIDGAMESERVER:$GIDGAMESERVER "$2/$filename_l" || exit 2 +} + +function create_recursive_link() +{ + if [[ -z "$1" ]] + then + msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)" + exit 2 + fi + if [[ -z "$2" ]] + then + msg_error "[$(basename $0):$LINENO] Missing 2nd argument (destination)" + exit 2 + fi + + msg_debug "[$(basename $0):$LINENO] link $1 -> $2" + for file in $1/* + do + if [ -d "$file" ] + then + filename=$(basename "$file") + msg_debug "[$(basename $0):$LINENO] create dir $2/$filename" + if [ ! -f "$2/$filename" ] + then + mkdir -p "$2/$filename" || exit 2 + fi + chown $UIDGAMESERVER:$GIDGAMESERVER "$2/$filename" || exit 2 + create_recursive_link "$file" "$2/$filename" || exit 2 + else + create_link "$file" "$2" || exit 2 + fi + done +} + +function create_link_2nd_level() +{ + # Function to create link + if [[ -z "$1" ]] + then + msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)" + exit 2 + fi + if [[ -z "$2" ]] + then + msg_error "[$(basename $0):$LINENO] Missing 2nd argument (destination)" + exit 2 + fi + + for file in $1 + do + create_link "$file" "$2" || exit 2 + done +} + +function create_dir_gameserver() +{ + if [ -z "$1" ] + then + msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)" + exit 2 + fi + mkdir -p "$1" || exit 2 + chown $UIDGAMESERVER:$GIDGAMESERVER "$1" || exit 2 +} + +function create_file_gameserver() +{ + if [ -z "$1" ] + then + msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)" + exit 2 + fi + touch "$1" || exit 2 + chown $UIDGAMESERVER:$GIDGAMESERVER "$1" || exit 2 +} + +###################### +### Manage multi process +###################### +declare -A JOBS +declare -A COMMENTJOBS + +function init_job() +{ + unset JOBS + unset COMMENTJOBS +} + +function launch_job() +{ + msg_debug "[$(basename $0):$LINENO] Launch job '$2'" + eval $1 & + JOBS[$!]="$1" + COMMENTJOBS[$!]="$2" +} + +function wait_all_job() +{ + local cmd + local code=0 + for pid in ${!JOBS[@]} + do + msg_debug "[$(basename $0):$LINENO] Wait job '${COMMENTJOBS[$pid]}' (pid:$pid) " + cmd=${JOBS[${pid}]} + wait ${pid} + JOBS[${pid}]=$? + if [[ ${JOBS[${pid}]} -ne 0 ]] + then + code=${JOBS[${pid}]} + msg_error "[$(basename $0):$LINENO] '${COMMENTJOBS[$pid]}' Exited with error [return code:$code, pid:${pid}, command:'${cmd}']" + fi + done + return $code +} + +###################### +# +###################### diff --git a/server/debian/common/servercontainer_init_apache.sh b/server/debian/common/servercontainer_init_apache.sh new file mode 100755 index 0000000..e9e7f91 --- /dev/null +++ b/server/debian/common/servercontainer_init_apache.sh @@ -0,0 +1,221 @@ +#!/bin/bash +# +# Prepare/Configure Apache +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +usage() +{ +cat << EOF +usage:$0 [options] + prepare mysql (create directory, update configuration) + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +##################### +# MAIN +##################### +source /opt/servercontainer_function.sh +msg_info "$(basename $0) => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + + +#################################### +# Configure apache log / Account use by apache +#################################### +msg_debug "Configure apache log / Account use by apache" +sed -i -r 's/^export[[:space:]]+APACHE_RUN_USER=(.*)/export APACHE_RUN_USER=gameserver/g' /etc/apache2/envvars || exit 2 +sed -i -r 's/^export[[:space:]]+APACHE_RUN_GROUP=(.*)/export APACHE_RUN_GROUP='$(id -g -n gameserver)'/g' /etc/apache2/envvars || exit 2 +sed -i -r 's/^export[[:space:]]+APACHE_LOG_DIR=(.*)/export APACHE_LOG_DIR=\/home\/gameserver\/log\/apache2\$SUFFIX/g' /etc/apache2/envvars || exit 2 +sed -i -r 's/^LogLevel[[:space:]]+warn/LogLevel debug/g' /etc/apache2/apache2.conf || exit 2 + + + +#################################### +# configure phpmyadmin +#################################### +msg_debug "configure phpmyadmin" +ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf || exit 2 +a2enconf phpmyadmin.conf || exit 2 +cp /etc/phpmyadmin/config.inc.php /etc/phpmyadmin/config.inc.php.ref || exit 2 +awk '{if($0 ~ /AllowNoPassword/){$1="";}; print $0;}' /etc/phpmyadmin/config.inc.php.ref > /etc/phpmyadmin/config.inc.php || exit 2 + + +#################################### +# configure phpmyadmin +#################################### +msg_debug "configure apache" +# configure apache +cat << EOF > /etc/apache2/sites-available/000-default.conf +# Default + + + Options Indexes FollowSymLinks + AllowOverride None + Require all granted + DirectoryIndex index.php + AddType text/html .php .phps + AddHandler application/x-httpd-php .php + AddHandler application/x-httpd-php-source .phps + + ServerName lirria.khaganat.net + + ServerAdmin webmaster@localhost + DocumentRoot /home/gameserver/khanat/khanatweb/public_php/ + + ErrorLog \${APACHE_LOG_DIR}/error.log + CustomLog \${APACHE_LOG_DIR}/access.log combined + + +# Khanat Server Web + + + Options Indexes FollowSymLinks + AllowOverride None + Require all granted + + ServerName lirria.khaganat.net + + ServerAdmin admin@localhost + DocumentRoot /home/gameserver/khanat/khanatweb/public_php + + ErrorLog \${APACHE_LOG_DIR}/error.log + CustomLog \${APACHE_LOG_DIR}/access.log combined + + +# Patch Server + + ServerName lirria.khaganat.net + DocumentRoot /home/gameserver/khanat/patch_service/patch_game/patch/ + + + Options -Indexes + AllowOverride All + Require all granted + + +EOF + +# Open port use by apache +cat << EOF > /etc/apache2/ports.conf +# If you just change the port or add more ports here, you will likely also +# have to change the VirtualHost statement in +# /etc/apache2/sites-enabled/000-default.conf + +Listen 80 +Listen 40916 +Listen 43435 + + + Listen 443 + + + + Listen 443 + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet +EOF + + +# Activate php - strange beacause we have only index.php (without php code !) +cat << EOF > /etc/apache2/conf-available/patch_service.conf +Alias /patch /home/gameserver/khanat/patch_service/patch_game/patch + + Options FollowSymLinks + DirectoryIndex index.php + + Require all granted + + + + AddType application/x-httpd-php .php + + + SetHandler application/x-httpd-php + + + +EOF + +# Configuration de la page client +cat << EOF > /etc/apache2/conf-available/client_service.conf +Alias /client /home/gameserver/khanat/client_service + + Options FollowSymLinks + DirectoryIndex index.html + + Require all granted + + + AddType application/tar .tar.gz + + + SetHandler application/tar + + + +EOF + +#################################### +# Activate web site +#################################### + +msg_info "Activate patch service" +# Activate & deploy new configuration +a2enconf patch_service.conf + +msg_info "Activate client service" +# Activate & deploy new configuration +a2enconf client_service.conf + + +#################################### +# End +#################################### +msg_info "$(basename $0) => END" diff --git a/server/debian/common/servercontainer_init_configure_envi.sh b/server/debian/common/servercontainer_init_configure_envi.sh new file mode 100755 index 0000000..4db1ff9 --- /dev/null +++ b/server/debian/common/servercontainer_init_configure_envi.sh @@ -0,0 +1,231 @@ +#!/bin/bash +# +# Configure environment +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +usage() +{ +cat << EOF +usage:$0 [options] + prepare mysql (create directory, update configuration) + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +##################### +# MAIN +##################### +source /opt/servercontainer_function.sh +msg_info "$(basename $0) => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + msg_error "Missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +#################################### +# configure shard.sh +#################################### +msg_info "configure shard.sh" +cat << EOF > /opt/shard.sh +# bashrc: executed by bash(1) for non-login shells. + +# You may uncomment the following lines if you want 'ls' to be colorized: +export SHELL=/bin/bash +export LS_OPTIONS='--color=auto' +eval "\`dircolors\`" +alias ls='ls \$LS_OPTIONS' +alias ll='ls \$LS_OPTIONS -l' +alias l='ls \$LS_OPTIONS -lA' + +# Some more alias to avoid making mistakes: +# alias rm='rm -i' +# alias cp='cp -i' +# alias mv='mv -i' + +# Autocompletion +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi + +export KHANAT_HOME=/home/gameserver +export KHANAT_PATH=/home/gameserver/khanat +export PATH=\$PATH:/usr/local/bin:/usr/local/sbin +export PATCH_CLIENT_SYSTEM=\$KHANAT_HOME/khanat/patch_service + +export DIRCLIENT="$DIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +export PREPARE_CLIENT_DIR="khanat/prepare_client/\$DIRCLIENT" +export CLIENT_DIR="khanat/client_service" +export HOME_PREPARE_CLIENT="\$KHANAT_HOME/\$PREPARE_CLIENT_DIR" +export HOME_CLIENT="\$KHANAT_HOME/\$CLIENT_DIR" +EOF + + +#################################### +# Initialize bashrc gameserver +#################################### +msg_info "configure bashrc" +cat << EOF > /home/gameserver/.bashrc +# bashrc: executed by bash(1) for non-login shells. + +# You may uncomment the following lines if you want 'ls' to be colorized: +export SHELL=/bin/bash +export LS_OPTIONS='--color=auto' +eval "\`dircolors\`" +alias ls='ls \$LS_OPTIONS' +alias ll='ls \$LS_OPTIONS -l' +alias l='ls \$LS_OPTIONS -lA' + +# Some more alias to avoid making mistakes: +# alias rm='rm -i' +# alias cp='cp -i' +# alias mv='mv -i' + +# Autocompletion +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi + +export KHANAT_HOME=/home/gameserver +export KHANAT_PATH=/home/gameserver/khanat +export PATH=\$PATH:/usr/local/bin +export PATCH_CLIENT_SYSTEM=\$KHANAT_HOME/khanat/patch_service + +export DIRCLIENT="$DIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +export PREPARE_CLIENT_DIR="khanat/prepare_client/\$DIRCLIENT" +export CLIENT_DIR="khanat/client_service" +export HOME_PREPARE_CLIENT="\$KHANAT_HOME/\$PREPARE_CLIENT_DIR" +export HOME_CLIENT="\$KHANAT_HOME/\$CLIENT_DIR" + +EOF +chown gameserver:$(id -g -n gameserver) /home/gameserver/.bashrc + + +# load environment +source /home/gameserver/.bashrc + +#################################### +# Initialize bashrc (for root) +#################################### +msg_debug "Configure bashrc (for root)" +cat << EOF > /root/.bashrc +# bashrc: executed by bash(1) for non-login shells. + +# You may uncomment the following lines if you want 'ls' to be colorized: +export SHELL=/bin/bash +export LS_OPTIONS='--color=auto' +eval "\`dircolors\`" +alias ls='ls \$LS_OPTIONS' +alias ll='ls \$LS_OPTIONS -l' +alias l='ls \$LS_OPTIONS -lA' + +# Some more alias to avoid making mistakes: +# alias rm='rm -i' +# alias cp='cp -i' +# alias mv='mv -i' + +# Autocompletion +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi +EOF + +#################################### +# Adding sudo command +#################################### + +# Update sudo rule (you can execute all command as root) +msg_debug "Configure sudo" +cat << EOF > /etc/sudoers.d/gameserver +# User privilege specification +gameserver ALL=NOPASSWD: ALL +EOF + +#################################### +# LOGING HEADER +#################################### +# Message see when connect on ssh + +# Before login +msg_debug "Configure message login" +cat << EOF > /etc/issue.net +********************* +* KHANAT SERVER DEV * +********************* + +account gameserver +password khanat + +EOF + +# After Login +msg_debug "Configure banner" +cat << EOF > /etc/motd +*************************************************** +connect to root use gameserver account and launch sudo command +like : + + sudo bash + +--------------------------------------------------- +mysql : account root (no password) +--------------------------------------------------- +log khanat server : /home/gameserver/khanat/server/log/log.log +*************************************************** +EOF + +# Activate banner +msg_debug "Activate banner" +sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config + + +# Initialize ssh +/etc/init.d/ssh restart + +#################################### +# End +#################################### +msg_info "$(basename $0) => END" diff --git a/server/debian/common/servercontainer_init_create_account.sh b/server/debian/common/servercontainer_init_create_account.sh new file mode 100755 index 0000000..60a9bdb --- /dev/null +++ b/server/debian/common/servercontainer_init_create_account.sh @@ -0,0 +1,82 @@ +#!/bin/bash +# +# Create account gameserver +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +usage() +{ +cat << EOF +usage:$0 [options] + create account gameserver + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +##################### +# MAIN +##################### +source /opt/servercontainer_function.sh +msg_info "$(basename $0) => START" + + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +#################################### +# Configure account gameserver +#################################### +msg_debug "Create gameserver account (shared with host)" +groupadd --gid $GIDGAMESERVER gameserver || echo "group id already exist" +useradd --uid $UIDGAMESERVER --gid $GIDGAMESERVER -G sudo -c /home -d /home/gameserver -c "Khanat account GAME" -m -p '$6$nxHX/3u.$azS0.eldpfKqxqOLDjgZj8.hPOLC64arXDTUVX0fs7RZvRBX/pNqPzDR89ccP5XkEE/daOyaD3wVtDGDUND5b/' -s /bin/bash gameserver +msg_debug "group : $(id -g -n gameserver)" + +create_dir_gameserver '/home/gameserver/ext' +create_dir_gameserver '/home/gameserver/khanat' + +#################################### +# End +#################################### +msg_info "$(basename $0) => END" diff --git a/server/debian/common/servercontainer_init_mysql.sh b/server/debian/common/servercontainer_init_mysql.sh new file mode 100755 index 0000000..a383e10 --- /dev/null +++ b/server/debian/common/servercontainer_init_mysql.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# +# Prepare/Configure MySQL +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +usage() +{ +cat << EOF +usage:$0 [options] + prepare mysql (create directory, update configuration) + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +##################### +# MAIN +##################### +source /opt/servercontainer_function.sh +msg_info "$(basename $0) => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +msg_debug "Create database for account gameserver" +# Create database on gameserver account (and change directory database) +sed -i -r 's/^user[[:space:]]+=[[:space:]]+(.*)/user = gameserver/g' /etc/mysql/my.cnf || exit 2 +sed -i -r 's/^datadir[[:space:]]+=[[:space:]]+(.*)/datadir = \/home\/gameserver\/database/g' /etc/mysql/my.cnf || exit 2 +sed -i -r 's/^log_error[[:space:]]+=[[:space:]]+(.*)/log_error = \/home\/gameserver\/log\/mysql\/error\.log/g' /etc/mysql/my.cnf || exit 2 +sed -i -r 's/^(#*)general_log_file[[:space:]]+=(.*)/general_log_file = \/home\/gameserver\/log\/mysql\/mysql\.log/g' /etc/mysql/my.cnf || exit 2 +sed -i -r 's/^(#*)general_log[[:space:]]+=(.*)/general_log = 1/g' /etc/mysql/my.cnf || exit 2 +sed -i -r 's/^(#*)slow_query_log_file[[:space:]]+=(.*)/slow_query_log_file = \/home\/gameserver\/log\/mysql\/mysql-slow\.log/g' /etc/mysql/my.cnf || exit 2 +sed -i -r 's/^(#*)slow_query_log[[:space:]]+=(.*)/slow_query_log = 1/g' /etc/mysql/my.cnf || exit 2 +sed -i -r 's/^(#*)long_query_time[[:space:]]+=(.*)/long_query_time = 2/g' /etc/mysql/my.cnf || exit 2 +sed -i -r 's/^(#*)log_queries_not_using_indexes(.*)/log_queries_not_using_indexes/g' /etc/mysql/my.cnf || exit 2 + +mkdir -p /home/gameserver/database/ || exit 2 +chown gameserver:$(id -g -n gameserver) /home/gameserver/database/ || exit 2 + +mkdir -p /home/gameserver/log/mysql || exit 2 +chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2 + +chown gameserver:$(id -g -n gameserver) /var/run/mysqld/ || exit 2 + +#################################### +# End +#################################### +msg_info "$(basename $0) => END" diff --git a/server/debian/common/servercontainer_init_package.sh b/server/debian/common/servercontainer_init_package.sh new file mode 100755 index 0000000..87f4a27 --- /dev/null +++ b/server/debian/common/servercontainer_init_package.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Install binary and data +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +usage() +{ +cat << EOF +usage:$0 [options] + prepare mysql (create directory, update configuration) + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +##################### +# MAIN +##################### +source /opt/servercontainer_function.sh +msg_info "$(basename $0) => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +# install new package +cd /; tar xzf /opt/ryzomcore.tar.gz --strip 1 || exit 2 +# Install data ref (web server, ...) +cd /opt; tar xzf khanat-ref-ressources.tar.gz || exit 2 + +#################################### +# End +#################################### +msg_info "$(basename $0) => END" + diff --git a/server/debian/common/servercontainer_launch_auto.sh b/server/debian/common/servercontainer_launch_auto.sh new file mode 100755 index 0000000..f7d6768 --- /dev/null +++ b/server/debian/common/servercontainer_launch_auto.sh @@ -0,0 +1,320 @@ +#!/bin/bash +# +# Prepare and launch server khanat +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +usage() +{ +cat << EOF +usage:$0 [options] + Prepare and launch server khanat + +options: + -h, --help : Show this help + -d, --debug : Show debug message + --start-khanat-with-screen : start with screen + --show-khanat-log : Show khanat log (after start) + --show-all-log : Show all log (after start) [apache, mysql, khanat] + --show-status-nagios : show status (ater start) + --show-status : show status (ater start) + --bash-after-start : command bash after start + --start-with-manager : start khanat with manager +EOF +} + +status_program() +{ + pid=$(cat /home/gameserver/khanat/server/$1/$1.pid) + ps -p $pid >/dev/null + if [[ $? -eq 0 ]] + then + pidstate="ok" + else + pidstate="ko" + fi + state=$(cat /home/gameserver/khanat/server/$1/$1.state) + echo "$1 $2 [$state] pid:$pid => $pidstate" +} + +status_all() +{ + # aes : admin_executor_service.log + status_program 'aes' 'ryzom_admin_service' + + # bms_master : backup_service.log + status_program 'bms_master' 'ryzom_backup_service' + + # bms_pd_master + # status_program 'bms_pd_master' 'ryzom_backup_service' + + # egs : entities_game_service.log + status_program 'egs' 'ryzom_entities_game_service' + + # gpms : gpm_service.log + status_program 'gpms' 'ryzom_gpm_service' + + # ios : input_output_service.log + status_program 'ios' 'ryzom_ios_service' + + # rns : naming_service.log + status_program 'rns' 'ryzom_naming_service' + + # rws : welcome_service.log + status_program 'rws' 'ryzom_welcome_service' + + # ts : tick_service.log + status_program 'ts' 'ryzom_tick_service' + + # ms : mirror_service.log + status_program 'ms' 'ryzom_mirror_service' + + # ais_newbyland : ai_service.log + status_program 'ais_newbyland' 'ryzom_ai_service' + + # mfs : mail_forum_service.log + status_program 'mfs' 'ryzom_mail_forum_service' + + # su : shard_unifier_service.log + status_program 'su' 'ryzom_shard_unifier_service' + + # fes : frontend_service.log + status_program 'fes' 'ryzom_frontend_service' + + # sbs : session_browser_server.log + status_program 'sbs' 'ryzom_session_browser_service' + + # lgs : logger_service.log + status_program 'lgs' 'ryzom_logger_service' + + # mos + # status_program 'mos' 'ryzom_monitor_service' + + # pdss + #status_program 'pdss' 'ryzom_pd_support_service' + + # ras : admin_service.log + status_program 'ras' 'ryzom_admin_service' +} + +function create_default_file_for_screen() +{ + # on scrren mode, we launch with root right + # But file are created on root, so , to solve that, we generate directory and file before + + create_dir_gameserver '/home/gameserver/khanat/server/bms_master' + create_dir_gameserver '/home/gameserver/khanat/server/rws' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/characters_offline_commands' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/characters' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/characters/002' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/ai_script_data' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/sale_store' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www/302' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www/302/ke' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www/302/ke/kem' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/totems' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/logs' + create_dir_gameserver '/home/gameserver/khanat/server/save_shard/sdb' + create_dir_gameserver '/home/gameserver/khanat/server/pds' + create_dir_gameserver '/home/gameserver/khanat/server/pds/00000000' + create_dir_gameserver '/home/gameserver/khanat/server/pds/00000000/logs' + create_dir_gameserver '/home/gameserver/khanat/server/gpms' + create_dir_gameserver '/home/gameserver/khanat/server/aes' + create_dir_gameserver '/home/gameserver/khanat/server/lgs' + create_dir_gameserver '/home/gameserver/khanat/server/data_shard/primitive_cache' + create_dir_gameserver '/home/gameserver/khanat/server/su' + create_dir_gameserver '/home/gameserver/khanat/server/ms' + create_dir_gameserver '/home/gameserver/khanat/server/egs' + create_dir_gameserver '/home/gameserver/khanat/server/data_shard_local' + create_dir_gameserver '/home/gameserver/khanat/server/data_shard_local/statistics' + create_dir_gameserver '/home/gameserver/khanat/server/fes' + create_dir_gameserver '/home/gameserver/khanat/server/mfs' + create_dir_gameserver '/home/gameserver/khanat/server/ras' + create_dir_gameserver '/home/gameserver/khanat/server/ios' + create_dir_gameserver '/home/gameserver/khanat/server/sbs' + create_dir_gameserver '/home/gameserver/khanat/server/ais_newbyland' + create_dir_gameserver '/home/gameserver/khanat/server/rns' + create_dir_gameserver '/home/gameserver/khanat/server/ts' +} + +##################### +# MAIN +##################### +source /opt/ext/servercontainer_function.sh +msg_info "START : $(basename $0)" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + --start-khanat-with-screen) + METHOD_START=0 + shift + ;; + --show-khanat-log) + METHOD_START=1 + shift + ;; + --show-all-log) + METHOD_START=3 + shift + ;; + --show-status-nagios) + METHOD_START=2 + shift + ;; + --show-status) + METHOD_START=4 + shift + ;; + --bash-after-start) + METHOD_START=5 + shift + ;; + --start-with-manager) + METHOD_START=6 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + + +##################### +# Start mysql, apache & ssh +##################### +msg_debug "Start mysql, apache & ssh" +sudo /etc/init.d/mysql restart +sudo /etc/init.d/apache2 restart +sudo /etc/init.d/ssh restart + + +##################### +# Update configuration with new IP +##################### +msg_debug "Update configuration with new IP" +tmp=$(hostname -I) +export addressip=${tmp//[[:blank:]]/} +sudo sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "'"$addressip"'";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2 + + +##################### +# Reconfigure database +##################### +msg_debug "Reconfigure database : Configure Domain" +## Configure Domain +sudo mysql -u root -e "use nel; +UPDATE nel.domain +SET backup_patch_url = '$addressip:23001' +, patch_urls = '$addressip/patch' +, login_address = '$addressip:49998' +, session_manager_address = '$addressip:49999' +, web_host = '$addressip:30000' +, web_host_php = '$addressip:40916' +WHERE domain_id = 12;" || exit 2 + +# Configure nel.shard +msg_debug "Reconfigure database : Configure nel.shard" +sudo mysql -u root -e "use nel; +UPDATE nel.shard +SET WsAddr = '$addressip:' +WHERE ShardId = 302;" || exit 2 + +# Configure nel_tool.neltool_domains +msg_debug "Reconfigure database : Configure nel_tool.neltool_domains" +sudo mysql -u root -e "use nel; +UPDATE nel_tool.neltool_domains +SET domain_as_host = '$addressip' +WHERE domain_id = 12;" || exit 2 + + +##################### +# Start khanat +##################### +msg_debug "Start khanat" +if [[ $METHOD_START -eq 0 ]] +then + source /home/gameserver/.bashrc; export RYZOM_PATH=$KHANAT_PATH; cd "$RYZOM_PATH"; $KHANAT_HOME/khanat/tools/scripts/linux/shard start +elif [[ $METHOD_START -eq 1 ]] +then + /opt/ext/servercontainer_launch_service.sh + sleep 10 + tail -n+0 -f /home/gameserver/log/khanat/log.log +elif [[ $METHOD_START -eq 2 ]] +then + /opt/ext/servercontainer_launch_service.sh + sleep 10 + watch cat /home/gameserver/khanat/server/aes_nagios_report.txt +elif [[ $METHOD_START -eq 3 ]] +then + /opt/ext/servercontainer_launch_service.sh + sleep 10 + tail -n+0 -f /home/gameserver/log/apache2/* /home/gameserver/log/mysql/* /home/gameserver/log/khanat/* +elif [[ $METHOD_START -eq 4 ]] +then + /opt/ext/servercontainer_launch_service.sh + sleep 10 + watch /opt/ext/servercontainer_launch_status.sh --no-color +elif [[ $METHOD_START -eq 5 ]] +then + /opt/ext/servercontainer_launch_service.sh + #sleep 10 + bash +elif [[ $METHOD_START -eq 6 ]] +then + mkdir -p /home/gameserver/log/khanat + mkdir -p /home/gameserver/khanat/server/gpms + /home/gameserver/ext/khaganat/tools/manage.py --log info --show-log-console --filelog /home/gameserver/log/khanat/manager.log -c /home/gameserver/khanat/khaganat.cfg --launch-program + bash +else + msg_error 'Bad option' + exit 2 +fi + + +###################### +# +###################### diff --git a/server/debian/common/servercontainer_launch_service.sh b/server/debian/common/servercontainer_launch_service.sh new file mode 100755 index 0000000..751ed3c --- /dev/null +++ b/server/debian/common/servercontainer_launch_service.sh @@ -0,0 +1,167 @@ +#!/bin/bash +# +# Script to launch khaganat +# (see shard.screen.rc) +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +usage() +{ +cat << EOF +usage:$0 [options] + Script to launch khaganat + +options: + -h, --help : Show this help + -d, --debug : Show debug message +EOF +} + +function start_stop() +{ + nameservice=$1 + printf RUNNING > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state + chown_gameserver /home/gameserver/khanat/server/${nameservice}/${nameservice}.state + nohup $2 + printf STOPPED > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state +} + +function launch_service() +{ + nameservice=$1 + + create_dir_gameserver "/home/gameserver/khanat/server/${nameservice}" + create_file_gameserver "/home/gameserver/khanat/server/$1/$1.pid" + create_file_gameserver "/home/gameserver/log/khanat/$nameservice.out" + create_file_gameserver "/home/gameserver/log/khanat/$nameservice.err" + + start_stop "$1" "$2" 1>/home/gameserver/log/khanat/$nameservice.out 2>/home/gameserver/log/khanat/$nameservice.err & + echo "$!" > /home/gameserver/khanat/server/$1/$1.pid + #nohup $2 1>/dev/null 2>&1 & + #echo "$!" > /home/gameserver/khanat/server/$1.pid + #printf RUNNING > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state +} + +##################### +# MAIN +##################### +source /opt/ext/servercontainer_function.sh +msg_info "START : $(basename $0)" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + + +#################################### +# Load Environment +#################################### +create_dir_gameserver '/home/gameserver/log/khanat' +cd /home/gameserver/log/khanat + +# aes : admin_executor_service.log +launch_service 'aes' 'ryzom_admin_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --fulladminname=admin_executor_service --shortadminname=AES' + +# bms_master : backup_service.log +launch_service 'bms_master' 'ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid -P49990' + +# bms_pd_master +# launch_service 'bms_pd_master' 'ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid -P49992' + +# egs : entities_game_service.log +launch_service 'egs' 'ryzom_entities_game_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# gpms : gpm_service.log +launch_service 'gpms' 'ryzom_gpm_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# ios : input_output_service.log +launch_service 'ios' 'ryzom_ios_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# rns : naming_service.log +launch_service 'rns' 'ryzom_naming_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# rws : welcome_service.log +launch_service 'rws' 'ryzom_welcome_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# ts : tick_service.log +launch_service 'ts' 'ryzom_tick_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# ms : mirror_service.log +launch_service 'ms' 'ryzom_mirror_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# ais_newbyland : ai_service.log +launch_service 'ais_newbyland' 'ryzom_ai_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid -mCommon:Newbieland:Post' + +# mfs : mail_forum_service.log +launch_service 'mfs' 'ryzom_mail_forum_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# su : shard_unifier_service.log +launch_service 'su' 'ryzom_shard_unifier_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# fes : frontend_service.log +launch_service 'fes' 'ryzom_frontend_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# sbs : session_browser_server.log +launch_service 'sbs' 'ryzom_session_browser_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# lgs : logger_service.log +launch_service 'lgs' 'ryzom_logger_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# mos +# launch_service 'mos' 'ryzom_monitor_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# pdss +#launch_service 'pdss' 'ryzom_pd_support_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + +# ras : admin_service.log +launch_service 'ras' 'ryzom_admin_service --fulladminname=admin_service --shortadminname=AS -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid' + + +###################### +# +###################### diff --git a/server/debian/common/servercontainer_launch_status.sh b/server/debian/common/servercontainer_launch_status.sh new file mode 100755 index 0000000..1d96e3a --- /dev/null +++ b/server/debian/common/servercontainer_launch_status.sh @@ -0,0 +1,174 @@ +#!/bin/bash +# +# Script to get status all process khanat +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +declare NOCOLOR=0 +declare RED="" +declare GREEN="" +declare NORMAL="" + +usage() +{ +cat << EOF +usage:$0 [options] + Script to launch khaganat + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -n, --no-color : disable color +EOF +} + +status_program() +{ + name=$1 + printf "%15s %-30s" "$1" "$2" + color="" + color2="" + + pid=$(cat /home/gameserver/khanat/server/$1/$1.pid 2>/dev/null) + if [[ -n "$pid" ]] + then + ps -p $pid >/dev/null + if [[ $? -eq 0 ]] + then + pidstate=" ok " + color=$GREEN + else + pidstate="*ko*" + color=$RED + fi + else + pidstate="*ko*" + color=$RED + fi + printf " pid:%-8s %4s" "$pid" "${color}${pidstate}${NORMAL}" + + state=$(cat /home/gameserver/khanat/server/$1/$1.state 2>/dev/null) + if [[ -n "$state" ]] + then + if [[ "$state" == "RUNNING" ]] + then + color2=$GREEN + else + color2=$RED + fi + else + state="NOT STARTED" + color2=$RED + fi + printf " %s\n" "${color2}[${state}]${NORMAL}" +} + +status_all() +{ + # aes : admin_executor_service.log + status_program 'aes' 'ryzom_admin_service' + + # bms_master : backup_service.log + status_program 'bms_master' 'ryzom_backup_service' + + # bms_pd_master + # status_program 'bms_pd_master' 'ryzom_backup_service' + + # egs : entities_game_service.log + status_program 'egs' 'ryzom_entities_game_service' + + # gpms : gpm_service.log + status_program 'gpms' 'ryzom_gpm_service' + + # ios : input_output_service.log + status_program 'ios' 'ryzom_ios_service' + + # rns : naming_service.log + status_program 'rns' 'ryzom_naming_service' + + # rws : welcome_service.log + status_program 'rws' 'ryzom_welcome_service' + + # ts : tick_service.log + status_program 'ts' 'ryzom_tick_service' + + # ms : mirror_service.log + status_program 'ms' 'ryzom_mirror_service' + + # ais_newbyland : ai_service.log + status_program 'ais_newbyland' 'ryzom_ai_service' + + # mfs : mail_forum_service.log + status_program 'mfs' 'ryzom_mail_forum_service' + + # su : shard_unifier_service.log + status_program 'su' 'ryzom_shard_unifier_service' + + # fes : frontend_service.log + status_program 'fes' 'ryzom_frontend_service' + + # sbs : session_browser_server.log + status_program 'sbs' 'ryzom_session_browser_service' + + # lgs : logger_service.log + status_program 'lgs' 'ryzom_logger_service' + + # mos + # status_program 'mos' 'ryzom_monitor_service' + + # pdss + #status_program 'pdss' 'ryzom_pd_support_service' + + # ras : admin_service.log + status_program 'ras' 'ryzom_admin_service' +} + +##################### +# MAIN +##################### +source /opt/ext/servercontainer_function.sh +msg_info "START : $(basename $0)" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + set_debug 1 + shift + ;; + -n|--no-color) + NOCOLOR=1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +if [[ $NOCOLOR -eq 0 ]] +then + RED=$(tput setaf 1) + GREEN=$(tput setaf 2) + NORMAL=$(tput sgr0) +fi +status_all + diff --git a/server/debian/common/servercontainer_update_auto.sh b/server/debian/common/servercontainer_update_auto.sh new file mode 100755 index 0000000..e872388 --- /dev/null +++ b/server/debian/common/servercontainer_update_auto.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Script to update khanat server +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +/opt/ext/servercontainer_configure_link.sh || exit 2 +#/opt/ext/servercontainer_configure_mysql.sh || exit 2 +#/opt/ext/servercontainer_configure_apache.sh || exit 2 +#/opt/ext/servercontainer_configure_world.sh || exit 2 +su -c '/opt/ext/servercontainer_configure_khanat.sh' gameserver || exit 2 +su -c '/opt/ext/servercontainer_configure_patch.sh -d' gameserver || exit 2 + +exit 0 + diff --git a/server/debian/common/serverimage_autostart.sh b/server/debian/common/serverimage_autostart.sh new file mode 100755 index 0000000..11f0743 --- /dev/null +++ b/server/debian/common/serverimage_autostart.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# Scritp to launch server khanat +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +declare METHOD_START=$1 + +/etc/init.d/mysql restart +/etc/init.d/apache2 restart +/etc/init.d/ssh restart +source /opt/shard.sh + +tmp=$(hostname -I) +export addressip=${tmp//[[:blank:]]/} +sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "'"$addressip"'";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2 + +/opt/serverimage_prepare_start_server.sh || exit 2 + +if [[ $METHOD_START -eq 1 ]] +then + export RYZOM_PATH=$KHANAT_PATH + /home/gameserver/khanat/tools/scripts/linux/shard start +elif [[ $METHOD_START -eq 2 ]] +then + bash /opt/serverimage_launch_services.sh + sleep 10 + tail -n+0 -f /home/gameserver/khanat/server/log/log.log +else + bash /opt/serverimage_launch_services.sh + sleep 10 + watch cat /home/gameserver/khanat/server/aes_nagios_report.txt +fi diff --git a/server/debian/common/serverimage_configure_apache.sh b/server/debian/common/serverimage_configure_apache.sh new file mode 100755 index 0000000..76d0f4a --- /dev/null +++ b/server/debian/common/serverimage_configure_apache.sh @@ -0,0 +1,155 @@ +#!/bin/bash +# +# Configure apache +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +echo "CONFIGURE APACHE" + +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi + +# load environment +source /home/gameserver/.bashrc + +# Create directory use for patch server +#mkdir -p $KHANAT_PATH/khanatweb/public_php/ +mkdir -p $PATCH_CLIENT_SYSTEM/patch_game/patch +mkdir -p $KHANAT_HOME/client_service/ + +# configure apache +cat << EOF > /etc/apache2/sites-available/000-default.conf +# Default + + + Options Indexes FollowSymLinks + AllowOverride None + Require all granted + DirectoryIndex index.php + AddType text/html .php .phps + AddHandler application/x-httpd-php .php + AddHandler application/x-httpd-php-source .phps + + ServerName lirria.khaganat.net + + ServerAdmin webmaster@localhost + DocumentRoot $KHANAT_PATH/khanatweb/public_php/ + + ErrorLog \${APACHE_LOG_DIR}/error.log + CustomLog \${APACHE_LOG_DIR}/access.log combined + + +# Khanat Server Web + + + Options Indexes FollowSymLinks + AllowOverride None + Require all granted + + ServerName lirria.khaganat.net + + ServerAdmin admin@localhost + DocumentRoot $KHANAT_PATH/khanatweb/public_php + + ErrorLog \${APACHE_LOG_DIR}/error.log + CustomLog \${APACHE_LOG_DIR}/access.log combined + + +# Patch Server + + ServerName lirria.khaganat.net + DocumentRoot $PATCH_HOME/patch_service/patch_game/patch/ + + + Options -Indexes + AllowOverride All + Require all granted + + +EOF + +# Open port use by apache +cat << EOF > /etc/apache2/ports.conf +# If you just change the port or add more ports here, you will likely also +# have to change the VirtualHost statement in +# /etc/apache2/sites-enabled/000-default.conf + +Listen 80 +Listen 40916 +Listen 43435 + + + Listen 443 + + + + Listen 443 + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet +EOF + + +# Activate php - strange beacause we have only index.php (without php code !) +cat << EOF > /etc/apache2/conf-available/patch_service.conf +Alias /patch /home/gameserver/patch_service/patch_game/patch + + Options FollowSymLinks + DirectoryIndex index.php + + Require all granted + + + + AddType application/x-httpd-php .php + + + SetHandler application/x-httpd-php + + + +EOF + +# Activate & deploy new configuration +a2enconf patch_service.conf + +# Configuration de la page client +cat << EOF > /etc/apache2/conf-available/client_service.conf +Alias /client /home/gameserver/client_service + + Options FollowSymLinks + DirectoryIndex index.html + + Require all granted + + + AddType application/tar .tar.gz + + + SetHandler application/tar + + + +EOF + +# Activate & deploy new configuration +a2enconf client_service.conf + +# Restart apache +service apache2 restart || exit 2 + diff --git a/server/debian/common/serverimage_configure_database.sh b/server/debian/common/serverimage_configure_database.sh new file mode 100755 index 0000000..1a76209 --- /dev/null +++ b/server/debian/common/serverimage_configure_database.sh @@ -0,0 +1,133 @@ +#!/bin/bash +# +# Configure database +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +echo "CONFIGURE DATABASE" + +export KHANAT_CLIENT_VERSION=1 +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi + +# load environment +source /home/gameserver/.bashrc + +# start/restart service mysql & apache +service mysql restart || exit 2 + +# Create account shard on MySQL +mysql -u root -e "CREATE USER 'shard'@'localhost' IDENTIFIED BY '';" || exit 2 +mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'shard'@'localhost' WITH GRANT OPTION;" || exit 2 + +# launch web configuration for khanat +curl 'http://localhost:40916/setup/install.php' \ + -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ + -H 'Accept-Language: en-US' \ + -H 'Connection: keep-alive' \ + -H 'Cookie: PHPSESSID=9jr1ssig58929bp777nrj2fa92' \ + -H 'DNT: 1' \ + -H 'Host: localhost:40916' \ + -H 'Referer: http://localhost:40916/setup/install.php' \ + -H 'Upgrade-Insecure-Requests: 1' \ + -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0' \ + -H 'Content-Type: application/x-www-form-urlencoded' \ + --data 'roleService=on'\ +'&roleSupport=on'\ +'&roleDomain=on'\ +'&privatePhpDirectory=..%2Fprivate_php%2F'\ +'&nelSetupPassword=admin'\ +'&nelSqlHostname=localhost'\ +'&nelSqlUsername=root'\ +'&nelSqlPassword='\ +'&nelDatabase=nel'\ +'&toolDatabase=nel_tool'\ +'&toolsAdminUsername=admin'\ +'&toolsAdminPassword=admin'\ +'&amsSqlHostname=localhost'\ +'&amsSqlUsername=root'\ +'&amsSqlPassword='\ +'&amsDatabase=nel_ams'\ +'&amsLibDatabase=nel_ams_lib'\ +'&amsAdminUsername=admin'\ +'&amsAdminPassword=admin'\ +'&nelDomainName=Lirria'\ +'&domainDatabase=ring_mini01'\ +'&submit=Configure' \ + -o /opt/setup.log || exit 2 + +# Check account is create +grep "Domain role successfully installed" /opt/setup.log >/dev/null || exit 2 + +# Get IP ADDRESS +tmp=$(hostname -I) +export addressip=${tmp//[[:blank:]]/} + +## Configure Domain +mysql -u root -e "use nel; +INSERT INTO nel.domain (domain_id, domain_name, status, patch_version, backup_patch_url, patch_urls, login_address, session_manager_address, ring_db_name, web_host, web_host_php, description) VALUES ('12', 'Lirria', 'ds_open', '$KHANAT_CLIENT_VERSION', '$addressip:23001', '$addressip/patch', '$addressip:49998', '$addressip:49999', 'ring_mini01', '$addressip:30000', '$addressip:40916', NULL);" || exit 2 + +# Configure nel.shard +mysql -u root -e "use nel; +INSERT INTO nel.shard (ShardId, domain_id, WsAddr, NbPlayers, Name, Online, Version, FixedSessionId, State, MOTD) VALUES ('302', '12', '$addressip:', '0', 'Lirria shard', '0', '', '0', 'ds_open', '');" || exit 2 + +# Configure nel_tool.neltool_domains +mysql -u root -e "use nel; +INSERT INTO nel_tool.neltool_domains (domain_id, domain_name, domain_as_host, domain_as_port, domain_rrd_path, domain_las_admin_path, domain_las_local_path, domain_application, domain_sql_string, domain_hd_check, domain_mfs_web, domain_cs_sql_string) VALUES ('12', 'Lirria', '$addressip', '46700', '/home/gameserver/khanat/server/save_shard/rrd_graphs', '', '', 'ryzom_open', '', '0', NULL, NULL);" || exit 2 + +# configure nel_tool.neltool_shards +mysql -u root -e "use nel; +INSERT INTO nel_tool.neltool_shards (shard_id, shard_name, shard_as_id, shard_domain_id, shard_lang, shard_restart) VALUES ('302', 'open', 'open', '12', 'fr', '0');" || exit 2 + +# configure nel_tool.neltool_user_domains +mysql -u root -e "use nel; +INSERT INTO nel_tool.neltool_user_domains (user_domain_id, user_domain_user_id, user_domain_domain_id) VALUES ('1', '1', '12');" || exit 2 + +# configure nel_tool.neltool_user_shards +mysql -u root -e "use nel; +INSERT INTO nel_tool.neltool_user_shards (user_shard_id, user_shard_user_id, user_shard_shard_id, user_shard_domain_id) VALUES ('1', '1', '302', '12');" || exit 2 + +# configure ring_mini01.sessions +mysql -u root -e "use ring_mini01; +INSERT INTO ring_mini01.sessions (session_id, session_type, title, owner, plan_date, start_date, description, orientation, level, rule_type, access_type, state, host_shard_id, subscription_slots, reserved_slots, free_slots, estimated_duration, final_duration, folder_id, lang, icone, anim_mode, race_filter, religion_filter, guild_filter, shard_filter, level_filter, subscription_closed, newcomer) VALUES ('302', 'st_mainland', '', '0', '2005-09-21 12:41:33.000000', '2005-08-31 00:00:00.000000', '', 'so_other', 'sl_a', 'rt_strict', 'at_private', 'ss_planned', '0', '0', '0', '0', 'et_short', '0', '0', '', '', 'am_dm', '', '', 'gf_only_my_guild', 'sf_shard00,sf_shard01,sf_shard02,sf_shard03,sf_shard04,sf_shard05,sf_shard06,sf_shard07,sf_shard08,sf_shard09,sf_shard10,sf_shard11,sf_shard12,sf_shard13,sf_shard14,sf_shard15,sf_shard16,sf_shard17,sf_shard18,sf_shard19,sf_shard20,sf_shard21,sf_shard22,sf_shard23,sf_shard24,sf_shard25,sf_shard26,sf_shard27,sf_shard28,sf_shard29,sf_shard30', 'lf_a,lf_b,lf_c,lf_d,lf_e,lf_f', '0', '0');" || exit 2 + + +## Create one user 'tester' (password : tester) +declare accountuser="tester" +declare passworduser="tester" +curl 'http://localhost:40916/ams/index.php' \ + -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ + -H 'Accept-Language: en-US' \ + -H 'Connection: keep-alive' \ + -H 'Cookie: PHPSESSID=lsoumn9f0ljgm3vo3hgjdead03' \ + -H 'DNT: 1' \ + -H 'Host: localhost:40916' \ + -H 'Referer: http://localhost:40916/ams/index.php?page=register' \ + -H 'Upgrade-Insecure-Requests: 1' \ + -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0' \ + -H 'Content-Type: application/x-www-form-urlencoded' \ + --data 'Username='"$accountuser"'&Password='"$passworduser"'&ConfirmPass=tester&Email=tester%40khaganat.net&TaC=on&function=add_user' \ + -o /opt/account_tester.log || exit 2 + +# configure nel.permission +mysql -u root -e "use nel; +UPDATE nel.permission SET AccessPrivilege = 'OPEN,DEV,RESTRICTED'; +" || exit 2 + + diff --git a/server/debian/common/serverimage_configure_environment.sh b/server/debian/common/serverimage_configure_environment.sh new file mode 100755 index 0000000..a80d5bb --- /dev/null +++ b/server/debian/common/serverimage_configure_environment.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# Configure environment +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#################################### +# Load Environment +#################################### +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + + +echo "CONFIGURE ENVIRONMENT" + +# configure environment +cat << EOF > /opt/shard.sh +export KHANAT_HOME=/home/gameserver +export KHANAT_PATH=/home/gameserver/khanat +export PATH=\$PATH:/usr/local/bin:/usr/local/sbin:\$KHANAT_PATH/tools/scripts/linux +export KHANAT_DATA=/home/gameserver/khanat-ressources +export PATCH_HOME=/home/gameserver +export PATCH_CLIENT_SYSTEM=\$PATCH_HOME/patch_service +export WORKDIRCLIENT="$WORKDIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +EOF + +# configure environment +cat << EOF > /home/gameserver/.bashrc +export KHANAT_HOME=/home/gameserver +export KHANAT_PATH=/home/gameserver/khanat +export PATH=\$PATH:/usr/local/bin:\$KHANAT_PATH/tools/scripts/linux +export KHANAT_DATA=/home/gameserver/khanat-ressources +export PATCH_HOME=/home/gameserver +export PATCH_CLIENT_SYSTEM=\$PATCH_HOME/patch_service +export WORKDIRCLIENT="$WORKDIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +EOF + +# load environment +source /home/gameserver/.bashrc + +# Initialize ssh +/etc/init.d/ssh restart + + + diff --git a/server/debian/common/serverimage_init_basic.sh b/server/debian/common/serverimage_init_basic.sh new file mode 100755 index 0000000..187ea8d --- /dev/null +++ b/server/debian/common/serverimage_init_basic.sh @@ -0,0 +1,325 @@ +#!/bin/bash +# +# Install all package we need to prepare and install khanat server +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +declare DEBUG=0 +declare MYSQL_GAMESERVER=0 +declare APACHE_GAMESERVER=0 + +usage() +{ +cat << EOF +usage:$0 [options] + script to intialize server + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -m, --mysql-gameserver : create database on gameserver account + -a, --apache-gameserver : configure apache to use gameserver account +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +msg_info "[$(basename $0):$LINENO] => START" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + -m|--mysql-gameserver) + MYSQL_GAMESERVER=1 + shift + ;; + -a|--apache-gameserver) + APACHE_GAMESERVER=1 + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +#################################### +# Load Environment +#################################### +msg_debug "[$(basename $0):$LINENO] Load environment" +if [[ ! -f /opt/khanat_config.sh ]] +then + echo "ERROR - missing /opt/khanat_config.sh" + exit 2 +fi +source /opt/khanat_config.sh + +#################################### +# Configure account gameserver +#################################### +if [[ $APACHE_GAMESERVER -ne 0 ]] +then + msg_debug "[$(basename $0):$LINENO] Create gameserver account (shared with host)" + groupadd --gid $GIDGAMESERVER gameserver || echo "group id already exist" + useradd --uid $UIDGAMESERVER --gid $GIDGAMESERVER -G sudo -c /home -d /home/gameserver -c "Khanat account GAME" -m -p '$6$nxHX/3u.$azS0.eldpfKqxqOLDjgZj8.hPOLC64arXDTUVX0fs7RZvRBX/pNqPzDR89ccP5XkEE/daOyaD3wVtDGDUND5b/' -s /bin/bash gameserver + echo "group : $(id -g -n gameserver)" +else + msg_debug "[$(basename $0):$LINENO] Create gameserver account" + useradd -G sudo,www-data -c /home -d /home/gameserver -c "Khanat account GAME" -m -p '$6$nxHX/3u.$azS0.eldpfKqxqOLDjgZj8.hPOLC64arXDTUVX0fs7RZvRBX/pNqPzDR89ccP5XkEE/daOyaD3wVtDGDUND5b/' -s /bin/bash -U gameserver +fi + +#################################### +# Initialize apache +#################################### +if [[ $APACHE_GAMESERVER -ne 0 ]] +then + msg_debug "[$(basename $0):$LINENO] Configure apache log" + sed -i -r 's/^export[[:space:]]+APACHE_RUN_USER=(.*)/export APACHE_RUN_USER=gameserver/g' /etc/apache2/envvars || exit 2 + sed -i -r 's/^export[[:space:]]+APACHE_RUN_GROUP=(.*)/export APACHE_RUN_GROUP='$(id -g -n gameserver)'/g' /etc/apache2/envvars || exit 2 + sed -i -r 's/^export[[:space:]]+APACHE_LOG_DIR=(.*)/export APACHE_LOG_DIR=\/home\/gameserver\/log\/apache2\$SUFFIX/g' /etc/apache2/envvars || exit 2 + mkdir -p /home/gameserver/log/apache2 || exit 2 + chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2 +fi + +#################################### +# Initialize database +#################################### + +if [[ $MYSQL_GAMESERVER -ne 0 ]] +then + msg_debug "[$(basename $0):$LINENO] Create database for account gameserver" + # Create database on gameserver account (and change directory database) + sed -i -r 's/^user[[:space:]]+=[[:space:]]+(.*)/user = gameserver/g' /etc/mysql/my.cnf || exit 2 + sed -i -r 's/^datadir[[:space:]]+=[[:space:]]+(.*)/datadir = \/home\/gameserver\/database/g' /etc/mysql/my.cnf || exit 2 + sed -i -r 's/^log_error[[:space:]]+=[[:space:]]+(.*)/log_error = \/home\/gameserver\/log\/mysql\/error\.log/g' /etc/mysql/my.cnf || exit 2 + sed -i -r 's/^(#*)general_log_file[[:space:]]+=(.*)/general_log_file = \/home\/gameserver\/log\/mysql\/mysql\.log/g' /etc/mysql/my.cnf || exit 2 + sed -i -r 's/^(#*)general_log[[:space:]]+=(.*)/general_log = 1/g' /etc/mysql/my.cnf || exit 2 + sed -i -r 's/^(#*)slow_query_log_file[[:space:]]+=(.*)/slow_query_log_file = \/home\/gameserver\/log\/mysql\/mysql-slow\.log/g' /etc/mysql/my.cnf || exit 2 + sed -i -r 's/^(#*)slow_query_log[[:space:]]+=(.*)/slow_query_log = 1/g' /etc/mysql/my.cnf || exit 2 + sed -i -r 's/^(#*)long_query_time[[:space:]]+=(.*)/long_query_time = 2/g' /etc/mysql/my.cnf || exit 2 + sed -i -r 's/^(#*)log_queries_not_using_indexes(.*)/log_queries_not_using_indexes/g' /etc/mysql/my.cnf || exit 2 + + mkdir -p /home/gameserver/database/ || exit 2 + chown gameserver:$(id -g -n gameserver) /home/gameserver/database/ || exit 2 + + mkdir -p /home/gameserver/log/mysql || exit 2 + chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2 + + /usr/bin/mysql_install_db --user=gameserver --skip-name-resolve || exit 2 + chown gameserver:$(id -g -n gameserver) /var/run/mysqld/ || exit 2 +else + msg_debug "[$(basename $0):$LINENO] Create database" + /usr/bin/mysql_install_db --user=mysql --skip-name-resolve || exit 2 +fi + +# Start the MySQL daemon in the background. +msg_debug "[$(basename $0):$LINENO] Start database" +/usr/sbin/mysqld & +mysql_pid=$! + +# Wait mysql start +msg_debug "[$(basename $0):$LINENO] Check database is started" +until /usr/bin/mysqladmin ping >/dev/null 2>&1 +do + echo -n "." + sleep 1 +done + +# Initialize password root (to empty) +msg_debug "[$(basename $0):$LINENO] configure password root for database" +/usr/bin/mysqladmin -u root password '' || exit 2 + +msg_debug "[$(basename $0):$LINENO] configure phpmyadmin" +ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf || exit 2 +a2enconf phpmyadmin.conf || exit 2 +cp /etc/phpmyadmin/config.inc.php /etc/phpmyadmin/config.inc.php.ref || exit 2 +awk '{if($0 ~ /AllowNoPassword/){$1="";}; print $0;}' /etc/phpmyadmin/config.inc.php.ref > /etc/phpmyadmin/config.inc.php || exit 2 + + +# Stop MySQL +msg_debug "[$(basename $0):$LINENO] Stop database" +/usr/bin/mysqladmin shutdown + +# Wait MySQL stop +wait $mysql_pid + +#################################### +# Initialize bashrc (for root) +#################################### +msg_debug "[$(basename $0):$LINENO] Configure bashrc (for root)" +cat << EOF > /root/.bashrc +# bashrc: executed by bash(1) for non-login shells. + +# You may uncomment the following lines if you want 'ls' to be colorized: +export SHELL=/bin/bash +export LS_OPTIONS='--color=auto' +eval "\`dircolors\`" +alias ls='ls \$LS_OPTIONS' +alias ll='ls \$LS_OPTIONS -l' +alias l='ls \$LS_OPTIONS -lA' + +# Some more alias to avoid making mistakes: +# alias rm='rm -i' +# alias cp='cp -i' +# alias mv='mv -i' + +# Autocompletion +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi + +# configure environment +export KHANAT_HOME=/home/gameserver +export KHANAT_PATH=/home/gameserver/khanat +export PATH=\$PATH:/usr/local/bin:/usr/local/sbin:\$KHANAT_PATH/tools/scripts/linux +export KHANAT_DATA=/home/gameserver/khanat-ressources +export PATCH_HOME=/home/gameserver +export PATCH_CLIENT_SYSTEM=\$PATCH_HOME/patch_service +export DIRCLIENT="$DIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +EOF + +#################################### +# Initialize bashrc (for gameserver) +#################################### +msg_debug "[$(basename $0):$LINENO] Configure bashrc (for gameserver)" +cat << EOF > /home/gameserver/.bashrc +# bashrc: executed by bash(1) for non-login shells. + +# You may uncomment the following lines if you want 'ls' to be colorized: +export SHELL=/bin/bash +export LS_OPTIONS='--color=auto' +eval "\`dircolors\`" +alias ls='ls \$LS_OPTIONS' +alias ll='ls \$LS_OPTIONS -l' +alias l='ls \$LS_OPTIONS -lA' + +# Some more alias to avoid making mistakes: +# alias rm='rm -i' +# alias cp='cp -i' +# alias mv='mv -i' + +# Autocompletion +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi + +# configure environment +export KHANAT_HOME=/home/gameserver +export KHANAT_PATH=/home/gameserver/khanat +export PATH=\$PATH:/usr/local/bin:/usr/local/sbin:\$KHANAT_PATH/tools/scripts/linux +export KHANAT_DATA=/home/gameserver/khanat-ressources +export PATCH_HOME=/home/gameserver +export PATCH_CLIENT_SYSTEM=\$PATCH_HOME/patch_service +export DIRCLIENT="$DIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +EOF +chown gameserver:$(id -g -n gameserver) /home/gameserver/.bashrc + +#################################### +# Initialize shard.sh +#################################### +# configure environment +msg_debug "[$(basename $0):$LINENO] Configure shard.sh" +cat << EOF > /opt/shard.sh +export KHANAT_HOME=/home/gameserver +export KHANAT_PATH=/home/gameserver/khanat +export PATH=\$PATH:/usr/local/bin:/usr/local/sbin:\$KHANAT_PATH/tools/scripts/linux +export KHANAT_DATA=/home/gameserver/khanat-ressources +export PATCH_HOME=/home/gameserver +export PATCH_CLIENT_SYSTEM=\$PATCH_HOME/patch_service +export WORKDIRCLIENT="$WORKDIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +EOF + +#################################### +# Adding sudo command +#################################### + +# Update sudo rule (you can execute all command as root) +msg_debug "[$(basename $0):$LINENO] Configure sudo" +cat << EOF > /etc/sudoers.d/gameserver +# User privilege specification +gameserver ALL=NOPASSWD: ALL +EOF + +#################################### +# LOGING HEADER +#################################### +# Message see when connect on ssh + +# Before login +msg_debug "[$(basename $0):$LINENO] Configure message login" +cat << EOF > /etc/issue.net +********************* +* KHANAT SERVER DEV * +********************* + +account gameserver +password khanat + +EOF + +# After Login +msg_debug "[$(basename $0):$LINENO] Configure banner" +cat << EOF > /etc/motd +*************************************************** +connect to root use gameserver account and launch sudo command +like : + + sudo bash + +--------------------------------------------------- +mysql : account root (no password) +--------------------------------------------------- +log khanat server : /home/gameserver/khanat/server/log/log.log +*************************************************** +EOF + +# Activate banner +msg_debug "[$(basename $0):$LINENO] Activate banner" +sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config + +#################################### +# End +#################################### +msg_info "[$(basename $0):$LINENO] => END" + diff --git a/server/debian/common/serverimage_init_khanat.sh b/server/debian/common/serverimage_init_khanat.sh new file mode 100755 index 0000000..8fff4b9 --- /dev/null +++ b/server/debian/common/serverimage_init_khanat.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Script to initialize khanat server +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +function msg_critical() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") CRITICAL - $*" >&2 + exit 2 +} + +/opt/serverimage_init_basic.sh || msg_critical "serverimage_init_basic.sh issue" +/opt/serverimage_install_package.sh || msg_critical "serverimage_install_package.sh issue" +/opt/serverimage_configure_apache.sh || msg_critical "serverimage_configure_apache.sh issue" +/opt/serverimage_configure_database.sh || msg_critical "serverimage_configure_database.sh issue" +/opt/serverimage_initialize_khanat_server.sh || msg_critical "serverimage_initialize_khanat_server.sh issue" +/opt/serverimage_initialize_patch_server.sh || msg_critical "serverimage_initialize_patch_server.sh issue" +/opt/serverimage_prepare_khanat_client.sh || msg_critical "serverimage_prepare_khanat_client.sh issue" + + +# +# Stop All +# + +service ssh stop || msg_critical "ssh stop issue" +service apache2 stop|| msg_critical "apache2 stop issue" +service mysql stop || msg_critical "mysql stop issue" + +exit 0 + diff --git a/server/debian/common/serverimage_initialize_khanat_server.sh b/server/debian/common/serverimage_initialize_khanat_server.sh new file mode 100755 index 0000000..fb1ca50 --- /dev/null +++ b/server/debian/common/serverimage_initialize_khanat_server.sh @@ -0,0 +1,103 @@ +#!/bin/bash +# +# Configure server Khanat +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +echo "INITIALIZE KHANAT SERVER" + +####################### +# GET PARAM ENVIRONMENT +####################### +export KHANAT_CLIENT_VERSION=1 + +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi + +# load environment +source /home/gameserver/.bashrc + +# Load +if [[ -f /opt/khanat_config.sh ]] +then + echo "Configuration loaded" + source /opt/khanat_config.sh + echo "KHANAT_CLIENT_VERSION:$KHANAT_CLIENT_VERSION" +fi + +# configure khanat server +sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "localhost";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2 +sed -i -r 's/(DBHost)(.*)(=)(.*)(;)/DBHost = "localhost";/g' $KHANAT_PATH/server/sql.cfg || exit 2 +sed -i -r 's/(DBRingName)(.*)(=)(.*)(;)/ DBRingName = "ring_mini01";/g' $KHANAT_PATH/server/sql.cfg || exit 2 + +# Generate data +cd /usr/local; /usr/local/bin/make_sheet_id \ + -o$KHANAT_DATA/leveldesign/game_elem/sheet_id.bin \ + $KHANAT_DATA/leveldesign/game_elem \ + $KHANAT_DATA/leveldesign/game_element \ + $KHANAT_DATA/leveldesign/world \ + $KHANAT_DATA/leveldesign/ecosystems \ + $KHANAT_DATA/sound \ + $KHANAT_DATA/mirror_sheets || exit 2 + +# configure sheets_packer.cfg +rm -rf /opt/sheets_packer/* +mkdir -p /opt/sheets_packer/common /opt/sheets_packer/khanat-ressources /opt/sheets_packer/client +cat << EOF > /opt/sheets_packer/sheets_packer.cfg +///////////////////////////////// +///////////////////////////////// +/// SHEETS PACKER CONFIG FILE /// +///////////////////////////////// +///////////////////////////////// +DataPath = { "/opt/sheets_packer/common/data_leveldesign", + "/opt/sheets_packer/common/data_common", + "/opt/sheets_packer/client/data", + "/opt/sheets_packer/khanat-ressources/common", + "/opt/sheets_packer/khanat-ressources/leveldesign", + "/opt/sheets_packer/khanat-ressources/primitives" }; +WorldSheet = "ryzom.world"; +PrimitivesPath = "/opt/sheets_packer/khanat-ressources/primitives"; +OutputDataPath = "/opt/sheets_packer/client/data"; +LigoPrimitiveClass = "world_editor_classes.xml"; +DumpVisualSlotsIndex = 1; +EOF + +# copy data to target +cp -r /opt/code/ryzom/common/* /opt/sheets_packer/common || exit 2 +cp -r $KHANAT_DATA/* /opt/sheets_packer/khanat-ressources || exit 2 +cp -r /opt/code/ryzom/client/* /opt/sheets_packer/client || exit 2 +cd /opt/sheets_packer; sheets_packer || exit 2 +cp /opt/sheets_packer/visual_slot.tab $KHANAT_PATH/common/data_common/visual_slot.tab || exit 2 +cp /opt/sheets_packer/visual_slot.tab $KHANAT_PATH/client/data/visual_slot.tab || exit 2 + +# link translation +for var in $KHANAT_DATA/translation/translated/*_en.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_en/_de}; done +for var in $KHANAT_DATA/translation/translated/*_en.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_en/_es}; done +for var in $KHANAT_DATA/translation/translated/*_wk.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_wk/_ru}; done + +# Copy default screen configuration +cp /opt/code/ryzom/server/shard.screen.rc $KHANAT_PATH/server/shard.screen.rc +sed -i -r 's/\$RYZOM_PATH\/\.\.\/build\/bin\///g' $KHANAT_PATH/server/shard.screen.rc + +ln -s /usr/local /home/gameserver/build + +# create default directory for rrd data +mkdir -p $KHANAT_PATH/server/save_shard/rrd_graphs + + diff --git a/server/debian/common/serverimage_initialize_patch_server.sh b/server/debian/common/serverimage_initialize_patch_server.sh new file mode 100755 index 0000000..763ff88 --- /dev/null +++ b/server/debian/common/serverimage_initialize_patch_server.sh @@ -0,0 +1,217 @@ +#!/bin/bash +# +# install / compile data / configure patch server +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +echo "INITIALIZE PATCH SERVER" + +####################### +# GET ENVIRONMENT +####################### +source /etc/apache2/envvars +export KHANAT_CLIENT_VERSION=1 +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi + +# load environment +source /home/gameserver/.bashrc + +# Load +if [[ -f /opt/khanat_config.sh ]] +then + echo "Configuration loaded" + source /opt/khanat_config.sh + echo "KHANAT_CLIENT_VERSION:$KHANAT_CLIENT_VERSION" +fi + +# +# Serveur Patch +# Account use : gameserver + +# Generate data to client +echo "PATCH - CREATE DIRECTORY" +echo "PATCH_HOME:$PATCH_HOME" +echo "PATCH_CLIENT_SYSTEM:$PATCH_CLIENT_SYSTEM" +mkdir -p $PATCH_HOME/patch_service/dataserver || exit 2 + +# Search le nombre de langue +listlang=$(ls $KHANAT_DATA/translation/translated | cut -f 1 -d '.' | sed 's/^.*\(.\{2\}\)$/\1/' | sort | uniq) +echo "LIST LANG : $listlang" + +for lang in $listlang +do + echo "create dir : $PATCH_HOME/patch_service/dataserver/kh_translate_$lang" + mkdir -p $PATCH_HOME/patch_service/dataserver/kh_translate_$lang || exit 2 +done +mkdir -p $PATCH_HOME/patch_service/kh_server || exit 2 +mkdir -p $PATCH_HOME/patch_service/dataserver || exit 2 +mkdir -p $PATCH_CLIENT_SYSTEM/patch_game/bnp/ + +echo "COPY DATA TO GENERATE PATCH" +cp $KHANAT_PATH/common/data_common/database.xml $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2 +cp $KHANAT_PATH/common/data_common/msg.xml $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2 +cp /opt/sheets_packer/client/data/*.packed_sheets $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2 +cp /opt/sheets_packer/client/data/*.packed $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2 +cp $KHANAT_PATH/common/data_common/visual_slot.tab $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2 +cp $KHANAT_DATA/leveldesign/game_elem/sheet_id.bin $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2 + + +cd $PATCH_HOME/patch_service/dataserver; tar xzf /opt/khanat-client-data.tar.gz || exit 2 + +# language : copy to client (to generate client patch) +for lang in $listlang +do + cp $KHANAT_DATA/translation/translated/*$lang.* $PATCH_CLIENT_SYSTEM/dataserver/kh_translate_$lang/ || exit 2 +done + +echo "GENERATE PATCH" +for lang in $listlang +do + cd $PATCH_CLIENT_SYSTEM/dataserver/; bnp_make -p kh_translate_$lang || exit 2 +done + +# tous les bnp de khanat-client-data +cd $PATCH_HOME/patch_service/dataserver/data/; bnp_make -p fonts || exit 2 +for dir in $PATCH_HOME/patch_service/dataserver/data/kh/* +do + cd $dir/..; bnp_make -p $(basename $dir) || exit 2 +done + +for dir in $PATCH_HOME/patch_service/dataserver/data/kh_shard/* +do + cd $dir/..; bnp_make -p $(basename $dir) || exit 2 +done + +for dir in $PATCH_HOME/patch_service/dataserver/data/ryz/* +do + cd $dir/..; bnp_make -p $(basename $dir) || exit 2 +done + +## TODO - check how generate '.ref' files +for dir in $PATCH_HOME/patch_service/dataserver/client/* +do + cd $dir/..; bnp_make -p $(basename $dir) || exit 2 +done +for file in $PATCH_HOME/patch_service/dataserver/client/*.bnp +do + mv "$file" "${file%.bnp}_.ref" || exit 2 +done + + +# kh_server +cd $PATCH_CLIENT_SYSTEM/; bnp_make -p kh_server || exit 2 + +echo "MOVE PATCH" + +for file in $PATCH_HOME/patch_service/dataserver/client/*.ref +do + mv "$file" $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2 +done + +for file in $PATCH_HOME/patch_service/dataserver/data/kh/*.bnp +do + mv "$file" $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2 +done + +#for file in $PATCH_HOME/patch_service/dataserver/data/kh_shard/*.bnp +#do +# mv "$file" $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2 +#done + +for file in $PATCH_HOME/patch_service/dataserver/data/ryz/*.bnp +do + mv "$file" $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2 +done + +for lang in $listlang +do + mv $PATCH_CLIENT_SYSTEM/dataserver/kh_translate_$lang.bnp $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2 +done +mv kh_server.bnp $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2 + +chown -R gameserver:$APACHE_RUN_GROUP $PATCH_HOME/patch_service || exit 2 + +echo "PREPARE PATCH" +# +su -c "cd $PATCH_HOME/patch_service; patch_gen createNewProduct patch_game/ryzom.xml" gameserver || exit 2 +su -c "cd $PATCH_HOME/patch_service;touch patch_game/Lirria.version" gameserver || exit 2 +sed -i -r 's/value="main"/value="khanat_lirria"/g' patch_game/ryzom.xml || exit 2 +sed -i -r 's/_NextVersionFile type="STRING" value=""/_NextVersionFile type="STRING" value="patch_game\/Lirria.version"/g' patch_game/ryzom.xml || exit 2 + +# Edit RYZOM file + +# search all ref files +ADDREF="" +for file in /home/gameserver/patch_service/patch_game/bnp/*.ref +do + ADDREF="$ADDREF"'<_Files type=\"STRING\" value=\"'$(basename $file)'\"/>' +done + +# Remove other _Category (keep 1st) and add ref file +cp patch_game/ryzom.xml patch_game/ryzom.xml.ref || exit 2 +awk 'BEGIN{found=0}{ + if(found==0 && $1 == "<_Category>") { + found = 1; + } else if(found == 1 && $1 == "") { + found = 2; + print "'"$ADDREF"'"; + print $0; + } else if(found == 2 && $1 == "") { + found = 3; + } + if ( found != 2 ) { + print $0 + } +}' patch_game/ryzom.xml.ref > patch_game/ryzom.xml || exit 2 + +# Force version release +if [[ $KHANAT_CLIENT_VERSION -gt 1 ]] +then + # rm $PATCH_HOME/patch_service/patch_game/ryzom.hist + # rm $PATCH_HOME/patch_service/patch_game/ref/* + echo -n "$KHANAT_CLIENT_VERSION" > $PATCH_HOME/patch_service/patch_game/Lirria.version +fi + +# Generate patch +su -c "cd $PATCH_HOME/patch_service; patch_gen updateProduct patch_game/ryzom.xml" gameserver || exit 2 + +# Edit release note +cat << EOF > $PATCH_HOME/patch_service/patch_game/patch/index.php + + + + + +

New test data - Release $KHANAT_CLIENT_VERSION

+

An update will now be performed to your client(the /user directory to be exact). + Please help us test the deployment of our free MMORPG server!! + + +EOF +chown gameserver:$APACHE_RUN_GROUP $PATCH_HOME/patch_service/patch_game/patch/index.php + +# TODO - Strange, we need update patch - to be check +cat << EOF > $PATCH_HOME/patch_service/patch_game/patch/Lirria.version +$KHANAT_CLIENT_VERSION $KHANAT_CLIENT_VERSION +EOF + +# configure right (apache can read files) +chown -R gameserver:$APACHE_RUN_GROUP $PATCH_HOME/patch_service +chmod g+w -R $PATCH_HOME/patch_service + diff --git a/server/debian/common/serverimage_install_package.sh b/server/debian/common/serverimage_install_package.sh new file mode 100755 index 0000000..b3ff94b --- /dev/null +++ b/server/debian/common/serverimage_install_package.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# +# Install binary and data +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +function msg_critical() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") CRITICAL - $*" >&2 + exit 2 +} + +echo "INSTALL PACKAGE" + +# Load Environment +source /etc/apache2/envvars +export KHANAT_CLIENT_VERSION=1 +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + +# install new package +cd /; tar xzf /opt/ryzomcore.tar.gz --strip 1 || msg_critical "[$LINENO] extract ryzomcore.tar.gz issue" +cd /opt; tar xzf ryzom-ressources.tar.gz || msg_critical "[$LINENO] extract ryzom-ressources.tar.gz issue" + +# Create Home directory (if not exist) +mkdir -p $KHANAT_PATH || msg_critical "[$LINENO] create directory $KHANAT_PATH issue" + +# install web khanat +ls -l /opt +ls -l /opt/code +cp -r /opt/code/web $KHANAT_PATH/khanatweb || msg_critical "[$LINENO] copy web data issue" +chmod -R a+w $KHANAT_PATH/khanatweb || msg_critical "[$LINENO] change right issue ($KHANAT_PATH/khanatweb)" +chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $KHANAT_PATH/khanatweb || msg_critical "[$LINENO] change owner issue ($KHANAT_PATH/khanatweb)" + +# Get Ressource +mkdir -p $KHANAT_DATA/ressources +(cd $KHANAT_DATA; tar xzf /opt/khanat-ressources.tar.gz) || msg_critical "[$LINENO] extract khanat-ressources.tar.gz issue" + +# Copy script ryzom +mkdir -p $KHANAT_PATH/tools/scripts/linux +cp -r /opt/code/ryzom/tools/scripts/linux/* $KHANAT_PATH/tools/scripts/linux || msg_critical "[$LINENO] copy all script to $KHANAT_PATH/tools/scripts/linux" + +# Copy data for server +mkdir -p $KHANAT_PATH/server || msg_critical "[$LINENO] create directory $KHANAT_PATH/server issue" +cp -r /opt/code/ryzom/common/ $KHANAT_PATH/common || msg_critical "[$LINENO] copy common data issue" +cp -r /opt/code/ryzom/client/ $KHANAT_PATH/client || msg_critical "[$LINENO] copy client data issue" +cp /opt/code/ryzom/server/*.cfg $KHANAT_PATH/server/. || msg_critical "[$LINENO] copy config issue" + +# create link resource +## Directories +ln -s $KHANAT_DATA/collisions $KHANAT_PATH/server/ +ln -s $KHANAT_DATA/leveldesign $KHANAT_PATH/server/ +ln -s $KHANAT_DATA/primitives $KHANAT_PATH/server/ +ln -s $KHANAT_DATA/translation $KHANAT_PATH/server/ +ln -s $KHANAT_DATA/continents $KHANAT_PATH/server/ +ln -s $KHANAT_DATA/common $KHANAT_PATH/server/ +## Files +mkdir -p $KHANAT_PATH/server/data_shard +cp -r /opt/code/ryzom/server/data_shard/* $KHANAT_PATH/server/data_shard/. +ln -s $KHANAT_DATA/shard/su/dev_gm_names.xml $KHANAT_PATH/server/data_shard/dev_gm_names.xml +ln -s $KHANAT_DATA/shard/su/invalid_entity_names.txt $KHANAT_PATH/server/data_shard/invalid_entity_names.txt +ln -s $KHANAT_DATA/shard/su/reserved_names.xml $KHANAT_PATH/server/data_shard/reserved_names.xml +ln -s $KHANAT_DATA/shard/egs/game_event.txt $KHANAT_PATH/server/data_shard/game_event.txt +ln -s $KHANAT_DATA/shard/egs/mission_queues.txt $KHANAT_PATH/server/data_shard/mission_queues.txt +ln -s $KHANAT_DATA/shard/egs/named_items.txt $KHANAT_PATH/server/data_shard/named_items.txt + +# copy data from khanat-code +mkdir -p $KHANAT_DATA/mirror_sheets +cp -r /opt/code/ryzom/server/data_shard/mirror_sheets/* $KHANAT_DATA/mirror_sheets + diff --git a/server/debian/common/serverimage_install_package_static.sh b/server/debian/common/serverimage_install_package_static.sh new file mode 100755 index 0000000..b527efe --- /dev/null +++ b/server/debian/common/serverimage_install_package_static.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# Install binary and data +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +echo "INSTALL PACKAGE" + +# Load Environment +source /etc/apache2/envvars +export KHANAT_CLIENT_VERSION=1 +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + +# install new package +cd /; tar xzf /opt/ryzomcore.tar.gz --strip 1 || exit 2 +cd /opt; tar xzf khanat-ref-ressources.tar.gz || exit 2 + diff --git a/server/debian/common/serverimage_launch_services.sh b/server/debian/common/serverimage_launch_services.sh new file mode 100755 index 0000000..3989130 --- /dev/null +++ b/server/debian/common/serverimage_launch_services.sh @@ -0,0 +1,99 @@ +#!/bin/bash +# +# Script to launch khaganat +# (see shard.screen.rc) +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +mkdir -p /home/gameserver/khanat/server/log +cd /home/gameserver/khanat/server/log + +function start_stop() +{ + nameservice=$1 + mkdir -p /home/gameserver/khanat/server/${nameservice} + printf RUNNING > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state + nohup $2 + printf STOPPED > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state +} + +function launch_service() +{ + nameservice=$1 + start_stop "$1" "$2" 1>/dev/null 2>&1 & + #nohup $2 1>/dev/null 2>&1 & + #echo "$!" > /home/gameserver/khanat/server/$1.pid + #printf RUNNING > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state +} + +# aes : admin_executor_service.log +launch_service 'aes' 'ryzom_admin_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --fulladminname=admin_executor_service --shortadminname=AES' + +# bms_master : backup_service.log +launch_service 'bms_master' 'ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid -P49990' + +# bms_pd_master +# launch_service 'bms_pd_master' 'ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid -P49992' + +# egs : entities_game_service.log +launch_service 'egs' 'ryzom_entities_game_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# gpms : gpm_service.log +launch_service 'gpms' 'ryzom_gpm_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# ios : input_output_service.log +launch_service 'ios' 'ryzom_ios_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# rns : naming_service.log +launch_service 'rns' 'ryzom_naming_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# rws : welcome_service.log +launch_service 'rws' 'ryzom_welcome_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# ts : tick_service.log +launch_service 'ts' 'ryzom_tick_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# ms : mirror_service.log +launch_service 'ms' 'ryzom_mirror_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# ais_newbyland : ai_service.log +launch_service 'ais_newbyland' 'ryzom_ai_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid -mCommon:Newbieland:Post' + +# mfs : mail_forum_service.log +launch_service 'mfs' 'ryzom_mail_forum_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# su : shard_unifier_service.log +launch_service 'su' 'ryzom_shard_unifier_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# fes : frontend_service.log +launch_service 'fes' 'ryzom_frontend_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# sbs : session_browser_server.log +launch_service 'sbs' 'ryzom_session_browser_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# lgs : logger_service.log +launch_service 'lgs' 'ryzom_logger_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# mos +# launch_service 'mos' 'ryzom_monitor_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# pdss +#launch_service 'pdss' 'ryzom_pd_support_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + +# ras : admin_service.log +launch_service 'ras' 'ryzom_admin_service --fulladminname=admin_service --shortadminname=AS -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid' + + diff --git a/server/debian/common/serverimage_prepare_khanat_client.sh b/server/debian/common/serverimage_prepare_khanat_client.sh new file mode 100755 index 0000000..c80ae3f --- /dev/null +++ b/server/debian/common/serverimage_prepare_khanat_client.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# +# Script to create package khanat_client +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +echo "[$(basename $0):$LINENO] PREPARE PACKAGE KHANAT CLIENT" + +# Load Environment +source /etc/apache2/envvars +export KHANAT_CLIENT_VERSION=1 +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - [$(basename $0):$LINENO] missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + +if [ -z "$PACKAGECLIENT" ] +then + echo "ERROR - [$(basename $0):$LINENO] missing definition PACKAGECLIENT" + exit 2 +fi + +if [ -z "$DIRCLIENT" ] +then + echo "ERROR - [$(basename $0):$LINENO] missing definition DIRCLIENT" + exit 2 +fi + +declare HOME_PREPARE_CLIENT="$KHANAT_HOME/prepare_client/$DIRCLIENT" +declare HOME_CLIENT="$KHANAT_HOME/client_service" + +# Create directory +mkdir -p $HOME_PREPARE_CLIENT || exit 2 +mkdir -p $HOME_PREPARE_CLIENT/{data,cfg,save,user,cache} || exit 2 +mkdir -p $HOME_CLIENT || exit 2 + +# Copy all data +cp /usr/local/games/khanat_client $HOME_PREPARE_CLIENT/. || exit 2 +cp /usr/local/etc/ryzom/client_default.cfg $HOME_PREPARE_CLIENT/. || exit 2 +sed -i -r 's/PatchWanted = 0;/PatchWanted = 1;/g' $HOME_PREPARE_CLIENT/client_default.cfg || exit 2 + +cp $PATCH_HOME/patch_service/patch_game/bnp/kh_translate_{wk,fr,en}.bnp $HOME_PREPARE_CLIENT/data/. || exit 2 +cp $PATCH_HOME/patch_service/dataserver/client/exedll_linux64/khanat.png $HOME_PREPARE_CLIENT/data/. || exit 2 +cp $PATCH_HOME/patch_service/dataserver/data/fonts.bnp $HOME_PREPARE_CLIENT/data/. || exit 2 +cp $PATCH_HOME/patch_service/patch_game/bnp/kh_interfaces.bnp $HOME_PREPARE_CLIENT/data/. || exit 2 +cp $PATCH_HOME/patch_service/patch_game/bnp/ryz_zzz_bazaar.bnp $HOME_PREPARE_CLIENT/data/. || exit 2 +cp $PATCH_HOME/khanat/client/cfg/* $HOME_PREPARE_CLIENT/cfg/. || exit 2 + +# TODO - we need search where are define some files +# .DS_Store : function ? +# khanat_install_desktop_menu.sh : script to install khanat on desktop +# khanat.desktop.in : config desktop for khanat +# khanat_install_desktop_menu.sh : script to uninstall khanat on desktop + +# Generate package +(cd $HOME_PREPARE_CLIENT/..; tar cfz $HOME_CLIENT/${PACKAGECLIENT}.tar.gz $DIRCLIENT) + +# create index for client +cat << EOF > $HOME_CLIENT/index.html + + + +KHANAT CLIENT + + + +

You can download khanat client

+khanat client + + + +EOF +chown -R gameserver:$APACHE_RUN_GROUP $HOME_CLIENT + +################################# +# +################################# + diff --git a/server/debian/common/serverimage_prepare_start_server.sh b/server/debian/common/serverimage_prepare_start_server.sh new file mode 100755 index 0000000..e2b8e62 --- /dev/null +++ b/server/debian/common/serverimage_prepare_start_server.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# +# Script to update khanat configuration (change ip address) +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +echo "PREPARE ENVIRONMENT" + +# Load Environment +export KHANAT_CLIENT_VERSION=1 +if [[ ! -f /home/gameserver/.bashrc ]] +then + echo "ERROR - missing /home/gameserver/.bashrc" + exit 2 +fi +source /home/gameserver/.bashrc + +# Get IP ADDRESS +tmp=$(hostname -I) +export addressip=${tmp//[[:blank:]]/} + +## Configure Domain +mysql -u root -e "use nel; +UPDATE nel.domain +SET backup_patch_url = '$addressip:23001' +, patch_urls = '$addressip/patch' +, login_address = '$addressip:49998' +, session_manager_address = '$addressip:49999' +, web_host = '$addressip:30000' +, web_host_php = '$addressip:40916' +WHERE domain_id = 12;" || exit 2 + +# Configure nel.shard +mysql -u root -e "use nel; +UPDATE nel.shard +SET WsAddr = '$addressip:' +WHERE ShardId = 302;" || exit 2 + +# Configure nel_tool.neltool_domains +mysql -u root -e "use nel; +UPDATE nel_tool.neltool_domains +SET domain_as_host = '$addressip' +WHERE domain_id = 12;" || exit 2 + diff --git a/server/debian/jessie/i686/Dockerfile b/server/debian/jessie/i686/Dockerfile new file mode 100644 index 0000000..9f2abbe --- /dev/null +++ b/server/debian/jessie/i686/Dockerfile @@ -0,0 +1,34 @@ +# Dockerfile - Build image to prepare khanat server +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM i386/debian:8 +MAINTAINER AleaJactaEst + +ENV HOSTNAME basic_server + +RUN apt-get update ; \ + apt-get dist-upgrade -y ; \ + apt-get install -y curl nano vim less bash-completion cron logrotate bsd-mailx ; \ + apt-get install -y openssh-server sudo net-tools ; \ + apt-get install -y lzma xdelta p7zip p7zip-full ; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server ; \ + apt-get install -y apache2 php5 libapache2-mod-php5 php5-mysql apache2-utils php5-gd php5-imagick rrdtool screen mcrypt php5-mcrypt python3 ; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin + + + diff --git a/server/debian/jessie/i686/Dockerfile.khanat.container b/server/debian/jessie/i686/Dockerfile.khanat.container new file mode 100644 index 0000000..b2b7500 --- /dev/null +++ b/server/debian/jessie/i686/Dockerfile.khanat.container @@ -0,0 +1,33 @@ +# Dockerfile - Build for server debian +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM opennel/server_generic_debian_jessie_i686 +MAINTAINER AleaJactaEst + +ENV HOSTNAME khanat_server + +COPY server/debian/common/servercontainer_function.sh /opt/ +COPY server/debian/common/servercontainer_init_* /opt/ + +COPY output/opennel_debian_jessie_i686/khanat_config.sh /opt/khanat_config.sh + +RUN /opt/servercontainer_init_create_account.sh +RUN /opt/servercontainer_init_mysql.sh +RUN /opt/servercontainer_init_apache.sh +RUN /opt/servercontainer_init_configure_envi.sh + diff --git a/server/debian/jessie/i686/Dockerfile.khanat.image b/server/debian/jessie/i686/Dockerfile.khanat.image new file mode 100644 index 0000000..cae8488 --- /dev/null +++ b/server/debian/jessie/i686/Dockerfile.khanat.image @@ -0,0 +1,33 @@ +# Dockerfile - Build for server debian +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM opennel/server_generic_debian_jessie_i686 +MAINTAINER AleaJactaEst + +ENV HOSTNAME khanat_server + +COPY todelete.sh /opt/khanat_config.sh +COPY server/debian/common/ /opt/ + +COPY output/extra/ryzomcore.tar.gz /opt/ +COPY output/extra/ryzom-ressources.tar.gz /opt/ +COPY output/extra/khanat-ressources.tar.gz /opt/ +COPY output/extra/khanat-client-data.tar.gz /opt/ + +RUN /opt/serverimage_init_khanat.sh + diff --git a/server/debian/jessie/i686/server-container.sh b/server/debian/jessie/i686/server-container.sh new file mode 100755 index 0000000..4848b0a --- /dev/null +++ b/server/debian/jessie/i686/server-container.sh @@ -0,0 +1,537 @@ +#!/bin/bash +# +# Script to start khanat server (with docker) +# All data are include on host +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +declare -i REMOVE=0 +declare -i IMAGE=1 +declare -i BASICSERVER=0 +declare -i KHANATSERVER=0 +declare -i CONFIGUREKHANATSERVER=0 +declare -i LAUNCHKHANAT=1 +declare -i UPDATEDATA=0 +declare -i DEBUG=0 +declare -i AUTODETEC=1 +declare -i STOPKHANAT=0 +declare -i CLEANCONTAINERKHANAT=0 +declare -i CONNECTSSHKHANAT=0 +declare -i KHANAT_CLIENT_VERSION=1 +declare -i SHOWIPKHANATSERVER=0 +declare METHODSTARTSERVER="--start-khanat-with-screen" +declare -i CLEANIMAGENONE=0 +declare DOCKERBUILDOPT="" + +declare IMAGEGENERICSERVER="opennel/server_generic_debian_jessie_i686" +declare IMAGEKHANATSERVER="opennel/servercontainer_debian_jessie_i686" +declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_i686" +declare DIROUTPUT="output/opennel_debian_jessie_i686" +declare ROOTDATAKHANAT="$DIROUTPUT/gameserver" +declare DIRLOG="$ROOTDATAKHANAT/log" +declare DIRDATABASE="$ROOTDATAKHANAT/database" +declare ENVIFILE="$DIROUTPUT/khanat_config.sh" +declare DIRKHANAT="$ROOTDATAKHANAT/khanat" +declare KHANAT_RESSOURCES_DIR="" +declare KHANAT_CLIENT_DATA_DIR="" +declare OPENNEL_CODE_DIR="" +declare STEP_CONFIGURE_OK="$ROOTDATAKHANAT/khanat/step_configure.ok" +declare DIRCLIENT="Khanat_Linux32" +declare PACKAGECLIENT="smokey_linux32" + +usage() +{ +cat << EOF +usage:$0 [options] + script to build under docker + + Step: + 1) create image basic server + 2) create image khanat server + 3) configure khagant server + 4) launch khagant server + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -r, --remove : Remove directory data khanat + -b, --force-basic : Force create/recreate image basic server + -k, --force-khanat : Force create/recreate image khanat server + -u, --update-data : generate a new patch (client & update server) + -g, --configure-khanat : Force configure khanat server + -n, --no-launch-khanat : Doesn't launch khanat server + -s, --stop-server : Stop server khanat + -c, --clean-container-khanat : Remove old server khanat (stopped) + -w, --clean-images-none : Remove images docker (with name 'none') + -i, --show-ip-khanat-server : show ip address for khanat server (launch under docker) + --option-docker-build=[STRING] : you can add option in "docker build" + --khanat-ressources-dir=[DIR] : localization khanat-ressources + --khanat-client-data-dir=[DIR] : localization khanat-client-data + --opennel-code-dir=[DIR] : localization opennel-code + --start-khanat-with-screen : start with screen + --start-khanat-with-khanat-log : start server khanat and show khanat log + --start-khanat-with-full-log : start server khanat and show full log + --start-khanat-with-watch-state : start server khanat and show state (loop) + --start-khanat-with-watch-state-nagios : start server khanat and show state [nagios format] (loop) + --start-khanat-with-bash-after : start server khanat and launch bash + --start-with-manager : start khanat with manager + --ssh : connect on khanat server (with ssh) [Exclusive action, can't execute other action] + --client-version=[INTEGER] : version client khanat (we need to communicate with our server) + +Example : + cd [root Khanat directory] + ./server.sh + ./server.sh -k + ./server.sh --ssh +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +# +# MAIN +# + +#msg_info "START" + +calldir="$(dirname $0)" +basedir=$(cd $calldir; pwd) +rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))" +ressourcedir="$(dirname ${rootdir})/khanat-ressources" +dataclientdir="$(dirname ${rootdir})/khanat-client-data" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + --ssh) + CONNECTSSHKHANAT=1 + shift + ;; + -r|--remove) + REMOVE=1 + CONFIGUREKHANATSERVER=1 + shift + ;; + -c|--clean-container-khanat) + CLEANCONTAINERKHANAT=1 + shift + ;; + -s|--stop-server) + STOPKHANAT=1 + shift + ;; + -b|--force-basic) + BASICSERVER=1 + shift + ;; + -n|--no-launch-khanat) + LAUNCHKHANAT=0 + shift + ;; + -k|--force-khanat) + KHANATSERVER=1 + shift + ;; + -g|--configure-khanat) + CONFIGUREKHANATSERVER=1 + shift + ;; + -i|--show-ip-khanat-server) + SHOWIPKHANATSERVER=1 + shift + ;; + --start-khanat-with-screen) + METHODSTARTSERVER="--start-khanat-with-screen" + shift + ;; + --start-khanat-with-khanat-log) + METHODSTARTSERVER="--show-khanat-log" + shift + ;; + --start-khanat-with-full-log) + METHODSTARTSERVER="--show-all-log" + shift + ;; + --start-khanat-with-watch-state) + METHODSTARTSERVER="--show-status" + shift + ;; + --start-khanat-with-watch-state-nagios) + METHODSTARTSERVER="--show-status-nagios" + shift + ;; + --start-khanat-with-bash-after) + METHODSTARTSERVER="--bash-after-start" + shift + ;; + --start-with-manager) + METHODSTARTSERVER="--start-with-manager" + shift + ;; + --client-version*) + KHANAT_CLIENT_VERSION="${1#*=}" + shift + ;; + --khanat-ressources-dir=*) + KHANAT_RESSOURCES_DIR="${1#*=}" + shift + ;; + --khanat-client-data-dir=*) + KHANAT_CLIENT_DATA_DIR="${1#*=}" + shift + ;; + --opennel-code-dir=*) + OPENNEL_CODE_DIR="${1#*=}" + shift + ;; + -w|--clean-images-none) + CLEANIMAGENONE=1 + shift + ;; + -u|--update-data) + UPDATEDATA=1 + shift + ;; + --option-docker-build) + DOCKERBUILDOPT="$DOCKERBUILDOPT ${1#*=}" + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +function chrashed() +{ + msg_error "BUILD FAILED (code:$?)" + exit 2 +} + +trap chrashed EXIT + +if [[ $SHOWIPKHANATSERVER -eq 0 ]] +then + msg_info "START" +fi + +msg_debug "prg: $0" + +docker -v 1>/dev/null +if [[ $? -ne 0 ]] +then + msg_error "docker not installed" + exit 2 +fi + +case "$(uname -m)" in + x86_64) + ;; + i686) + ;; + *) + msg_error "Unknown archi : $(uname -m)" + exit 2 + ;; +esac + +if [[ $REMOVE -ne 0 ]] +then + msg_info "REMOVE DATA KHANAT : $ROOTDATAKHANAT" + if [[ -n "$ROOTDATAKHANAT" ]] + then + rm -rf ${ROOTDATAKHANAT}/* || exit 2 + fi +fi + +msg_debug "Create directory on host ($ROOTDATAKHANAT)" +mkdir -p $ROOTDATAKHANAT || exit 2 +chmod g+s $ROOTDATAKHANAT + + +if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]] +then + msg_debug "clean container" + listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')" + if [[ ${#listcontainer[@]} -eq 1 ]] + then + ipaddress=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" ${listcontainer[@]}) + fi +fi + +if [[ $SHOWIPKHANATSERVER -ne 0 ]] +then + trap '' EXIT + echo "$ipaddress" + exit 0 +fi + +if [[ $CONNECTSSHKHANAT -ne 0 ]] +then + ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no gameserver@$ipaddress + trap '' EXIT + msg_info "END SSH" + exit 0 +fi + +if [[ $AUTODETEC -ne 0 ]] +then + msg_debug "Autodetect state" + if [[ $(docker images -f "reference=$IMAGEGENERICSERVER" | wc -l) -lt 2 ]] + then + BASICSERVER=1 + fi + if [[ $(docker images -f "reference=$IMAGEKHANATSERVER" | wc -l) -lt 2 ]] + then + KHANATSERVER=1 + fi + if [[ -z "$KHANAT_RESSOURCES_DIR" ]] + then + KHANAT_RESSOURCES_DIR="$(dirname $rootdir)/khanat-ressources" + fi + if [[ -z "$KHANAT_CLIENT_DATA_DIR" ]] + then + KHANAT_CLIENT_DATA_DIR="$(dirname $rootdir)/khanat-client-data" + fi + if [[ -z "$OPENNEL_CODE_DIR" ]] + then + OPENNEL_CODE_DIR="$(dirname $rootdir)/khanat-opennel-code" + fi + if [[ ! (-f $rootdir/$STEP_CONFIGURE_OK) ]] + then + CONFIGUREKHANATSERVER=1 + fi +fi + +DIRBUILD="${rootdir}/${LOCALBUILDDIR}" + +msg_debug "calldir: $calldir" +msg_debug "basedir: $basedir" +msg_debug "rootdir: $rootdir" +msg_debug "ressourcedir: $ressourcedir" +msg_debug "generate basic image: $BASICSERVER" +msg_debug "localization khanat-ressources : ${KHANAT_RESSOURCES_DIR}" +msg_debug "localization khanat-client-data: ${KHANAT_CLIENT_DATA_DIR}" +msg_debug "localization opennel-code-client : ${OPENNEL_CODE_DIR}" +msg_debug "generate khanat image: $KHANATSERVER" +msg_debug "launch khanat: $LAUNCHKHANAT" +msg_debug "stop khanat: $STOPKHANAT" + +msg_info "check khanat-ressources" +if [[ ! -d ${KHANAT_RESSOURCES_DIR} ]] +then + msg_error "Missing directory khanat-ressources [${KHANAT_RESSOURCES_DIR}]" + cat << EOF +You need clone repo khanat-ressource. + +cd $(dirname ${KHANAT_RESSOURCES_DIR}) +git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-ressources.git + +EOF + exit 2 +fi + + +msg_info "check khanat-client-data" +if [[ ! -d ${KHANAT_CLIENT_DATA_DIR} ]] +then + msg_error "Missing directory khanat-client-data [${KHANAT_CLIENT_DATA_DIR}]" + cat << EOF +You need clone repo khanat-client-data. + +cd $(dirname ${KHANAT_CLIENT_DATA_DIR}) +git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-client-data.git + +EOF + exit 2 +fi + +if [[ ! -d ${OPENNEL_CODE_DIR} ]] +then + msg_error "Missing directory opennel-code [${OPENNEL_CODE_DIR}]" + cat << EOF +You need clone repo khanat-opennel-code. + +cd $(dirname ${KHANAT_RESSOURCES_DIR}) +git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git + +EOF + exit 2 +fi +if [[ $STOPKHANAT -ne 0 ]] +then + msg_info "STOP SERVER KHANAT" + listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')" + msg_debug "CONTAINER KHANAT UP : ${listcontainer[@]}" + if [[ -n "$listcontainer" ]] + then + docker stop "$listcontainer" || exit 2 + fi +fi + +if [[ $CLEANCONTAINERKHANAT -ne 0 ]] +then + msg_info "CLEAN CONTAINER KHANAT" + listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') ) + msg_debug "CONTAINER KHANAT EXITED : ${listcontainer[@]}" + if [[ -n "${listcontainer[@]}" ]] + then + docker rm --force "${listcontainer[@]}" || exit 2 + fi +fi + +if [[ $CLEANIMAGENONE -ne 0 ]] +then + msg_info "CLEAN IMAGE DOCKER 'NONE'" + listimages=( $(docker images | awk '{if ($1=="")print $3}') ) + + msg_debug "IMAGES NONE : ${listimages[@]}" + if [[ -n "${listimages[@]}" ]] + then + docker rmi --force "${listimages[@]}" || exit 2 + fi +fi + +if [[ $BASICSERVER -ne 0 ]] +then + msg_info "GENERATE DOCKER IMAGE BASIC SERVER" + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEGENERICSERVER} \ + --file "${basedir}/Dockerfile" || exit 2 +fi + +if [[ $KHANATSERVER -ne 0 ]] +then + msg_info "GENERATE DOCKER IMAGE KHANAT SERVER" + cat << EOF > $rootdir/${ENVIFILE} +#!/bin/bash +# Temporary file, use only to send some information on build docker +export KHANAT_CLIENT_VERSION=$KHANAT_CLIENT_VERSION +export UIDGAMESERVER=$(id -u) +export GIDGAMESERVER=$(id -g) +export DIRCLIENT="$DIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +EOF + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \ + --file "${basedir}/Dockerfile.khanat.container" || exit 2 +fi + +if [[ $CONFIGUREKHANATSERVER -ne 0 ]] +then + msg_info "CONFIGURE KHANAT SERVER" + mkdir -p $DIRLOG || exit 2 + mkdir -p $DIRDATABASE || exit 2 + msg_debug "command : cd $rootdir; docker run -it --hostname=khanat \ + -v /etc/localtime:/etc/localtime:ro \ + -v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \ + -v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \ + -v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \ + -v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \ + -v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \ + -v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \ + -v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \ + -v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \ + -v ${rootdir}/server/debian/common/:/opt/ext:ro \ + ${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh" + cd $rootdir; docker run -it --hostname=khanat \ + -v /etc/localtime:/etc/localtime:ro \ + -v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \ + -v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \ + -v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \ + -v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \ + -v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \ + -v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \ + -v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \ + -v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \ + -v ${rootdir}/server/debian/common/:/opt/ext:ro \ + ${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh || exit 2 +fi + +if [[ $UPDATEDATA -ne 0 ]] +then + msg_info "UPDATE KHANAT SERVER" + msg_debug "command: cd $rootdir; docker run -it --hostname=khanat \ + -v /etc/localtime:/etc/localtime:ro \ + -v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \ + -v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \ + -v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \ + -v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \ + -v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \ + -v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \ + -v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \ + -v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \ + -v ${rootdir}/server/debian/common/:/opt/ext:ro \ + ${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh" + cd $rootdir; docker run -it --hostname=khanat \ + -v /etc/localtime:/etc/localtime:ro \ + -v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \ + -v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \ + -v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \ + -v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \ + -v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \ + -v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \ + -v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \ + -v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \ + -v ${rootdir}/server/debian/common/:/opt/ext:ro \ + ${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh +fi + +if [[ $LAUNCHKHANAT -ne 0 ]] +then + msg_info "START KHANAT SERVER" + cd $rootdir; docker run -it --hostname=khanat \ + -u "$(id -u $USERNAME):$(id -g $USERNAME)" \ + -v /etc/localtime:/etc/localtime:ro \ + -v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \ + -v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \ + -v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \ + -v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \ + -v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \ + -v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \ + -v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \ + -v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \ + -v ${rootdir}/server/debian/common/:/opt/ext:ro \ + ${IMAGEKHANATSERVER} /opt/ext/servercontainer_launch_auto.sh $METHODSTARTSERVER -d +fi + +trap '' EXIT +msg_info "END" diff --git a/server/debian/jessie/i686/server-image.sh b/server/debian/jessie/i686/server-image.sh new file mode 100755 index 0000000..2ab11b2 --- /dev/null +++ b/server/debian/jessie/i686/server-image.sh @@ -0,0 +1,443 @@ +#!/bin/bash +# +# Script to start khanat server +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +declare -i IMAGE=1 +declare -i BASICSERVER=0 +declare -i KHANATSERVER=0 +declare -i KHANATRESSOURCES=0 +declare -i KHANATDATACLIENT=0 +declare -i RYZOMRESSOURCES=0 +declare -i LAUNCHKHANAT=1 +declare -i DEBUG=0 +declare -i AUTODETEC=1 +declare -i STOPKHANAT=0 +declare -i CLEANCONTAINERKHANAT=0 +declare -i CONNECTSSHKHANAT=0 +declare -i KHANAT_CLIENT_VERSION=1 +declare -i SHOWIPKHANATSERVER=0 +declare -i METHODSTARTSERVER=1 +declare -i CLEANIMAGENONE=0 +declare DOCKERBUILDOPT="" +declare OPENNEL_CODE_DIR="" + +declare IMAGEGENERICSERVER="opennel/server_generic_debian_jessie_i686" +declare IMAGEKHANATSERVER="opennel/serverimage_debian_jessie_i686" +declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_i686" +declare DIRCLIENT="Khanat_Linux32" +declare PACKAGECLIENT="smokey_linux32" +declare DIROUTPUT="output/extra" + +usage() +{ +cat << EOF +usage:$0 [options] + script to build under docker + + Step: + 1) generate tar with khanat-ressources + 2) generate tar with ryzom-ressources + 3) create image basic server + 4) create image khanat server + 5) launch khanat server + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -b, --force-basic : Force create/recreate image basic server + -t, --force-tar-ressources : Generate TAR.GZ for khanat-ressources (look directory ../khanat-ressources) + -q, --force-tar-client-data : Generate TAR.GZ for khanat-client-data (look directory ../khanat-client-data) + -z, --force-tar-ryzom-ressources : Generate TAR.GZ in data khanat-code + -k, --force-khanat : Force create/recreate image khanat server + -n, --no-launch-khanat : Doesn't launch khanat server + -s, --stop-server : Stop server khanat + -c, --clean-container-khanat : Remove old server khanat (stopped) + -w, --clean-images-none : Remove images docker (with name 'none') + -i, --show-ip-khanat-server : show ip address for khanat server (launch under docker) + --option-docker-build=[STRING] : you can add option in "docker build" + --opennel-code-dir=[DIR] : localization opennel-code + --start-khanat-with-screen : [default] start khanat with screen + --start-khanat-with-full-log : start server khanat and show full log + --start-khanat-with-watch-state : start server khanat and show state (loop) + --ssh : connect on khanat server (with ssh) [Exclusive action, can't execute other action] + --client-version=[INTEGER] : version client khanat (we need to communicate with our server) + +Example : + cd [root Khanat directory] + ./server.sh + ./server.sh -k + ./server.sh --ssh +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +# +# MAIN +# + +#msg_info "START" + +calldir="$(dirname $0)" +basedir=$(cd $calldir; pwd) +rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))" +ressourcedir="$(dirname ${rootdir})/khanat-ressources" +dataclientdir="$(dirname ${rootdir})/khanat-client-data" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + --ssh) + CONNECTSSHKHANAT=1 + shift + ;; + -c|--clean-container-khanat) + CLEANCONTAINERKHANAT=1 + shift + ;; + -s|--stop-server) + STOPKHANAT=1 + shift + ;; + -b|--force-basic) + BASICSERVER=1 + shift + ;; + -n|--no-launch-khanat) + LAUNCHKHANAT=0 + shift + ;; + -t|--force-tar-ressources) + KHANATRESSOURCES=1 + shift + ;; + -q|--force-tar-client-data) + KHANATDATACLIENT=1 + shift + ;; + -z|--force-tar-ryzom-ressources) + RYZOMRESSOURCES=1 + shift + ;; + -k|--force-khanat) + KHANATSERVER=1 + shift + ;; + -i|--show-ip-khanat-server) + SHOWIPKHANATSERVER=1 + shift + ;; + --start-khanat-with-screen) + METHODSTARTSERVER=1 + shift + ;; + --start-khanat-with-full-log) + METHODSTARTSERVER=2 + shift + ;; + --start-khanat-with-watch-state) + METHODSTARTSERVER=3 + shift + ;; + --client-version*) + KHANAT_CLIENT_VERSION="${1#*=}" + shift + ;; + -w|--clean-images-none) + CLEANIMAGENONE=1 + shift + ;; + --option-docker-build) + DOCKERBUILDOPT="$DOCKERBUILDOPT ${1#*=}" + shift + ;; + --opennel-code-dir=*) + OPENNEL_CODE_DIR="${1#*=}" + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +function chrashed() +{ + msg_error "BUILD FAILED (code:$?)" + exit 2 +} + +trap chrashed EXIT + +if [[ $SHOWIPKHANATSERVER -eq 0 ]] +then + msg_info "START" +fi + +msg_debug "prg: $0" + +extradir="${rootdir}/${DIROUTPUT}" +mkdir -p ${extradir} || exit 2 + + +docker -v 1>/dev/null +if [[ $? -ne 0 ]] +then + msg_error "docker not installed" + exit 2 +fi + +case "$(uname -m)" in + x86_64) + ;; + i686) + ;; + *) + msg_error "Unknown archi : $(uname -m)" + exit 2 + ;; +esac + +if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]] +then + listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')" + if [[ ${#listcontainer[@]} -eq 1 ]] + then + ipaddress=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" ${listcontainer[@]}) + fi +fi + +if [[ $SHOWIPKHANATSERVER -ne 0 ]] +then + trap '' EXIT + echo "$ipaddress" + exit 0 +fi + +if [[ $CONNECTSSHKHANAT -ne 0 ]] +then + ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no gameserver@$ipaddress + trap '' EXIT + msg_info "END SSH" + exit 0 +fi + +if [[ $AUTODETEC -ne 0 ]] +then + if [[ $(docker images -f "reference=$IMAGEGENERICSERVER" | wc -l) -lt 2 ]] + then + BASICSERVER=1 + fi + if [[ ! -f ${extradir}/khanat-ressources.tar.gz ]] + then + KHANATRESSOURCES=1 + fi + if [[ ! -f ${extradir}/khanat-client-data.tar.gz ]] + then + KHANATDATACLIENT=1 + fi + if [[ ! -f ${extradir}/ryzom-ressources.tar.gz ]] + then + RYZOMRESSOURCES=1 + fi + if [[ $(docker images -f "reference=$IMAGEKHANATSERVER" | wc -l) -lt 2 ]] + then + KHANATSERVER=1 + fi + if [[ -z "$OPENNEL_CODE_DIR" ]] + then + OPENNEL_CODE_DIR="$(dirname $rootdir)/khanat-opennel-code" + fi + + if [[ -f ${extradir}/ryzomcore.tar.gz ]] + then + sumsrc=$(md5sum ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz | awk '{print $1}') + sumdst=$(md5sum ${extradir}/ryzomcore.tar.gz | awk '{print $1}') + else + sumsrc=1 + sumdsr=2 + fi + msg_debug "ryzomcore checksum src:$sumsrc dst:$sumdst" + if [[ "$sumsrc" != "$sumdst" ]] + then + msg_debug "copy ryzomcore" + cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${extradir}/ryzomcore.tar.gz || exit 2 + KHANATSERVER=1 + fi +fi + +DIRBUILD="${rootdir}/${LOCALBUILDDIR}" + +msg_debug "calldir: $calldir" +msg_debug "basedir: $basedir" +msg_debug "rootdir: $rootdir" +msg_debug "ressourcedir: $ressourcedir" +msg_debug "generate basic image: $BASICSERVER" +msg_debug "generate tar khanat ressources: $KHANATRESSOURCES" +msg_debug "generate tar khanat data client: $KHANATDATACLIENT" +msg_debug "generate tar ryzom ressources: $RYZOMRESSOURCES" +msg_debug "generate khanat image: $KHANATSERVER" +msg_debug "launch khanat: $LAUNCHKHANAT" +msg_debug "stop khanat: $STOPKHANAT" + +if [[ ! -d ${OPENNEL_CODE_DIR} ]] +then + msg_error "Missing directory opennel-code [${OPENNEL_CODE_DIR}]" + cat << EOF +You need clone repo khanat-opennel-code. + +cd $(dirname ${KHANAT_RESSOURCES_DIR}) +git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git + +EOF + exit 2 +fi + +if [[ $KHANATRESSOURCES -ne 0 ]] +then + msg_info "CREATE TAR with KHANAT Ressources" + if [[ ! -d ${ressourcedir} ]] + then + msg_error "Missing khanat-ressources directory ($ressourcedir)" + exit 2 + fi + (cd $ressourcedir; tar --exclude='.git' -czf ${extradir}/khanat-ressources.tar.gz .) || exit 2 +fi + +if [[ $KHANATDATACLIENT -ne 0 ]] +then + msg_info "CREATE TAR with KHANAT DATA CLIENT" + if [[ ! -d ${dataclientdir} ]] + then + msg_error "Missing khanat-client-data directory ($dataclientdir)" + exit 2 + fi + (cd $dataclientdir; tar --exclude='.git' -czf ${extradir}/khanat-client-data.tar.gz .) || exit 2 +fi + +if [[ $RYZOMRESSOURCES -ne 0 ]] +then + msg_info "CREATE TAR with RYZOM Ressources" + if [[ ! -d ${ressourcedir} ]] + then + msg_error "Missing khanat-ressources directory ($ressourcedir)" + exit 2 + fi + cd ${OPENNEL_CODE_DIR}; tar czf ${extradir}/ryzom-ressources.tar.gz \ + code/ryzom/server/shard.screen.rc \ + code/ryzom/common/* \ + code/ryzom/client/* \ + code/ryzom/server/* \ + code/ryzom/tools/scripts/linux/* \ + code/web/* || exit 2 +fi + +if [[ $STOPKHANAT -ne 0 ]] +then + msg_info "STOP SERVER KHANAT" + listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')" + msg_debug "CONTAINER KHANAT UP : ${listcontainer[@]}" + if [[ -n "$listcontainer" ]] + then + docker stop "$listcontainer" || exit 2 + fi +fi + +if [[ $CLEANCONTAINERKHANAT -ne 0 ]] +then + msg_info "CLEAN CONTAINER KHANAT" + listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') ) + msg_debug "CONTAINER KHANAT EXITED : ${listcontainer[@]}" + if [[ -n "${listcontainer[@]}" ]] + then + docker rm --force "${listcontainer[@]}" || exit 2 + fi +fi + +if [[ $CLEANIMAGENONE -ne 0 ]] +then + msg_info "CLEAN IMAGE DOCKER 'NONE'" + listimages=( $(docker images | awk '{if ($1=="")print $3}') ) + + msg_debug "IMAGES NONE : ${listimages[@]}" + if [[ -n "${listimages[@]}" ]] + then + docker rmi --force "${listimages[@]}" || exit 2 + fi +fi + +if [[ $BASICSERVER -ne 0 ]] +then + msg_info "GENERATE DOCKER IMAGE BASIC SERVER" + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEGENERICSERVER} \ + --file "${basedir}/Dockerfile" || exit 2 +fi + +if [[ $KHANATSERVER -ne 0 ]] +then + msg_info "GENERATE DOCKER IMAGE KHANAT SERVER" + cat << EOF > $rootdir/todelete.sh +#!/bin/bash +# Temporary file, use only to send some information on build docker +export KHANAT_CLIENT_VERSION=$KHANAT_CLIENT_VERSION +export DIRCLIENT="$DIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +EOF + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \ + --file "${basedir}/Dockerfile.khanat.image" || exit 2 + rm $rootdir/todelete.sh +fi + +if [[ $LAUNCHKHANAT -ne 0 ]] +then + msg_info "START KHANAT SERVER" + cd $rootdir; docker run -it --hostname=khanat \ + -v /etc/localtime:/etc/localtime:ro \ + ${IMAGEKHANATSERVER} /opt/serverimage_autostart.sh $METHODSTARTSERVER + clear +fi + +trap '' EXIT +msg_info "END" diff --git a/server/debian/jessie/x86_64/Dockerfile b/server/debian/jessie/x86_64/Dockerfile new file mode 100644 index 0000000..030055e --- /dev/null +++ b/server/debian/jessie/x86_64/Dockerfile @@ -0,0 +1,34 @@ +# Dockerfile - Build image to prepare khanat server +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM amd64/debian:8 +MAINTAINER AleaJactaEst + +ENV HOSTNAME basic_server + +RUN apt-get update ; \ + apt-get dist-upgrade -y ; \ + apt-get install -y curl nano vim less bash-completion cron logrotate bsd-mailx ; \ + apt-get install -y openssh-server sudo net-tools ; \ + apt-get install -y lzma xdelta p7zip p7zip-full ; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server ; \ + apt-get install -y apache2 php5 libapache2-mod-php5 php5-mysql apache2-utils php5-gd php5-imagick rrdtool screen mcrypt php5-mcrypt python3 ; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin + + + diff --git a/server/debian/jessie/x86_64/Dockerfile.khanat.container b/server/debian/jessie/x86_64/Dockerfile.khanat.container new file mode 100644 index 0000000..825f087 --- /dev/null +++ b/server/debian/jessie/x86_64/Dockerfile.khanat.container @@ -0,0 +1,33 @@ +# Dockerfile - Build for server debian +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM opennel/server_generic_debian_jessie_x86_64 +MAINTAINER AleaJactaEst + +ENV HOSTNAME khanat_server + +COPY server/debian/common/servercontainer_function.sh /opt/ +COPY server/debian/common/servercontainer_init_* /opt/ + +COPY output/opennel_debian_jessie_x86_64/khanat_config.sh /opt/khanat_config.sh + +RUN /opt/servercontainer_init_create_account.sh +RUN /opt/servercontainer_init_mysql.sh +RUN /opt/servercontainer_init_apache.sh +RUN /opt/servercontainer_init_configure_envi.sh + diff --git a/server/debian/jessie/x86_64/Dockerfile.khanat.image b/server/debian/jessie/x86_64/Dockerfile.khanat.image new file mode 100644 index 0000000..57b4ff0 --- /dev/null +++ b/server/debian/jessie/x86_64/Dockerfile.khanat.image @@ -0,0 +1,33 @@ +# Dockerfile - Build for server debian +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM opennel/server_generic_debian_jessie_x86_64 +MAINTAINER AleaJactaEst + +ENV HOSTNAME khanat_server + +COPY todelete.sh /opt/khanat_config.sh +COPY server/debian/common/ /opt/ + +COPY output/extra/ryzomcore.tar.gz /opt/ +COPY output/extra/ryzom-ressources.tar.gz /opt/ +COPY output/extra/khanat-ressources.tar.gz /opt/ +COPY output/extra/khanat-client-data.tar.gz /opt/ + +RUN /opt/serverimage_init_khanat.sh + diff --git a/server/debian/jessie/x86_64/server-container.sh b/server/debian/jessie/x86_64/server-container.sh new file mode 100755 index 0000000..af3fd46 --- /dev/null +++ b/server/debian/jessie/x86_64/server-container.sh @@ -0,0 +1,537 @@ +#!/bin/bash +# +# Script to start khanat server (with docker) +# All data are include on host +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +declare -i REMOVE=0 +declare -i IMAGE=1 +declare -i BASICSERVER=0 +declare -i KHANATSERVER=0 +declare -i CONFIGUREKHANATSERVER=0 +declare -i LAUNCHKHANAT=1 +declare -i UPDATEDATA=0 +declare -i DEBUG=0 +declare -i AUTODETEC=1 +declare -i STOPKHANAT=0 +declare -i CLEANCONTAINERKHANAT=0 +declare -i CONNECTSSHKHANAT=0 +declare -i KHANAT_CLIENT_VERSION=1 +declare -i SHOWIPKHANATSERVER=0 +declare METHODSTARTSERVER="--start-khanat-with-screen" +declare -i CLEANIMAGENONE=0 +declare DOCKERBUILDOPT="" + +declare IMAGEGENERICSERVER="opennel/server_generic_debian_jessie_x86_64" +declare IMAGEKHANATSERVER="opennel/servercontainer_debian_jessie_x86_64" +declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_x86_64" +declare DIROUTPUT="output/opennel_debian_jessie_x86_64" +declare ROOTDATAKHANAT="$DIROUTPUT/gameserver" +declare DIRLOG="$ROOTDATAKHANAT/log" +declare DIRDATABASE="$ROOTDATAKHANAT/database" +declare ENVIFILE="$DIROUTPUT/khanat_config.sh" +declare DIRKHANAT="$ROOTDATAKHANAT/khanat" +declare KHANAT_RESSOURCES_DIR="" +declare KHANAT_CLIENT_DATA_DIR="" +declare OPENNEL_CODE_DIR="" +declare STEP_CONFIGURE_OK="$ROOTDATAKHANAT/khanat/step_configure.ok" +declare DIRCLIENT="Khanat_Linux64" +declare PACKAGECLIENT="smokey_linux64" + +usage() +{ +cat << EOF +usage:$0 [options] + script to build under docker + + Step: + 1) create image basic server + 2) create image khanat server + 3) configure khagant server + 4) launch khagant server + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -r, --remove : Remove directory data khanat + -b, --force-basic : Force create/recreate image basic server + -k, --force-khanat : Force create/recreate image khanat server + -u, --update-data : generate a new patch (client & update server) + -g, --configure-khanat : Force configure khanat server + -n, --no-launch-khanat : Doesn't launch khanat server + -s, --stop-server : Stop server khanat + -c, --clean-container-khanat : Remove old server khanat (stopped) + -w, --clean-images-none : Remove images docker (with name 'none') + -i, --show-ip-khanat-server : show ip address for khanat server (launch under docker) + --option-docker-build=[STRING] : you can add option in "docker build" + --khanat-ressources-dir=[DIR] : localization khanat-ressources + --khanat-client-data-dir=[DIR] : localization khanat-client-data + --opennel-code-dir=[DIR] : localization opennel-code + --start-khanat-with-screen : start with screen + --start-khanat-with-khanat-log : start server khanat and show khanat log + --start-khanat-with-full-log : start server khanat and show full log + --start-khanat-with-watch-state : start server khanat and show state (loop) + --start-khanat-with-watch-state-nagios : start server khanat and show state [nagios format] (loop) + --start-khanat-with-bash-after : start server khanat and launch bash + --start-with-manager : start khanat with manager + --ssh : connect on khanat server (with ssh) [Exclusive action, can't execute other action] + --client-version=[INTEGER] : version client khanat (we need to communicate with our server) + +Example : + cd [root Khanat directory] + ./server.sh + ./server.sh -k + ./server.sh --ssh +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +# +# MAIN +# + +#msg_info "START" + +calldir="$(dirname $0)" +basedir=$(cd $calldir; pwd) +rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))" +ressourcedir="$(dirname ${rootdir})/khanat-ressources" +dataclientdir="$(dirname ${rootdir})/khanat-client-data" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + --ssh) + CONNECTSSHKHANAT=1 + shift + ;; + -r|--remove) + REMOVE=1 + CONFIGUREKHANATSERVER=1 + shift + ;; + -c|--clean-container-khanat) + CLEANCONTAINERKHANAT=1 + shift + ;; + -s|--stop-server) + STOPKHANAT=1 + shift + ;; + -b|--force-basic) + BASICSERVER=1 + shift + ;; + -n|--no-launch-khanat) + LAUNCHKHANAT=0 + shift + ;; + -k|--force-khanat) + KHANATSERVER=1 + shift + ;; + -g|--configure-khanat) + CONFIGUREKHANATSERVER=1 + shift + ;; + -i|--show-ip-khanat-server) + SHOWIPKHANATSERVER=1 + shift + ;; + --start-khanat-with-screen) + METHODSTARTSERVER="--start-khanat-with-screen" + shift + ;; + --start-khanat-with-khanat-log) + METHODSTARTSERVER="--show-khanat-log" + shift + ;; + --start-khanat-with-full-log) + METHODSTARTSERVER="--show-all-log" + shift + ;; + --start-khanat-with-watch-state) + METHODSTARTSERVER="--show-status" + shift + ;; + --start-khanat-with-watch-state-nagios) + METHODSTARTSERVER="--show-status-nagios" + shift + ;; + --start-khanat-with-bash-after) + METHODSTARTSERVER="--bash-after-start" + shift + ;; + --start-with-manager) + METHODSTARTSERVER="--start-with-manager" + shift + ;; + --client-version*) + KHANAT_CLIENT_VERSION="${1#*=}" + shift + ;; + --khanat-ressources-dir=*) + KHANAT_RESSOURCES_DIR="${1#*=}" + shift + ;; + --khanat-client-data-dir=*) + KHANAT_CLIENT_DATA_DIR="${1#*=}" + shift + ;; + --opennel-code-dir=*) + OPENNEL_CODE_DIR="${1#*=}" + shift + ;; + -w|--clean-images-none) + CLEANIMAGENONE=1 + shift + ;; + -u|--update-data) + UPDATEDATA=1 + shift + ;; + --option-docker-build) + DOCKERBUILDOPT="$DOCKERBUILDOPT ${1#*=}" + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +function chrashed() +{ + msg_error "BUILD FAILED (code:$?)" + exit 2 +} + +trap chrashed EXIT + +if [[ $SHOWIPKHANATSERVER -eq 0 ]] +then + msg_info "START" +fi + +msg_debug "prg: $0" + +docker -v 1>/dev/null +if [[ $? -ne 0 ]] +then + msg_error "docker not installed" + exit 2 +fi + +case "$(uname -m)" in + x86_64) + ;; + i686) + ;; + *) + msg_error "Unknown archi : $(uname -m)" + exit 2 + ;; +esac + +if [[ $REMOVE -ne 0 ]] +then + msg_info "REMOVE DATA KHANAT : $ROOTDATAKHANAT" + if [[ -n "$ROOTDATAKHANAT" ]] + then + rm -rf ${ROOTDATAKHANAT}/* || exit 2 + fi +fi + +msg_debug "Create directory on host ($ROOTDATAKHANAT)" +mkdir -p $ROOTDATAKHANAT || exit 2 +chmod g+s $ROOTDATAKHANAT + + +if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]] +then + msg_debug "clean container" + listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')" + if [[ ${#listcontainer[@]} -eq 1 ]] + then + ipaddress=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" ${listcontainer[@]}) + fi +fi + +if [[ $SHOWIPKHANATSERVER -ne 0 ]] +then + trap '' EXIT + echo "$ipaddress" + exit 0 +fi + +if [[ $CONNECTSSHKHANAT -ne 0 ]] +then + ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no gameserver@$ipaddress + trap '' EXIT + msg_info "END SSH" + exit 0 +fi + +if [[ $AUTODETEC -ne 0 ]] +then + msg_debug "Autodetect state" + if [[ $(docker images -f "reference=$IMAGEGENERICSERVER" | wc -l) -lt 2 ]] + then + BASICSERVER=1 + fi + if [[ $(docker images -f "reference=$IMAGEKHANATSERVER" | wc -l) -lt 2 ]] + then + KHANATSERVER=1 + fi + if [[ -z "$KHANAT_RESSOURCES_DIR" ]] + then + KHANAT_RESSOURCES_DIR="$(dirname $rootdir)/khanat-ressources" + fi + if [[ -z "$KHANAT_CLIENT_DATA_DIR" ]] + then + KHANAT_CLIENT_DATA_DIR="$(dirname $rootdir)/khanat-client-data" + fi + if [[ -z "$OPENNEL_CODE_DIR" ]] + then + OPENNEL_CODE_DIR="$(dirname $rootdir)/khanat-opennel-code" + fi + if [[ ! (-f $rootdir/$STEP_CONFIGURE_OK) ]] + then + CONFIGUREKHANATSERVER=1 + fi +fi + +DIRBUILD="${rootdir}/${LOCALBUILDDIR}" + +msg_debug "calldir: $calldir" +msg_debug "basedir: $basedir" +msg_debug "rootdir: $rootdir" +msg_debug "ressourcedir: $ressourcedir" +msg_debug "generate basic image: $BASICSERVER" +msg_debug "localization khanat-ressources : ${KHANAT_RESSOURCES_DIR}" +msg_debug "localization khanat-client-data: ${KHANAT_CLIENT_DATA_DIR}" +msg_debug "localization opennel-code-client : ${OPENNEL_CODE_DIR}" +msg_debug "generate khanat image: $KHANATSERVER" +msg_debug "launch khanat: $LAUNCHKHANAT" +msg_debug "stop khanat: $STOPKHANAT" + +msg_info "check khanat-ressources" +if [[ ! -d ${KHANAT_RESSOURCES_DIR} ]] +then + msg_error "Missing directory khanat-ressources [${KHANAT_RESSOURCES_DIR}]" + cat << EOF +You need clone repo khanat-ressource. + +cd $(dirname ${KHANAT_RESSOURCES_DIR}) +git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-ressources.git + +EOF + exit 2 +fi + + +msg_info "check khanat-client-data" +if [[ ! -d ${KHANAT_CLIENT_DATA_DIR} ]] +then + msg_error "Missing directory khanat-client-data [${KHANAT_CLIENT_DATA_DIR}]" + cat << EOF +You need clone repo khanat-client-data. + +cd $(dirname ${KHANAT_CLIENT_DATA_DIR}) +git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-client-data.git + +EOF + exit 2 +fi + +if [[ ! -d ${OPENNEL_CODE_DIR} ]] +then + msg_error "Missing directory opennel-code [${OPENNEL_CODE_DIR}]" + cat << EOF +You need clone repo khanat-opennel-code. + +cd $(dirname ${KHANAT_RESSOURCES_DIR}) +git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git + +EOF + exit 2 +fi +if [[ $STOPKHANAT -ne 0 ]] +then + msg_info "STOP SERVER KHANAT" + listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')" + msg_debug "CONTAINER KHANAT UP : ${listcontainer[@]}" + if [[ -n "$listcontainer" ]] + then + docker stop "$listcontainer" || exit 2 + fi +fi + +if [[ $CLEANCONTAINERKHANAT -ne 0 ]] +then + msg_info "CLEAN CONTAINER KHANAT" + listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') ) + msg_debug "CONTAINER KHANAT EXITED : ${listcontainer[@]}" + if [[ -n "${listcontainer[@]}" ]] + then + docker rm --force "${listcontainer[@]}" || exit 2 + fi +fi + +if [[ $CLEANIMAGENONE -ne 0 ]] +then + msg_info "CLEAN IMAGE DOCKER 'NONE'" + listimages=( $(docker images | awk '{if ($1=="")print $3}') ) + + msg_debug "IMAGES NONE : ${listimages[@]}" + if [[ -n "${listimages[@]}" ]] + then + docker rmi --force "${listimages[@]}" || exit 2 + fi +fi + +if [[ $BASICSERVER -ne 0 ]] +then + msg_info "GENERATE DOCKER IMAGE BASIC SERVER" + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEGENERICSERVER} \ + --file "${basedir}/Dockerfile" || exit 2 +fi + +if [[ $KHANATSERVER -ne 0 ]] +then + msg_info "GENERATE DOCKER IMAGE KHANAT SERVER" + cat << EOF > $rootdir/${ENVIFILE} +#!/bin/bash +# Temporary file, use only to send some information on build docker +export KHANAT_CLIENT_VERSION=$KHANAT_CLIENT_VERSION +export UIDGAMESERVER=$(id -u) +export GIDGAMESERVER=$(id -g) +export DIRCLIENT="$DIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +EOF + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \ + --file "${basedir}/Dockerfile.khanat.container" || exit 2 +fi + +if [[ $CONFIGUREKHANATSERVER -ne 0 ]] +then + msg_info "CONFIGURE KHANAT SERVER" + mkdir -p $DIRLOG || exit 2 + mkdir -p $DIRDATABASE || exit 2 + msg_debug "command : cd $rootdir; docker run -it --hostname=khanat \ + -v /etc/localtime:/etc/localtime:ro \ + -v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \ + -v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \ + -v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \ + -v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \ + -v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \ + -v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \ + -v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \ + -v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \ + -v ${rootdir}/server/debian/common/:/opt/ext:ro \ + ${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh" + cd $rootdir; docker run -it --hostname=khanat \ + -v /etc/localtime:/etc/localtime:ro \ + -v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \ + -v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \ + -v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \ + -v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \ + -v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \ + -v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \ + -v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \ + -v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \ + -v ${rootdir}/server/debian/common/:/opt/ext:ro \ + ${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh || exit 2 +fi + +if [[ $UPDATEDATA -ne 0 ]] +then + msg_info "UPDATE KHANAT SERVER" + msg_debug "command: cd $rootdir; docker run -it --hostname=khanat \ + -v /etc/localtime:/etc/localtime:ro \ + -v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \ + -v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \ + -v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \ + -v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \ + -v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \ + -v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \ + -v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \ + -v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \ + -v ${rootdir}/server/debian/common/:/opt/ext:ro \ + ${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh" + cd $rootdir; docker run -it --hostname=khanat \ + -v /etc/localtime:/etc/localtime:ro \ + -v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \ + -v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \ + -v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \ + -v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \ + -v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \ + -v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \ + -v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \ + -v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \ + -v ${rootdir}/server/debian/common/:/opt/ext:ro \ + ${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh +fi + +if [[ $LAUNCHKHANAT -ne 0 ]] +then + msg_info "START KHANAT SERVER" + cd $rootdir; docker run -it --hostname=khanat \ + -u "$(id -u $USERNAME):$(id -g $USERNAME)" \ + -v /etc/localtime:/etc/localtime:ro \ + -v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \ + -v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \ + -v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \ + -v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \ + -v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \ + -v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \ + -v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \ + -v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \ + -v ${rootdir}/server/debian/common/:/opt/ext:ro \ + ${IMAGEKHANATSERVER} /opt/ext/servercontainer_launch_auto.sh $METHODSTARTSERVER -d +fi + +trap '' EXIT +msg_info "END" diff --git a/server/debian/jessie/x86_64/server-image.sh b/server/debian/jessie/x86_64/server-image.sh new file mode 100755 index 0000000..66d031c --- /dev/null +++ b/server/debian/jessie/x86_64/server-image.sh @@ -0,0 +1,441 @@ +#!/bin/bash +# +# Script to start khanat server +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +declare -i IMAGE=1 +declare -i BASICSERVER=0 +declare -i KHANATSERVER=0 +declare -i KHANATRESSOURCES=0 +declare -i KHANATDATACLIENT=0 +declare -i RYZOMRESSOURCES=0 +declare -i LAUNCHKHANAT=1 +declare -i DEBUG=0 +declare -i AUTODETEC=1 +declare -i STOPKHANAT=0 +declare -i CLEANCONTAINERKHANAT=0 +declare -i CONNECTSSHKHANAT=0 +declare -i KHANAT_CLIENT_VERSION=1 +declare -i SHOWIPKHANATSERVER=0 +declare -i METHODSTARTSERVER=1 +declare -i CLEANIMAGENONE=0 +declare DOCKERBUILDOPT="" + +declare IMAGEGENERICSERVER="server_generic_debian_jessie_x86_64" +declare IMAGEKHANATSERVER="serverimage_khanat_debian_jessie_x86_64" +declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_x86_64" +declare DIRCLIENT="Khanat_Linux64" +declare PACKAGECLIENT="smokey_linux64" +declare DIROUTPUT="output/extra" + +usage() +{ +cat << EOF +usage:$0 [options] + script to build under docker + + Step: + 1) generate tar with khanat-ressources + 2) generate tar with ryzom-ressources + 3) create image basic server + 4) create image khanat server + 5) launch khanat server + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -b, --force-basic : Force create/recreate image basic server + -t, --force-tar-ressources : Generate TAR.GZ for khanat-ressources (look directory ../khanat-ressources) + -q, --force-tar-client-data : Generate TAR.GZ for khanat-client-data (look directory ../khanat-client-data) + -z, --force-tar-ryzom-ressources : Generate TAR.GZ in data khanat-code + -k, --force-khanat : Force create/recreate image khanat server + -n, --no-launch-khanat : Doesn't launch khanat server + -s, --stop-server : Stop server khanat + -c, --clean-container-khanat : Remove old server khanat (stopped) + -w, --clean-images-none : Remove images docker (with name 'none') + -i, --show-ip-khanat-server : show ip address for khanat server (launch under docker) + --option-docker-build=[STRING] : you can add option in "docker build" + --opennel-code-dir=[DIR] : localization opennel-code + --start-khanat-with-screen : [default] start khanat with screen + --start-khanat-with-full-log : start server khanat and show full log + --start-khanat-with-watch-state : start server khanat and show state (loop) + --ssh : connect on khanat server (with ssh) [Exclusive action, can't execute other action] + --client-version=[INTEGER] : version client khanat (we need to communicate with our server) + +Example : + cd [root Khanat directory] + ./server.sh + ./server.sh -k + ./server.sh --ssh +EOF +} + +function msg_debug() +{ + if [[ $DEBUG -ne 0 ]] + then + echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" + fi +} + +function msg_info() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" +} + +function msg_error() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2 +} + +# +# MAIN +# + +#msg_info "START" + +calldir="$(dirname $0)" +basedir=$(cd $calldir; pwd) +rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))" +ressourcedir="$(dirname ${rootdir})/khanat-ressources" +dataclientdir="$(dirname ${rootdir})/khanat-client-data" + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + --ssh) + CONNECTSSHKHANAT=1 + shift + ;; + -c|--clean-container-khanat) + CLEANCONTAINERKHANAT=1 + shift + ;; + -s|--stop-server) + STOPKHANAT=1 + shift + ;; + -b|--force-basic) + BASICSERVER=1 + shift + ;; + -n|--no-launch-khanat) + LAUNCHKHANAT=0 + shift + ;; + -t|--force-tar-ressources) + KHANATRESSOURCES=1 + shift + ;; + -q|--force-tar-client-data) + KHANATDATACLIENT=1 + shift + ;; + -z|--force-tar-ryzom-ressources) + RYZOMRESSOURCES=1 + shift + ;; + -k|--force-khanat) + KHANATSERVER=1 + shift + ;; + -i|--show-ip-khanat-server) + SHOWIPKHANATSERVER=1 + shift + ;; + --start-khanat-with-screen) + METHODSTARTSERVER=1 + shift + ;; + --start-khanat-with-full-log) + METHODSTARTSERVER=2 + shift + ;; + --start-khanat-with-watch-state) + METHODSTARTSERVER=3 + shift + ;; + --client-version*) + KHANAT_CLIENT_VERSION="${1#*=}" + shift + ;; + -w|--clean-images-none) + CLEANIMAGENONE=1 + shift + ;; + --option-docker-build) + DOCKERBUILDOPT="$DOCKERBUILDOPT ${1#*=}" + shift + ;; + --opennel-code-dir=*) + OPENNEL_CODE_DIR="${1#*=}" + shift + ;; + *) + msg_error "options '$1' not recognize" + usage + exit 1 + ;; + esac +done + +function chrashed() +{ + msg_error "BUILD FAILED (code:$?)" + exit 2 +} + +trap chrashed EXIT + +if [[ $SHOWIPKHANATSERVER -eq 0 ]] +then + msg_info "START" +fi + +msg_debug "prg: $0" + +extradir="${rootdir}/${DIROUTPUT}" +mkdir -p ${extradir} || exit 2 + + +docker -v 1>/dev/null +if [[ $? -ne 0 ]] +then + msg_error "docker not installed" + exit 2 +fi + +case "$(uname -m)" in + x86_64) + ;; + i686) + ;; + *) + msg_error "Unknown archi : $(uname -m)" + exit 2 + ;; +esac + +if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]] +then + listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')" + if [[ ${#listcontainer[@]} -eq 1 ]] + then + ipaddress=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" ${listcontainer[@]}) + fi +fi + +if [[ $SHOWIPKHANATSERVER -ne 0 ]] +then + trap '' EXIT + echo "$ipaddress" + exit 0 +fi + +if [[ $CONNECTSSHKHANAT -ne 0 ]] +then + ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no gameserver@$ipaddress + trap '' EXIT + msg_info "END SSH" + exit 0 +fi + +if [[ $AUTODETEC -ne 0 ]] +then + if [[ $(docker images -f "reference=$IMAGEGENERICSERVER" | wc -l) -lt 2 ]] + then + BASICSERVER=1 + fi + if [[ ! -f ${extradir}/khanat-ressources.tar.gz ]] + then + KHANATRESSOURCES=1 + fi + if [[ ! -f ${extradir}/khanat-client-data.tar.gz ]] + then + KHANATDATACLIENT=1 + fi + if [[ ! -f ${extradir}/ryzom-ressources.tar.gz ]] + then + RYZOMRESSOURCES=1 + fi + if [[ $(docker images -f "reference=$IMAGEKHANATSERVER" | wc -l) -lt 2 ]] + then + KHANATSERVER=1 + fi + if [[ -z "$OPENNEL_CODE_DIR" ]] + then + OPENNEL_CODE_DIR="$(dirname $rootdir)/khanat-opennel-code" + fi + + if [[ -f ${extradir}/ryzomcore.tar.gz ]] + then + sumsrc=$(md5sum ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz | awk '{print $1}') + sumdst=$(md5sum ${extradir}/ryzomcore.tar.gz | awk '{print $1}') + else + sumsrc=1 + sumdsr=2 + fi + msg_debug "ryzomcore checksum src:$sumsrc dst:$sumdst" + if [[ "$sumsrc" != "$sumdst" ]] + then + msg_debug "copy ryzomcore" + cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${extradir}/ryzomcore.tar.gz || exit 2 + KHANATSERVER=1 + fi +fi + +DIRBUILD="${rootdir}/${LOCALBUILDDIR}" + +msg_debug "calldir: $calldir" +msg_debug "basedir: $basedir" +msg_debug "rootdir: $rootdir" +msg_debug "ressourcedir: $ressourcedir" +msg_debug "generate basic image: $BASICSERVER" +msg_debug "generate tar khanat ressources: $KHANATRESSOURCES" +msg_debug "generate tar khanat data client: $KHANATDATACLIENT" +msg_debug "generate tar ryzom ressources: $RYZOMRESSOURCES" +msg_debug "generate khanat image: $KHANATSERVER" +msg_debug "launch khanat: $LAUNCHKHANAT" +msg_debug "stop khanat: $STOPKHANAT" + +if [[ ! -d ${OPENNEL_CODE_DIR} ]] +then + msg_error "Missing directory opennel-code [${OPENNEL_CODE_DIR}]" + cat << EOF +You need clone repo khanat-opennel-code. + +cd $(dirname ${KHANAT_RESSOURCES_DIR}) +git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git + +EOF + exit 2 +fi + +if [[ $KHANATRESSOURCES -ne 0 ]] +then + msg_info "CREATE TAR with KHANAT Ressources" + if [[ ! -d ${ressourcedir} ]] + then + msg_error "Missing khanat-ressources directory ($ressourcedir)" + exit 2 + fi + (cd $ressourcedir; tar --exclude='.git' -czf ${extradir}/khanat-ressources.tar.gz .) || exit 2 +fi + +if [[ $KHANATDATACLIENT -ne 0 ]] +then + msg_info "CREATE TAR with KHANAT DATA CLIENT" + if [[ ! -d ${dataclientdir} ]] + then + msg_error "Missing khanat-client-data directory ($dataclientdir)" + exit 2 + fi + (cd $dataclientdir; tar --exclude='.git' -czf ${extradir}/khanat-client-data.tar.gz .) || exit 2 +fi + +if [[ $RYZOMRESSOURCES -ne 0 ]] +then + msg_info "CREATE TAR with RYZOM Ressources" + if [[ ! -d ${ressourcedir} ]] + then + msg_error "Missing khanat-ressources directory ($ressourcedir)" + exit 2 + fi + cd ${OPENNEL_CODE_DIR}; tar czf ${extradir}/ryzom-ressources.tar.gz \ + code/ryzom/server/shard.screen.rc \ + code/ryzom/common/* \ + code/ryzom/client/* \ + code/ryzom/server/* \ + code/ryzom/tools/scripts/linux/* \ + code/web/* || exit 2 +fi + +if [[ $STOPKHANAT -ne 0 ]] +then + msg_info "STOP SERVER KHANAT" + listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')" + msg_debug "CONTAINER KHANAT UP : ${listcontainer[@]}" + if [[ -n "$listcontainer" ]] + then + docker stop "$listcontainer" || exit 2 + fi +fi + +if [[ $CLEANCONTAINERKHANAT -ne 0 ]] +then + msg_info "CLEAN CONTAINER KHANAT" + listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') ) + msg_debug "CONTAINER KHANAT EXITED : ${listcontainer[@]}" + if [[ -n "${listcontainer[@]}" ]] + then + docker rm --force "${listcontainer[@]}" || exit 2 + fi +fi + +if [[ $CLEANIMAGENONE -ne 0 ]] +then + msg_info "CLEAN IMAGE DOCKER 'NONE'" + listimages=( $(docker images | awk '{if ($1=="")print $3}') ) + + msg_debug "IMAGES NONE : ${listimages[@]}" + if [[ -n "${listimages[@]}" ]] + then + docker rmi --force "${listimages[@]}" || exit 2 + fi +fi + +if [[ $BASICSERVER -ne 0 ]] +then + msg_info "GENERATE DOCKER IMAGE BASIC SERVER" + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEGENERICSERVER} \ + --file "${basedir}/Dockerfile" || exit 2 +fi + +if [[ $KHANATSERVER -ne 0 ]] +then + msg_info "GENERATE DOCKER IMAGE KHANAT SERVER" + cat << EOF > $rootdir/todelete.sh +#!/bin/bash +# Temporary file, use only to send some information on build docker +export KHANAT_CLIENT_VERSION=$KHANAT_CLIENT_VERSION +export DIRCLIENT="$DIRCLIENT" +export PACKAGECLIENT="$PACKAGECLIENT" +EOF + cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \ + --file "${basedir}/Dockerfile.khanat.image" || exit 2 + rm $rootdir/todelete.sh +fi + +if [[ $LAUNCHKHANAT -ne 0 ]] +then + msg_info "START KHANAT SERVER" + cd $rootdir; docker run -it --hostname=khanat \ + -v /etc/localtime:/etc/localtime:ro \ + ${IMAGEKHANATSERVER} /opt/serverimage_autostart.sh $METHODSTARTSERVER + clear +fi + +trap '' EXIT +msg_info "END"