Oracle Instant Client

This commit is contained in:
AcuGIS 2024-01-29 19:03:18 +02:00
parent b3a46ba6b5
commit 538e0e2356
47 changed files with 1688 additions and 1 deletions

161
.gitignore vendored Normal file
View File

@ -0,0 +1,161 @@
# ignore autogenerated .rst files in docs directory
docs/source/**/*.rst
# custom, package specific ignores
.DS_Store
.DS_Store?
pymakr.conf
tests/
config/config*.py
thinking/
*.bin
.idea
*.bak
*.o
.vagrant/
# meson files under development
untitled.meson.build
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
# micropython libs are stored in lib/
# lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
*.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/

20
.readthedocs.yaml Normal file
View File

@ -0,0 +1,20 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.9"
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt

View File

@ -1,2 +1,81 @@
# Oracle-Instant-Client
# Oracle Instant Client
## Webmin Module for installing Oracle Instant Client
![Oracle Instant Client](docs/_static/oracle-instant-client.png)
# About
Installs Oracle Instant Client Basic, jdbc, odbc, sdk, sqlplus, and tools packages
# Supported Operating Systems
Ubuntu 22
Rocky Linux 9
Alma Linux 9
# Install via Webmin
Webmin->Webmin Configuration->Webmin Modules->From ftp or http URL
URL: http://github.com/cited/Oracle-Instant-Client/raw/master/scripts/Oracle-Instant-Client.wbm.gz
Go to Servers->Apache Tomcat to complete set up using the setup Wizard (you may need to refresh page).
# Install via Script
Ubuntu (as root):
```bash
wget https://raw.githubusercontent.com/cited/Oracle-Instant-Client/master/scripts/ubuntu.sh
chmod +x pre-install.sh
./pre-install.sh
```
Rocky Linux or Alma Linux (as root):
```bash
wget https://raw.githubusercontent.com/cited/Oracle-Instant-Client/master/scripts/alma-rocky.sh
chmod +x pre-install.sh
./pre-install.sh
```
Go to Servers->Apache Tomcat to complete set up using the setup Wizard.
# Install via GIT
As Root:
```bash
git clone https://github.com/cited/Oracle-Instant-Client
mv Oracle-Instant-Client oci
tar -cvzf oci.wbm.gz oci/
```
Upload from Webmin->Webmin Configuration->Webmin Modules
Go to Servers->Oracle Instant Client (you may need to refresh page)
## **Issues**
Please report issue here
# Screen Shots
![Oracle Instant Client](docs/_static/6.png)
# SQLPlus Connection via Webmin Terminal
![Oracle Instant Client](docs/_static/9.png)
Copyright
---------
* Copyright AcuGIS, 2023
* Copyright Cited, Inc., 2023

81
changelog.md Normal file
View File

@ -0,0 +1,81 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
<!--
## [x.y.z] - yyyy-mm-dd
### Added
### Changed
### Removed
### Fixed
-->
<!--
RegEx for release version from file
r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
-->
## Released
## [0.5.0] - 2022-12-17
### Added
- Example for ReStructuredText evaluation directive to show a warning and a notes highlighted text
### Changed
- Removed outdated command to convert Markdown files to ReStructuredText files
### Fixed
- Call to generate sphinx documentation in USAGE
## [0.4.0] - 2022-12-06
### Added
- Usage guide for building docs locally in root README
- `changelog_link.rst` added to [docs](docs) to include this changelog from
its real location without further relocation before building the docs
### Changed
- Relocate files of `docs/source` into `docs` directly
- Replace ReStructuredText references in Markdown files of [docs](docs)
- `docutils >=0.14,<0.18` is required to build the docs
- Sphinx extensions sorted aphabetically in [`config.py`](docs/config.py)
### Removed
- Documentation build process is no longer depending in `m2rr` package
- Unused batch file and Makefile
## [0.3.0] - 2022-10-29
### Added
- Add link to created documentation to root README
### Fixed
- Subtitle of root README does not reference MicroPython
## [0.2.0] - 2022-10-29
### Added
- Docs badge to root README, see [#2][ref-issue-2]
### Changed
- Converted root README from Markdown to ReStructuredText
## [0.1.0] - 2022-10-29
### Added
- This changelog file
- [.gitignore](.gitignore) file
- Docs [requirements.txt](docs/requirements.txt) file to setup tools for
documentation generation
- [.readthedocs.yaml](.readthedocs.yaml) file to define custom actions after
the default installation and before the actual docs build process
- [Dummy python package files](my_package/)
- [Script to convert](docs/convert_md2rst.py) Markdown to ReStructuredText
files for Sphinx
<!-- Links -->
[Unreleased]: https://github.com/brainelectronics/rtd-tutorial-template/compare/0.5.0...main
[0.5.0]: https://github.com/brainelectronics/rtd-tutorial-template/tree/0.5.0
[0.4.0]: https://github.com/brainelectronics/rtd-tutorial-template/tree/0.4.0
[0.3.0]: https://github.com/brainelectronics/rtd-tutorial-template/tree/0.3.0
[0.2.0]: https://github.com/brainelectronics/rtd-tutorial-template/tree/0.2.0
[0.1.0]: https://github.com/brainelectronics/rtd-tutorial-template/tree/0.1.0
[ref-issue-2]: https://github.com/brainelectronics/rtd-tutorial-template/issues/2

1
config Normal file
View File

@ -0,0 +1 @@
oci_config=/etc/webmin/oci/config

1
config.info Normal file
View File

@ -0,0 +1 @@
oci_config=Path to the Oracle Instant Client Webmin module config file,8

18
docs/README.md Normal file
View File

@ -0,0 +1,18 @@
## Installation
The preferred method is installing via GIT.
Install the package with GIT::
$ git clone https://github.com/cited/Tomcat-Webmin-Module
$ mv Tomcat-Webmin-Module tomcat
$ tar -cvzf tomcat.wbm.gz tomcat/
Upload from Webmin->Webmin Configuration->Webmin Modules
Go to Servers->Apache Tomcat (you may need to refresh page)

73
docs/USAGE.md Normal file
View File

@ -0,0 +1,73 @@
# Usage
## Package
To use the very useless python classes of this example import the
```python
from my_package.asdf import ASDF
asdf = ASDF()
# ASDF init done
asdf.print_hello(who='Carl')
# Hello Carl
```
To get a list of random integers the
[**`my_package.qwertz.QWERTZ.get_list_of_int`**](my_package.qwertz.QWERTZ.get_list_of_int)
function can be used. The list will contain 5 integers between 0 and 100 by
default. The `how_long` argument can be used to change the number of elements
in the returned list.
```{note} Notes require **no** arguments, so content can start here.
```
```{eval-rst}
.. warning::
This is warning text. Use a warning for information the user must
understand to avoid negative consequences.
Warnings are formatted in the same way as notes. In the same way,
lines must be broken and indented under the warning tag.
```
## Create docs
### Installation
Python3 must be installed on your system. Check the current Python version
with the following command
```bash
python --version
python3 --version
```
Depending on which command `Python 3.x.y` (with x.y as some numbers) is
returned, use that command to proceed.
```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r docs/requirements.txt
```
### Sphinx link checks
```bash
sphinx-build \
docs/ docs/build/linkcheck \
-d docs/build/docs_doctree \
--color -blinkcheck -W
```
### Sphinx build
```bash
sphinx-build \
docs/ docs/build/html \
-d docs/build/docs_doctree \
--color -bhtml -W
```

BIN
docs/_static/1.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
docs/_static/10.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
docs/_static/11.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
docs/_static/6.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
docs/_static/7.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
docs/_static/8.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
docs/_static/9.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
docs/_static/Setup-2.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

1
docs/_static/index.rst vendored Normal file
View File

@ -0,0 +1 @@
OCI Images

BIN
docs/_static/oci-tab-main.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
docs/_static/oci-tab.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
docs/_static/oracle-instant-client.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
docs/_static/php-1.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
docs/_static/php-2.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

BIN
docs/_static/wizard.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

3
docs/changelog_link.rst Normal file
View File

@ -0,0 +1,3 @@
.. include:: ../changelog.md
:parser: myst_parser.sphinx_

31
docs/components.rst Normal file
View File

@ -0,0 +1,31 @@
Dashboard
===========================
The dashboard contains links to Oracle Instant Client installer and PHP installer.
PHP
---------------------
Click the PHP tab:
.. image:: _static/php-1.png
Here, you can add/remove/update any listed PHP packages
.. image:: _static/php-2.png
php-2.png
Instant Client
---------------------
Click the Oracle Instant Client tab:
.. image:: _static/oci-tab.png
Here, you can add/remove/update any listed Oracle Instant Client packages
.. image:: _static/oci-tab-main.png

68
docs/conf.py Normal file
View File

@ -0,0 +1,68 @@
# Configuration file for the Sphinx documentation builder.
import os
import sys
from pathlib import Path
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
sys.path.insert(0, os.path.abspath('../'))
here = Path(__file__).parent.resolve()
# -- Project information
project = 'Oracle Instant Client'
copyright = '2023, Cited Inc.'
author = 'Cited'
release = '0.1'
version = '0.1.0'
# -- General configuration
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
# 'myst_parser',
'sphinx.ext.autodoc',
'sphinx.ext.autosectionlabel',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.duration',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
]
autosectionlabel_prefix_document = True
# The suffix of source filenames.
source_suffix = ['.rst', '.md']
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
}
intersphinx_disabled_domains = ['std']
suppress_warnings = [
# throws an error due to not found reference targets to files not in docs/
'ref.myst',
# throws an error due to multiple "Added" labels in "changelog.md"
'autosectionlabel.*'
]
templates_path = ['_templates']
# -- Options for HTML output
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
# -- Options for EPUB output
epub_show_urls = 'footnote'

15
docs/index.rst Normal file
View File

@ -0,0 +1,15 @@
Oracle Instant Client
===================================
.. image:: _static/7.png
Contents
--------
.. toctree::
:maxdepth: 1
install
components

100
docs/install.rst Normal file
View File

@ -0,0 +1,100 @@
Installation
===========================
This module is for installing and configuring Oracle Instant Client
The module can be used on a new or existing Webmin installation
Installation
------------
Step 1: Get the repo from Github::
git clone https://github.com/cited/Oracle-Instant-Client.git
Step 2: Change name::
mv Oracle-Instant-Client oci
Step 4 Create the Webmin wbm.gz file::
tar -cvzf oci.wbm.gz oci/
Step 5: Install the module (Ubuntu)::
/usr/share/webmin/install-module.pl oci.wbm.gz
Step 5: Install the module (Rocky/Alma)::
/usr/libexec/webmin/install-module.pl oci.wbm.gz
Wizard
-------
Once the module is installed, go to Servers >> Oracle Instant Client
.. image:: _static/1.png
Click throught the Set Up Wizard
.. image:: _static/Setup-2.png
Select the package(s) you want to install
.. image:: _static/6.png
Once completed, the panel should look like below:
.. image:: _static/7.png
SQL Plus
-----------------
If you selected SQLPlus, you can test functionality via the Webmin terminal app:
.. image:: _static/8.png
Start SQL Plus
.. image:: _static/9.png
PHP OCI
-----------------
PHP oci funcationality can be tested using below
.. code-block:: console
<?php
$c = @oci_connect("username", "password", "hostname/servicename(pdb)");
if (!$c) {
print "Sorry! The connection to the database failed. Please try again later.";
die();
}
else {
print "Congrats! You've connected to an Oracle database!";
oci_close($c);
}
?>
Contribute
----------
- Issue Tracker: github.com/cited/Oracle-Instant-Client/issues
- Source Code: github.com/AcuGIS/Oracle-Instant-Client
Support
-------
If you are having issues, please let us know.
We have a mailing list located at: project@google-groups.com
License
-------
The project is licensed under the BSD license.

13
docs/requirements.txt Normal file
View File

@ -0,0 +1,13 @@
# use fixed versions
#
# fix docutils to a version working for all
docutils >=0.14,<0.18
# sphinx 5.3.0 requires Jinja2 >=3.0 and docutils >=0.14,<0.20
sphinx >=5.0.0,<6
# sphinx-rtd-theme >=1.0.0 would require docutils <0.18
sphinx-rtd-theme >=1.0.0,<2
# replaces outdated and no longer maintained m2rr
# myst-parser >= 0.18.1,<1

29
edit_oci.cgi Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/perl
require './oci-lib.pl';
&ReadParse();
&ui_print_header(undef, $text{'oci_title'}, "");
my @oci_vers = get_oci_versions();
my $page_number = pop @oci_vers;
my %pkgs = ('basic'=>1, 'jdbc'=>1, 'sqlplus'=>0, 'sdk'=>1, 'odbc'=>1, 'tools'=>0);
print &ui_form_start("install_oci.cgi", "form-data");
print &ui_hidden('page_number', $page_number);
print &ui_table_start($text{'oci_install'}, undef, 2);
print &ui_table_row($text{'oci_version'}, &ui_select("oci_ver", undef, \@oci_vers, 1, 0));
my $pkg_checks='';
foreach my $name (sort keys %pkgs){
$pkg_checks .= &ui_checkbox('pkg_'.$name, 1, $name, $pkgs{$name});
}
print &ui_table_row($text{'oci_packages'}, $pkg_checks, 2);
print &ui_table_end();
print &ui_form_end([ [ "", $text{'install_button'} ] ]);
&ui_print_footer("", $text{'index_return'});

8
help/intro.html Normal file
View File

@ -0,0 +1,8 @@
<header>Oracle Client</header>
<p>Free, light-weight and easily installed Oracle Database tools, libraries and SDKs for building and connecting client applications to local or remote Oracle Databases</p>
<p>Oracle Instant Client enables development and production deployment of Oracle Database applications. It is used for popular languages and environments including Node.js, Python and PHP, as well as providing access for OCI, OCCI, JDBC-OCI, ODBC and Pro*C applications.
ISVs and Partners can benefit greatly from being able to bundle Instant Client in their applications.</p>
<hr>

BIN
images/java.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
images/manual.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
images/oci.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
images/pg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
images/php.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

6
images/php.svg Normal file
View File

@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="95.776" height="48.124">
<view viewBox="24 12 196 96"/>
<path d="m7.579 10.123 14.204 0c4.169 0.035 7.19 1.237 9.063 3.604 1.873 2.367 2.491 5.6 1.855 9.699-0.247 1.873-0.795 3.71-1.643 5.512-0.813 1.802-1.943 3.427-3.392 4.876-1.767 1.837-3.657 3.003-5.671 3.498-2.014 0.495-4.099 0.742-6.254 0.742l-6.36 0-2.014 10.07-7.367 0 7.579-38.001 0 0m6.201 6.042-3.18 15.9c0.212 0.035 0.424 0.053 0.636 0.053 0.247 0 0.495 0 0.742 0 3.392 0.035 6.219-0.3 8.48-1.007 2.261-0.742 3.781-3.321 4.558-7.738 0.636-3.71 0-5.848-1.908-6.413-1.873-0.565-4.222-0.83-7.049-0.795-0.424 0.035-0.83 0.053-1.219 0.053-0.353 0-0.724 0-1.113 0l0.053-0.053"/>
<path d="m41.093 0 7.314 0-2.067 10.123 6.572 0c3.604 0.071 6.289 0.813 8.056 2.226 1.802 1.413 2.332 4.099 1.59 8.056l-3.551 17.649-7.42 0 3.392-16.854c0.353-1.767 0.247-3.021-0.318-3.763-0.565-0.742-1.784-1.113-3.657-1.113l-5.883-0.053-4.346 21.783-7.314 0 7.632-38.054 0 0"/>
<path d="m70.412 10.123 14.204 0c4.169 0.035 7.19 1.237 9.063 3.604 1.873 2.367 2.491 5.6 1.855 9.699-0.247 1.873-0.795 3.71-1.643 5.512-0.813 1.802-1.943 3.427-3.392 4.876-1.767 1.837-3.657 3.003-5.671 3.498-2.014 0.495-4.099 0.742-6.254 0.742l-6.36 0-2.014 10.07-7.367 0 7.579-38.001 0 0m6.201 6.042-3.18 15.9c0.212 0.035 0.424 0.053 0.636 0.053 0.247 0 0.495 0 0.742 0 3.392 0.035 6.219-0.3 8.48-1.007 2.261-0.742 3.781-3.321 4.558-7.738 0.636-3.71 0-5.848-1.908-6.413-1.873-0.565-4.222-0.83-7.049-0.795-0.424 0.035-0.83 0.053-1.219 0.053-0.353 0-0.724 0-1.113 0l0.053-0.053"/>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

36
index.cgi Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/perl
require './oci-lib.pl';
require '../webmin/webmin-lib.pl'; #for OS detection
# Check if config file exists
if (! -r $config{'oci_config'}) {
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
print &text('index_econfig', "<tt>$config{'oci_config'}</tt>",
"$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
&ui_print_footer("/", $text{"index"});
exit;
}
if(-f "$module_root_directory/setup.cgi"){
&redirect("setup.cgi?mode=checks");
exit;
}
my %version = get_versions();
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
&help_search_link("oracle", "oci", "php", "google"), undef, undef,
"InstantClient $version{'oci'} / PHP $version{'php'}");
push(@links, "php_install.cgi");
push(@titles, $text{'php_title'});
push(@icons, "images/php.png");
push(@links, "edit_oci.cgi");
push(@titles, $text{'oci_title'});
push(@icons, "images/oci.png");
&icons_table(\@links, \@titles, \@icons, 3);
&ui_print_footer("/", $text{"index"});

254
install_oci.cgi Normal file
View File

@ -0,0 +1,254 @@
#!/usr/bin/perl
require './oci-lib.pl';
sub download_otn{
my $ver = $_[0];
my $ver2;
my $name = $_[1];
my $page_number = $_[2];
($ver2 = $ver) =~ s/\.//g;
my $time_limit = time().100;
print "<hr>Downloading $name-$ver ...<br>";
my $url = "http://download.oracle.com/otn_software/linux/instantclient/$ver2/instantclient-$name-linux.x64-".$ver."dbru.zip";
my $tmpfile = &transname("instantclient-$name-linux.x64-$ver.zip");
#my $tmpfile = "/tmp/instantclient-$name-linux.x64-$ver.zip";
&error_setup(&text('install_err3', $url));
&http_download("download.oracle.com", 443, "/otn_software/linux/instantclient/$ver2/instantclient-$name-linux.x64-".$ver."dbru.zip",
$tmpfile, \$error, undef, 1);#, undef, undef, 0, 0, 1, \%cookie_headers);
return $tmpfile;
}
sub download_cdn{
my $ver = $_[0];
my $name = $_[1];
my $cdn_host = '10.0.3.1';
my $cdn_folder = '/12.1.0.2.0';
print "<hr>Downloading $name-$ver ...<br>";
my $url = "http://$cdn_host"."$cdn_folder/instantclient-$name-linux.x64-$ver.zip";
my $tmpfile = &transname("instantclient-$name-linux.x64-$ver.zip");
&error_setup(&text('install_err3', $url));
&http_download($cdn_host, 80,"$cdn_folder/instantclient-$name-linux.x64-$ver.zip", $tmpfile);
return $tmpfile;
}
sub install_oci8{
my $oracle_home = $_[0];
my $instantclient_home = $_[1];
my $oci_ver;
my %versions = get_versions();
my @php_ver = split(/\./, $versions{'php'});
if(($php_ver[0] == 8) and ($php_ver[1] == 2)){
$oci_ver = '3.3.0';
}elsif(($php_ver[0] == 8) and ($php_ver[1] == 1)){
$oci_ver = '3.2.1';
}elsif(($php_ver[0] == 8) and ($php_ver[1] == 0)){
$oci_ver = '3.0.1';
}elsif($php_ver[0] == 7){
$oci_ver = '2.1.4';
}elsif($php_ver[0] == 5){
$oci_ver = '2.0.10';
}elsif($php_ver[0] == 4){
$oci_ver = '1.4.10';
}else{
&error("Error: oci8: Unsupported PHP version $versions{'php'}<br>");
}
my $oci8_home = "$oracle_home/src/oci8-$oci_ver";
&make_dir($oracle_home.'/src', 0754, 1);
#pecl download oci8
my $url = "https://pecl.php.net/get/oci8-$oci_ver.tgz";
my $tmpfile = &transname("oci8-$oci_ver.tgz");
&error_setup(&text('install_err3', $url));
&http_download("pecl.php.net", 443,"/get/oci8-$oci_ver.tgz", $tmpfile, \$error, undef, 1);
my $cmd_out='';
my $cmd_err='';
print "<hr>Extracting $tmpfile to $oracle_home/src...<br>";
local $out = &execute_command("tar -x --overwrite -f \"$tmpfile\" -C$oracle_home/src", undef, \$cmd_out, \$cmd_err, 0, 0);
if($cmd_err){
&error("Error: tar: $cmd_err");
}else{
$cmd_out =~ s/\r\n/<br>/g;
print &html_escape($cmd_out);
}
#compile OCI 8 module
my $orig_cwd = cwd;
chdir $oci8_home;
my @cmds = ('phpize',
"./configure --with-oci8=share,instantclient,$oracle_home/instantclient/",
"make && make install");
foreach my $cmd (@cmds){
my $cmd_out='';
my $cmd_err='';
local $out = &execute_command($cmd, undef, \$cmd_out, \$cmd_err, 0, 0);
if($out != 0){
&error($cmd_err);
}
}
copy_source_dest("$oci8_home/modules/oci8.so", "$oracle_home/instantclient/oci8.so");
chdir $orig_cwd;
#Add PHP config for CLI and CGI
print "Setting PHP ini files for CLI and CGI<br>";
my $cgi_file = &transname('info.php');
open(my $fh, '>', $cgi_file) or die "open:$!";
print $fh "<?php phpinfo(); ?>";
close $fh;
my %php_cmds = ('php --ini' =>"^Scan for additional .ini files in: (.*)",
"REDIRECT_STATUS=200 REQUEST_METHOD=GET SCRIPT_FILENAME=$cgi_file SCRIPT_NAME=/info.php PATH_INFO=/ SERVER_NAME=site.tld SERVER_PROTOCOL=HTTP/1.1 REQUEST_URI=/nl/page HTTP_HOST=site.tld /usr/bin/php-cgi"=>"Scan this dir for additional \.ini files <\/td><td class=\"v\">([a-z0-9\/_\.-]+)");
my %ext_file = ('extension'=>'oci8.so');
$SIG{'TERM'} = 'ignore';
foreach my $cmd (keys %php_cmds){
&open_execute_command(CMD, $cmd, 1);
my $pattern = $php_cmds{$cmd};
my $php_confd = '';
while(my $line = <CMD>) {
if($line =~ /$pattern/){
$php_confd = $1;
last;
}
}
close(CMD);
if(-d $php_confd){
write_file($php_confd.'/90-oci.ini', \%ext_file);
}else{
print "Warning: Failed to add OCI extension to $cmd ini files.<br>";
}
}
}
sub setup_instant_libs{
my $instantclient_home = $_[0];
print "<hr>Setting Oracle Instant Client libs in /etc/ld.so.conf.d/instantclient.conf<br>";
opendir(DIR, $instantclient_home) or die $!;
my @libs
= grep {
/\.so([0-9\.]+)?$/ # Has .so* extension
&& -f "$instantclient_home/$_" # and is a file
} readdir(DIR);
closedir(DIR);
&make_dir($instantclient_home.'/lib', 0755, 1);
for my $lib (@libs){
symlink_file($instantclient_home.'/'.$lib,
$instantclient_home."/lib/$lib");
}
open(my $fh, '>', '/etc/ld.so.conf.d/instantclient.conf') or die "open:$!";
print $fh '/opt/oracle/instantclient/lib';
close $fh;
#echo '/usr/lib/grass64/lib/' > /etc/ld.so.conf.d/grass.conf
#echo '/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/' > /etc/ld.so.conf.d/jvm.conf
my $cmd_out='';
my $cmd_err='';
local $out = &execute_command('ldconfig', undef, \$cmd_out, \$cmd_err, 0, 0);
if($out != 0){
&error($cmd_err);
}
}
sub setup_instant_env{
my $instantclient_home = $_[0];
my $instantclient_ver = $_[1];
my %os_env;
$os_env{'INSTANTCLIENT_VERSION'} = $instantclient_ver;
$os_env{'INSTANTCLIENT_HOME'} = $instantclient_home;
$os_env{'ORACLE_HOME'} = $instantclient_home;
print "<hr>Setting Oracle Instant Client environment...";
if(-d '/etc/profile.d/'){
$os_env{'PATH'} = "\$PATH:$instantclient_home";
write_env_file('/etc/profile.d/instantclient.sh', \%os_env, 1);
}else{
read_env_file('/etc/environment', \%os_env);
$os_env{'PATH'} = "$os_env{'PATH'}:$instantclient_home";
write_env_file('/etc/environment', \%os_env, 0);
}
}
$| = 1;
if ($ENV{REQUEST_METHOD} eq "POST") {
&ReadParseMime();
}else {
&ReadParse();
$no_upload = 1;
}
&ui_print_header(undef, $text{'install_title'}, "");
my $oci_ver = $in{'oci_ver'};
my $page_number = $in{'page_number'};
my @pkgs = ('basic', 'jdbc', 'sqlplus', 'sdk', 'odbc', 'tools');
my $oracle_home = "/opt/oracle";
&make_dir($oracle_home, 0755, 1);
if(-d $oracle_home.'/instantclient_'.$oci_ver){
print "Error: Oracle Instant Client $oci_ver is already installed!<br>";
&ui_print_footer("", $text{'index_return'});
exit;
}
#download and unzip selected packages
foreach my $pkg_name (@pkgs){
if($in{'pkg_'.$pkg_name} == 1){
my $zip_file = download_otn($oci_ver, $pkg_name, $page_number);
unzip_file($zip_file, $oracle_home);
}
}
my @oci_ver_digits = split(/\./, $oci_ver);
&rename_file($oracle_home.'/instantclient_'.$oci_ver_digits[0].'_'.$oci_ver_digits[1],
$oracle_home.'/instantclient_'.$oci_ver);
my $instantclient_home = $oracle_home.'/instantclient_'.$oci_ver;
symlink_file($instantclient_home, $oracle_home.'/instantclient');
#link clntsh and occi libs
symlink_file($instantclient_home.'/libclntsh.so.'.$oci_ver_digits[0].'.'.$oci_ver_digits[1],
$oracle_home.'/instantclient/libclntsh.so');
symlink_file($instantclient_home.'/libocci.so.'.$oci_ver_digits[0].'.'.$oci_ver_digits[1],
$oracle_home.'/instantclient/libocci.so');
install_oci8($oracle_home);
setup_instant_libs($instantclient_home);
setup_instant_env($instantclient_home, $oci_ver);
&ui_print_footer("", $text{'index_return'});

71
lang/en Normal file
View File

@ -0,0 +1,71 @@
index_title=Oracle Instant Client
index_root=The root directory is $1.
index_return=Oracle Instant Client
manual_title=Edit config
manual_ecannot=You are not allowed to edit the Tomcat server.xml config file
manual_ok=Edit
manual_efile=Selected file is not part of the Tomcat server configuration
manual_file=Edit config file:
manual_edata=Nothing entered!
manual_err=Failed to save config file
install_button=Install
install_title=Installing ...
install_err1=Invalid URL
install_err2=Failed to install uploaded module
install_err3=Failed to install module from $1
install_efile=File does not exist
install_ebrowser=Your browser does not support file uploads
java_title=Oracle Java 8
java_tabinstall=Install
java_tabuninstall=Uninstall
java_desc1=Install Oracle Java 8 from an archive(tar.gz)
java_desc2=Uninstall Oracle Java 8 files from /usr/share
java_install=Install Oracle Java SDK/JRE 8
java_uninstall=Uninstall Oracle Java SDK/JRE 8
jdk_installsource=Oracle JDK source (.tar.gz)
jdk_latest=Latest JDK Version
java_installok=Install
java_deleteok=Uninstall
java_def_jdk=Set as system default Java
java_rm_def_jdk=Remove, if default Java
java_installed=JDK versions
source_local=Local file
source_uploaded=Uploaded file
source_ftp=FTP or HTTP URL
source_err0=File Error
source_err1=Upload Error
source_err1.2=No upload file
source_err2=Download error
source_err3=Invalid URL
oci_title=Oracle Instant Client
oci_install=Select version and packages
oci_version=Version
oci_packages=Packages
php_title=PHP
php_inst_title=Manage PHP packages
php_inst_edit=PHP Packages
php_inst_save=Update
php_versions=PHP Versions
pg_ext_title=Extensions
pg_ext_edit=Edit PostgreSQL extensions
pg_ext_save=Save
pg_ext_enabled=Enabled
pg_ext_disabled=Disabled
pg_ext_database=Database
pg_inst_title=PG Installer
pg_inst_edit=Edit PostgreSQL packages
pg_versions=Supported Versions
pg_inst_save=Update
pg_repo_install=Install repo
pg_enable_ssl=Enable SSL
pg_listen_all=Listen on all interfaces

3
module.info Normal file
View File

@ -0,0 +1,3 @@
desc=Oracle Instant Client
os_support=*-linux freebsd archlinux
category=servers

155
oci-lib.pl Normal file
View File

@ -0,0 +1,155 @@
BEGIN { push(@INC, ".."); };
use WebminCore;
#use File::Copy;
init_config();
sub get_oci_config
{
my $lref = &read_file_lines($config{'oci_conf'});
my @rv;
my $lnum = 0;
foreach my $line (@$lref) {
my ($n, $v) = split(/\s+/, $line, 2);
if ($n) {
push(@rv, { 'name' => $n, 'value' => $v, 'line' => $lnum });
}
$lnum++;
}
return @rv;
}
sub get_versions
{
local %version;
my $cmd_out='';
my $cmd_err='';
local $out = &execute_command("php -v", undef, \$cmd_out, \$cmd_err, 0, 0);
if($cmd_err ne ""){
&error("Error: php: $cmd_err");
return 1;
}
my @lines = split /\n/, $cmd_out;
foreach my $line (@lines){
if($line =~ /^PHP ([0-9\.-]+)/i){
$version{'php'} = $1;
}
}
$version{'oci'} = installed_instantclient_version();
return %version;
}
sub file_basename
{
my $rv = $_[0];
$rv =~ s/^.*[\/\\]//;
return $rv;
}
sub installed_instantclient_version(){
my %os_env;
if(-f '/etc/profile.d/instantclient.sh'){
read_env_file('/etc/profile.d/instantclient.sh', \%os_env);
}else{
read_env_file('/etc/environment', \%os_env);
}
return $os_env{'INSTANTCLIENT_VERSION'};
}
sub get_instantclient_home(){
my %os_env;
if(-f '/etc/profile.d/oci.sh'){
read_env_file('/etc/profile.d/oci.sh', \%os_env);
}else{
read_env_file('/etc/environment', \%os_env);
}
return $os_env{'INSTANTCLIENT_HOME'};
}
#Parse available OCI versions from OTN
sub get_oci_versions(){
my $error;
$url = "https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html";
$tmpfile = &transname("oci.html");
&error_setup(&text('install_err3', $url));
my %cookie_headers = ('Cookie'=> 'oraclelicense=accept-securebackup-cookie');
&http_download("www.oracle.com", 443,"/database/technologies/instant-client/linux-x86-64-downloads.html",
$tmpfile, \$error, undef, 1, undef, undef, 0, 0, 1, \%cookie_headers);
my @oci_versions;
open($fh, '<', $tmpfile) or die "open:$!";
while(my $line = <$fh>){
if($line =~ /Version ([0-9\.]+)/){
push(@oci_versions, $1);
}
}
close $fh;
push(@oci_versions, $page_number);
return @oci_versions;
}
sub download_file{
my $url = $_[0];
my ($proto, $x, $host, $path) = split('/', $url, 4);
my @paths = split('/', $url);
my $filename = $paths[-1];
if($filename eq ''){
$filename = 'index.html';
}
my $sslmode = $proto eq 'https:';
my $port = 80;
if($sslmode){
$port = 443;
}
&error_setup(&text('install_err3', $url));
my $tmpfile = &transname($filename);
$progress_callback_url = $url;
&http_download($host, $port, '/'.$path, $tmpfile, \$error, \&progress_callback, $sslmode);
if($error){
print &html_escape($error);
return '';
}
return $tmpfile;
}
sub exec_cmd{
my $cmd = $_[0];
my $cmd_out='';
my $rv = &execute_command($cmd, undef, \$cmd_out, \$cmd_out, 0, 0);
if($cmd_out){
$cmd_out = &html_escape($cmd_out);
$cmd_out =~ s/[\r\n]/<\/br>/g;
print $cmd_out;
}
return $rv;
}
sub unzip_file{
my $file = $_[0];
my $unzip_dir = $_[1];
my $unzip_out;
my $unzip_err;
print "<hr>Unzipping $file to $unzip_dir ...<br>";
local $out = &execute_command("unzip -ou \"$file\" -d \"$unzip_dir\"", undef, \$unzip_out, \$unzip_err, 0, 0);
if($unzip_err){
&error("Error: unzip: $unzip_err");
}else{
$unzip_out = s/\r\n/<br>/g;
print &html_escape($unzip_out);
}
return $unzip_dir;
}

190
php_install.cgi Normal file
View File

@ -0,0 +1,190 @@
#!/usr/bin/perl
require './oci-lib.pl';
require '../webmin/webmin-lib.pl'; #for OS detection
foreign_require('software', 'software-lib.pl');
sub get_packages_yum{
my $cmd_out='';
my $cmd_err='';
local $out = &execute_command("yum search php", undef, \$cmd_out, \$cmd_err, 0, 0);
if($out != 0){
&error("Error: yum: $cmd_err");
return 1;
}
my %pkgs;
my @lines = split /\n/, $cmd_out;
foreach my $line (@lines){
if($line =~ /^(php[a-z0-9_\.-]+)\.(noarch|x86_64)+ : (.*)/i){
$pkgs{$1} = $3;
}
}
return %pkgs;
}
sub get_installed_yum{
my $href = $_[0];
my $pkg_list = "";
foreach my $pkg (keys %$href){
$pkg_list .= " $pkg";
}
my $cmd_out='';
my $cmd_err='';
local $out = &execute_command("rpm -q --queryformat \"%{NAME}\n\" $pkg_list", undef, \$cmd_out, \$cmd_err, 0, 0);
my %pkgs;
my @lines = split /\n/, $cmd_out;
foreach my $line (@lines){
if($line =~ /^package\s+([a-z0-9_\.-]+)\s/i){ #package php is not installed
$pkgs{$1} = 0;
}else{
$pkgs{$line} = 1;
}
}
return %pkgs;
};
sub get_packages_apt{
my $cmd_out='';
my $cmd_err='';
local $out = &execute_command("apt-cache search '^php'", undef, \$cmd_out, \$cmd_err, 0, 0);
if($cmd_err ne ""){
&error("Error: apt-cache: $cmd_err");
return 1;
}
my %pkgs;
my @lines = split /\n/, $cmd_out;
foreach my $line (@lines){
if($line =~ /^(php.*) - (.*)/i){
$pkgs{$1} = $2;
}
}
return %pkgs;
}
sub get_installed_apt{
my $href = $_[0]; #package names
my %pkgs;
my $cmd_out='';
my $cmd_err='';
local $out = &execute_command("dpkg -l 'php*'", undef, \$cmd_out, \$cmd_err);
if($cmd_err ne ""){
&error("Error: dpkg: $cmd_err");
return %pkgs;
}
#set all packages to not installed, since dpkg won't list them
foreach my $name (keys %$href){
$pkgs{$name} = 0;
}
my @lines = split /\n/, $cmd_out;
foreach my $line (@lines){
if($line =~ /^(..)\s+(php[a-z0-9_\.-]+)\s+/i){
my $pkg = $2;
if($1 =~ /[uirph]i/){
$pkgs{$pkg} = 1;
}
}
}
return %pkgs;
};
sub update_packages{
my $pkgs_install = $_[0];
my $pkgs_remove = $_[1]; #\@lref
if($pkgs_install ne ""){
software::update_system_install($pkgs_install, undef);
}
if(@$pkgs_remove){
print "<br><p>Removing packages</p>";
my %opts = ('depstoo'=>1);
my $error = "";
if (defined(&delete_packages)) {
$error = software::delete_packages($pkgs_remove, \%opts, undef);
}else{
foreach my $pkg (@$pkgs_remove){
$error .= software::delete_package($pkg, \%opts, undef)
}
}
if($error ne ""){
&error($error);
}else{
foreach my $pkg (@$pkgs_remove){
print "<tt>Deleted $pkg</tt><br>"
}
}
}
}
&ui_print_header(undef, $text{'php_inst_title'}, "", "intro", 1, 1);
my $no_install = 1;
if($ENV{'CONTENT_TYPE'} =~ /boundary=(.*)$/) {
&ReadParseMime();
$no_install = 0;
}else{
&ReadParse();
$no_install = 1;
}
my %pkgs;
my %pkgs_installed;
my %osinfo = &detect_operating_system();
if( $osinfo{'os_type'} =~ /redhat/i){ #other redhat
%pkgs = get_packages_yum();
%pkgs_installed = get_installed_yum(\%pkgs);
}elsif( $osinfo{'real_os_type'} =~ /ubuntu/i){ #ubuntu
%pkgs = get_packages_apt();
%pkgs_installed = get_installed_apt(\%pkgs);
}
#Check what is updated
if ($ENV{REQUEST_METHOD} eq "POST" && $no_install == 0) {
#find what was changed
my @pkgs_remove;
my $pkgs_install="";
foreach my $pkg (sort keys %pkgs_installed){
if($in{$pkg.'_status'} != $pkgs_installed{$pkg}){
if($in{$pkg.'_status'} == 1){
$pkgs_install .= " $pkg";
}else{
push(@pkgs_remove, $pkg);
}
}
}
update_packages($pkgs_install, \@pkgs_remove);
&ui_print_footer("", $text{'index_return'});
exit;
}
print &ui_form_start("php_install.cgi", "form-data");
print &ui_table_start($text{'php_inst_edit'}, "width=100%", 3);
foreach my $pkg (sort keys %pkgs){
print &ui_table_row($pkg, ui_yesno_radio($pkg.'_status', $pkgs_installed{$pkg}).$pkgs{$pkg} ,3);
}
print &ui_table_end();
print &ui_form_end([ [ "", $text{'php_inst_save'} ] ]);
&ui_print_footer("", $text{'index_return'});

95
scripts/alma-rocky.sh Normal file
View File

@ -0,0 +1,95 @@
# !/bin/bash -e
# Tomcat Module Script for Rocky Linux
# Usage:
# wget https://raw.githubusercontent.com/cited/Tomcat-Webmin-Module/master/scripts/rocky-linux.sh
# chmod +x pre-installer
# ./pre-installer.sh
function get_deps(){
yum -y install wget unzip bzip2
}
function setup_selinux(){
#allow apache port for django app
semanage port -a -t http_port_t -p tcp 7800
semanage port -m -t http_port_t -p tcp 9000
setsebool -P httpd_can_network_connect 1
}
function install_apache(){
yum -y install httpd
}
function install_webmin(){
wget -P/tmp 'https://download.webmin.com/developers-key.asc'
rpm --import /tmp/developers-key.asc || true
cp -f /tmp/developers-key.asc /etc/pki/rpm-gpg/RPM-GPG-KEY-webmin-developers
cat >/etc/yum.repos.d/webmin.repo <<EOF
[Webmin]
name=Webmin Distribution Neutral
baseurl=https://download.webmin.com/download/newkey/yum
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webmin-developers
EOF
dnf --nogpgcheck install -y webmin tar rsync
}
function install_certbot_module(){
dnf install epel-release mod_ssl -y
dnf install certbot python3-certbot-apache -y
systemctl restart httpd
pushd /opt/
wget --quiet https://github.com/cited/Certbot-Webmin-Module/archive/master.zip
unzip master.zip
mv Certbot-Webmin-Module-master certbot
tar -czf /opt/certbot.wbm.gz certbot
rm -rf certbot master.zip
/usr/libexec/webmin/install-module.pl certbot.wbm.gz
popd
}
function download_oci_module(){
pushd /tmp/
wget https://github.com/cited/Oracle-Instant-Client/archive/master.zip
unzip master.zip
mv Oracle-Instant-Client oci
tar -czf /opt/ocu.wbm.gz oci
rm -rf oci master.zip
popd
}
function install_oci_module(){
pushd /opt/
/usr/libexec/webmin/install-module.pl oci.wbm.gz
popd
echo -e "Tomcat module is now installed. Go to Servers > Tomcat to complete installation"
}
get_deps;
setup_selinux;
#install_apache;
#install_webmin;
#download_certbot_module;
#install_certbot_module;
download_oci_module;
install_oci_module;

BIN
scripts/oci.wbm.gz Normal file

Binary file not shown.

79
scripts/ubuntu.sh Normal file
View File

@ -0,0 +1,79 @@
# !/bin/bash -e
# Tomcat Module Script for CentOS and Ubuntu
# For use on clean CentOS or Ubuntu box only
# Usage:
# wget https://raw.githubusercontent.com/cited/Tomcat-Webmin-Module/master/scripts/pre-install.sh
# chmod +x pre-installer
# ./pre-installer.sh
function install_webmin(){
echo "deb http://download.webmin.com/download/repository sarge contrib" > /etc/apt/sources.list.d/webmin.list
wget -qO - http://www.webmin.com/jcameron-key.asc | apt-key add -
apt-get -y update
apt-get -y install webmin
}
function download_oci_module(){
pushd /tmp/
wget https://github.com/cited/Oracle-Instant-Client/archive/master.zip
unzip master.zip
mv Oracle-Instant-Client-master oci
tar -czf /opt/oci.wbm.gz oci
rm -rf oci master.zip
popd
}
function install_oci_module(){
pushd /opt/
/usr/share/webmin/install-module.pl oci.wbm.gz
popd
echo -e "Tomcat module is now installed. Go to Servers > Tomcat to complete installation"
}
function download_certbot_module(){
pushd /tmp/
wget https://github.com/cited/Certbot-Webmin-Module/archive/master.zip
unzip master.zip
mv Certbot-Webmin-Module-master certbot
tar -czf /opt/certbot.wbm.gz certbot
rm -rf certbot master.zip
popd
}
function install_apache(){
apt-get -y install apache2
}
function install_certbot_module(){
pushd /opt/
/usr/share/webmin/install-module.pl certbot.wbm.gz
popd
echo -e "Certbot is now installed. Go to Servers > Certbot to complete installation"
}
function get_deps(){
apt-get -y install wget unzip
}
get_deps;
# Uncomment line(s) below if you wish to install Webmin, Apache HTTP Server, and Certbot as well.
#install_webmin;
#install_apache;
#download_certbot_module;
#install_certbot_module;
download_oci_module;
install_oci_module;

96
setup.cgi Normal file
View File

@ -0,0 +1,96 @@
#!/usr/bin/perl
require 'oci-lib.pl';
require '../webmin/webmin-lib.pl'; #for OS detection
foreign_require('software', 'software-lib.pl');
foreign_require('apache', 'apache-lib.pl');
sub setup_checks{
my %osinfo = &detect_operating_system();
if( $osinfo{'os_type'} =~ /redhat/i){ #other redhat
@pinfo = software::package_info('epel-release', undef, );
if(!@pinfo){
print "<p>Info: You can install epel-release to have more PHP packages. Install it manually or ".
"<a href='../software/install_pack.cgi?source=3&update=epel-release&return=%2E%2E%2Foci%2F&returndesc=Oracle%20PHP&caller=oci'>click here</a> to have it downloaded and installed.</p>";
}
}
my @pkg_deps;
if( ( $osinfo{'real_os_type'} =~ /rocky/i) or #Rocky
($osinfo{'real_os_type'} =~ /centos/i) or #CentOS
($osinfo{'real_os_type'} =~ /alma/i) ){ #Alma Linux
@pkg_deps = ('php', 'php-devel', 'mod_fcgid', 'php-cli', 'httpd', 'libaio', 'make', 'gcc')
}elsif( ($osinfo{'real_os_type'} =~ /ubuntu/i) or
($osinfo{'real_os_type'} =~ /debian/i) ){ #ubuntu or debian
@pkg_deps = ('php', 'php-dev', 'php-cgi', 'php-cli', 'apache2', 'libaio1', 'make', 'gcc');
if($found_pg_repo == 1){
push(@pkg_deps, ("postgresql-$pg_ver-mysql-fdw", "postgresql-$pg_ver-tds-fdw", "postgresql-server-dev-$pg_ver"));
}
}
my @pkg_missing;
foreach my $pkg (@pkg_deps){
my @pinfo = software::package_info($pkg);
if(!@pinfo){
push(@pkg_missing, $pkg);
}
}
if(@pkg_missing){
my $url_pkg_list = '';
foreach my $pkg (@pkg_missing){
$url_pkg_list .= '&u='.&urlize($pkg);
}
my $pkg_list = join(', ', @pkg_missing);
print "<p>Warning: Missing package dependencies - $pkg_list - are not installed. Install them manually or ".
"<a href='../package-updates/update.cgi?mode=new&source=3${url_pkg_list}&redir=%2E%2E%2Foci%2Fsetup.cgi&redirdesc=Setup'>click here</a> to have them installed.</p>";
}
if(! -d '/opt/oracle'){
print '<p>Oracle Instant Client is not installed. Install it from <a href="./edit_oci.cgi">OCI</a>';
}
print '<p>If you don\'t see any warning above, you can complete setup from '.
"<a href='setup.cgi?mode=cleanup&return=%2E%2E%2Foci%2F&returndesc=Setup&caller=oci'>here</a></p>";
}
#Remove all setup files
sub setup_cleanup{
my $file = $module_root_directory.'/setup.cgi';
print "Completing Installation</br>";
&unlink_file($file);
print &js_redirect("index.cgi");
}
&ui_print_header(undef, $text{'setup_title'}, "");
if($ENV{'CONTENT_TYPE'} =~ /boundary=(.*)$/) {
&ReadParseMime();
}else {
&ReadParse(); $no_upload = 1;
}
my $mode = $in{'mode'} || "checks";
if($mode eq "checks"){ setup_checks();
&ui_print_footer('', $text{'index_return'});
exit 0;
}elsif($mode eq "cleanup"){ setup_cleanup();
&ui_print_footer('', $text{'index_return'});
exit 0;
}elsif($mode eq "oracle_fdw"){ install_oracle_fdw();
&ui_print_footer('', $text{'index_return'});
exit 0;
}else{
print "Error: Invalid setup mode\n";
}
&ui_print_footer('setup.cgi', $text{'setup_title'});