Skip to content

Commit

Permalink
Software title: MariaDb and phpMyAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Dec 4, 2024
1 parent 478d328 commit e363dde
Show file tree
Hide file tree
Showing 10 changed files with 286 additions and 0 deletions.
Binary file added tools/include/images/DAT001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tools/include/images/DAT005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions tools/include/markdown/DAT001-footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
=== "Configuration"

Database access configuration is done at first install:
- create root password
- create database
- create normal user
- create password for normal user

- Database host: `<your.IP>`

=== "Directories"

- Install directory: `/armbian/mariadb`
- Site configuration directory: `/armbian/mariadb/config`

=== "View logs"

```sh
docker logs -f mariadb
```
1 change: 1 addition & 0 deletions tools/include/markdown/DAT001-header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mariadb is one of the most popular database servers. Made by the original developers of MySQL.
19 changes: 19 additions & 0 deletions tools/include/markdown/DAT005-footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
=== "Access to the web interface"

The web interface is accessible via port **8071**:

- URL: `https://<your.IP>:8071`
- Server: IP from server you are connecting to. If you have installed MariaDB via this tool, then this is `<your.IP>`
- Username: defined at SQL server install (MariaDb)
- Password: defined at SQL server install (MariaDb)

=== "Directories"

- Install directory: `/armbian/phpmyadmin`
- Site configuration directory: `/armbian/phpmyadmin/config`

=== "View logs"

```sh
docker logs -f phpmyadmin
```
1 change: 1 addition & 0 deletions tools/include/markdown/DAT005-header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Phpmyadmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. phpMyAdmin supports a wide range of operations on MySQL and MariaDB.
66 changes: 66 additions & 0 deletions tools/json/config.software.json
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,72 @@
}
]
},
{
"id": "Database",
"description": "Database",
"sub": [
{
"id": "DAT001",
"description": "Mariadb install",
"command": [
"module_mariadb install"
],
"status": "Stable",
"author": "@armbian",
"condition": "! module_mariadb status"
},
{
"id": "DAT002",
"description": "Mariadb remove",
"command": [
"module_mariadb remove"
],
"status": "Stable",
"author": "@armbian",
"condition": "module_mariadb status"
},
{
"id": "DAT003",
"description": "Mariadb purge",
"command": [
"module_mariadb purge"
],
"status": "Stable",
"author": "@armbian",
"condition": "! module_mariadb status && [[ -d \"${SOFTWARE_FOLDER}/mariadb\" ]]"
},
{
"id": "DAT005",
"description": "phpMyAdmin install",
"command": [
"module_phpmyadmin install"
],
"status": "Stable",
"author": "@armbian",
"condition": "! module_phpmyadmin status"
},
{
"id": "DAT006",
"description": "phpMyAdmin remove",
"command": [
"module_phpmyadmin remove"
],
"status": "Stable",
"author": "@armbian",
"condition": "module_phpmyadmin status"
},
{
"id": "DAT007",
"description": "phpMyAdmin purge",
"command": [
"module_phpmyadmin purge"
],
"status": "Stable",
"author": "@armbian",
"condition": "! module_phpmyadmin status && [[ -d \"${SOFTWARE_FOLDER}/phpmyadmin\" ]]"
}
]
},
{
"id": "DNS",
"description": "DNS blockers",
Expand Down
2 changes: 2 additions & 0 deletions tools/modules/runtime/config.runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ fi
#plex_media_port="$(lsof -i -P -n | grep TCP | grep LISTEN | grep 'plex' | awk -F: '{print $2}' | awk '{print $1}' | head -n 1)"
#update_sub_submenu_data "Software" "Media" "SW22" "https://localhost:$plex_media_port"

update_sub_submenu_data "Software" "Database" "DAT002" "Server: $LOCALIPADD"
update_sub_submenu_data "Software" "Database" "DAT006" "http://$LOCALIPADD:${module_options["module_phpmyadmin,port"]}"
update_sub_submenu_data "Software" "Media" "MED006" "http://$LOCALIPADD:${module_options["module_stirling,port"]}"
update_sub_submenu_data "Software" "Containers" "CON006" "http://$LOCALIPADD:${module_options["module_portainer,port"]}"
update_sub_submenu_data "Software" "HomeAutomation" "HA004" "http://$LOCALIPADD:${module_options["module_haos,port"]}"
Expand Down
93 changes: 93 additions & 0 deletions tools/modules/software/install_mariadb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
module_options+=(
["module_mariadb,author"]=""
["module_mariadb,maintainer"]="@igorpecovnik"
["module_mariadb,testers"]="@igorpecovnik"
["module_mariadb,feature"]="module_mariadb"
["module_mariadb,desc"]="Install mariadb container"
["module_mariadb,example"]="install remove purge status help"
["module_mariadb,port"]="3306"
["module_mariadb,status"]="Active"
["module_mariadb,arch"]=""
)
#
# Module mariadb-PDF
#
function module_mariadb () {
local title="mariadb"
local condition=$(which "$title" 2>/dev/null)

if check_if_installed docker-ce; then
local container=$(docker container ls -a | mawk '/mariadb?( |$)/{print $1}')
local image=$(docker image ls -a | mawk '/mariadb?( |$)/{print $3}')
fi

local commands
IFS=' ' read -r -a commands <<< "${module_options["module_mariadb,example"]}"

MARIADB_BASE="${SOFTWARE_FOLDER}/mariadb"

case "$1" in
"${commands[0]}")
check_if_installed docker-ce || install_docker
[[ -d "$MARIADB_BASE" ]] || mkdir -p "$MARIADB_BASE" || { echo "Couldn't create storage directory: $MARIADB_BASE"; exit 1; }

# get parameters
MYSQL_ROOT_PASSWORD=$($DIALOG --title "Enter root password for Mariadb SQL server" --inputbox "\nHit enter for defaults" 9 50 "armbian" 3>&1 1>&2 2>&3)
MYSQL_DATABASE=$($DIALOG --title "Enter database name for Mariadb SQL server" --inputbox "\nHit enter for defaults" 9 50 "armbian" 3>&1 1>&2 2>&3)
MYSQL_USER=$($DIALOG --title "Enter user name for Mariadb SQL server" --inputbox "\nHit enter for defaults" 9 50 "armbian" 3>&1 1>&2 2>&3)
MYSQL_PASSWORD=$($DIALOG --title "Enter new password for ${MYSQL_USER}" --inputbox "\nHit enter for defaults" 9 50 "armbian" 3>&1 1>&2 2>&3)
docker run -d \
--name=mariadb \
-e PUID=1000 \
-e PGID=1000 \
-e TZ="$(cat /etc/timezone)" \
-e "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" \
-e "MYSQL_DATABASE=${MYSQL_DATABASE}" \
-e "MYSQL_USER=${MYSQL_USER}" \
-e "MYSQL_PASSWORD=${MYSQL_PASSWORD}" \
-p 3306:3306 \
-v "${MARIADB_BASE}/config:/config" \
--restart unless-stopped \
lscr.io/linuxserver/mariadb:latest
for i in $(seq 1 20); do
if docker inspect -f '{{ index .Config.Labels "build_version" }}' mariadb >/dev/null 2>&1 ; then
break
else
sleep 3
fi
if [ $i -eq 20 ] ; then
echo -e "\nTimed out waiting for ${title} to start, consult your container logs for more info (\`docker logs mariadb\`)"
exit 1
fi
done
;;
"${commands[1]}")
[[ "${container}" ]] && docker container rm -f "$container" >/dev/null
[[ "${image}" ]] && docker image rm "$image" >/dev/null
;;
"${commands[2]}")
[[ -n "${MARIADB_BASE}" && "${MARIADB_BASE}" != "/" ]] && rm -rf "${MARIADB_BASE}"
;;
"${commands[3]}")
if [[ "${container}" && "${image}" ]]; then
return 0
else
return 1
fi
;;
"${commands[4]}")
echo -e "\nUsage: ${module_options["module_mariadb,feature"]} <command>"
echo -e "Commands: ${module_options["module_mariadb,example"]}"
echo "Available commands:"
echo -e "\tinstall\t- Install $title."
echo -e "\tremove\t- Remove $title."
echo -e "\tpurge\t- Purge $title data folder."
echo -e "\tstatus\t- Installation status $title."

echo
;;
*)
${module_options["module_mariadb,feature"]} ${commands[4]}
;;
esac
}
84 changes: 84 additions & 0 deletions tools/modules/software/install_phpmyadmin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
module_options+=(
["module_phpmyadmin,author"]=""
["module_phpmyadmin,maintainer"]="@igorpecovnik"
["module_phpmyadmin,testers"]="@igorpecovnik"
["module_phpmyadmin,feature"]="module_phpmyadmin"
["module_phpmyadmin,desc"]="Install phpmyadmin container"
["module_phpmyadmin,example"]="install remove purge status help"
["module_phpmyadmin,port"]="8071"
["module_phpmyadmin,status"]="Active"
["module_phpmyadmin,arch"]=""
)
#
# Module phpmyadmin-PDF
#
function module_phpmyadmin () {
local title="phpmyadmin"
local condition=$(which "$title" 2>/dev/null)

if check_if_installed docker-ce; then
local container=$(docker container ls -a | mawk '/phpmyadmin?( |$)/{print $1}')
local image=$(docker image ls -a | mawk '/phpmyadmin?( |$)/{print $3}')
fi

local commands
IFS=' ' read -r -a commands <<< "${module_options["module_phpmyadmin,example"]}"

PHPMYADMIN_BASE="${SOFTWARE_FOLDER}/phpmyadmin"

case "$1" in
"${commands[0]}")
check_if_installed docker-ce || install_docker
[[ -d "$PHPMYADMIN_BASE" ]] || mkdir -p "$PHPMYADMIN_BASE" || { echo "Couldn't create storage directory: $PHPMYADMIN_BASE"; exit 1; }
docker run -d \
--name=phpmyadmin \
-e PUID=1000 \
-e PGID=1000 \
-e TZ="$(cat /etc/timezone)" \
-e PMA_ARBITRARY=1 \
-p 8071:80 \
-v "${PHPMYADMIN_BASE}/config:/config" \
--restart unless-stopped \
lscr.io/linuxserver/phpmyadmin:latest
for i in $(seq 1 20); do
if docker inspect -f '{{ index .Config.Labels "build_version" }}' phpmyadmin >/dev/null 2>&1 ; then
break
else
sleep 3
fi
if [ $i -eq 20 ] ; then
echo -e "\nTimed out waiting for ${title} to start, consult your container logs for more info (\`docker logs phpmyadmin\`)"
exit 1
fi
done
;;
"${commands[1]}")
[[ "${container}" ]] && docker container rm -f "$container" >/dev/null
[[ "${image}" ]] && docker image rm "$image" >/dev/null
;;
"${commands[2]}")
[[ -n "${PHPMYADMIN_BASE}" && "${PHPMYADMIN_BASE}" != "/" ]] && rm -rf "${PHPMYADMIN_BASE}"
;;
"${commands[3]}")
if [[ "${container}" && "${image}" ]]; then
return 0
else
return 1
fi
;;
"${commands[4]}")
echo -e "\nUsage: ${module_options["module_phpmyadmin,feature"]} <command>"
echo -e "Commands: ${module_options["module_phpmyadmin,example"]}"
echo "Available commands:"
echo -e "\tinstall\t- Install $title."
echo -e "\tremove\t- Remove $title."
echo -e "\tpurge\t- Purge $title data folder."
echo -e "\tstatus\t- Installation status $title."

echo
;;
*)
${module_options["module_phpmyadmin,feature"]} ${commands[4]}
;;
esac
}

0 comments on commit e363dde

Please sign in to comment.