Skip to content

antony@notes:~/container$ cat "Install-Apache-Guacamole-on-alpine-linux.md"

Install Apache Guacamole on alpine linux

2022-08-19· container ·Apache Guacamole

Install Apache Guacamole on alpine linux

Rrepare

下載 guacamole 套件

$ git clone https://gitlab.com/flysangel/oss_gmm.git

檢查

$ cd oss_gmm/

$ $ ls -al
total 84
drwxr-sr-x    6 bigred   bigred        4096 Aug 11 18:05 .
drwxr-sr-x    9 bigred   bigred        4096 Aug 11 18:05 ..
drwxr-sr-x    8 bigred   bigred        4096 Aug 11 18:05 .git
-rw-r--r--    1 bigred   bigred         184 Aug 11 18:05 Dockerfile.ext-demeter-v1.0.0
-rw-r--r--    1 bigred   bigred         184 Aug 11 18:05 Dockerfile.ext-leopard-v1.0.0
-rw-r--r--    1 bigred   bigred         180 Aug 11 18:05 Dockerfile.ext-sre-v1.0.0
-rw-r--r--    1 bigred   bigred         184 Aug 11 18:05 Dockerfile.ext-storage-v1.0.0
-rw-r--r--    1 bigred   bigred         181 Aug 11 18:05 Dockerfile.ext-zeus-v1.0.0
-rw-r--r--    1 bigred   bigred         934 Aug 11 18:05 Dockerfile.guacenc-v1.0.0
-rw-r--r--    1 bigred   bigred         239 Aug 11 18:05 Dockerfile.mariadb-v1.0.0
-rw-r--r--    1 bigred   bigred         136 Aug 11 18:05 Dockerfile.zh-fonts-v1.0.0
-rw-r--r--    1 bigred   bigred       11357 Aug 11 18:05 LICENSE
-rw-r--r--    1 bigred   bigred        3424 Aug 11 18:05 README.md
drwxr-sr-x    6 bigred   bigred        4096 Aug 11 18:05 guac-ext
drwxr-sr-x    5 bigred   bigred        4096 Aug 11 18:05 kubernetes
-rw-r--r--    1 bigred   bigred        1527 Aug 11 18:05 podman.yaml
drwxr-sr-x    3 bigred   bigred        4096 Aug 11 18:05 rest-api
-rw-r--r--    1 bigred   bigred         156 Aug 11 18:05 run.conf
-rwxr-xr-x    1 bigred   bigred        1369 Aug 11 18:05 run.sh

看 podman.yaml 內容

$ cat podman.yaml
apiVersion: v1
kind: Pod
metadata:
  name: gmm
  labels:
    app: gmm
spec:
  containers:
    - name: guacamole
      image: quay.io/flysangel/gmm:ext-demeter-v1.0.0
      imagePullPolicy: IfNotPresent
      ports:
        - containerPort: 8080
          hostPort: 8080
          protocol: TCP
      env:
        - name: GUACAMOLE_HOME
          value: /guacamole-home
        - name: GUACD_HOSTNAME
          value: gmm
        - name: MYSQL_HOSTNAME
          value: gmm
        - name: MYSQL_DATABASE
          value: guacamole
        - name: MYSQL_USER
          value: guacamole
        - name: MYSQL_PASSWORD
          value: mymariadbguacamole
        - name: TZ
          value: Asia/Taipei

    - name: guacd
      image: quay.io/flysangel/gmm:zh-fonts-v1.0.0
      imagePullPolicy: IfNotPresent

    - name: mariadb
      image: quay.io/flysangel/gmm:mariadb-v1.0.0
      imagePullPolicy: IfNotPresent
      args:
        [
          "--character-set-server=utf8mb4",
          "--collation-server=utf8mb4_general_ci",
        ]
      env:
        - name: MYSQL_ROOT_PASSWORD
          value: root
        - name: MYSQL_DATABASE
          value: guacamole
        - name: MYSQL_USER
          value: guacamole
        - name: MYSQL_PASSWORD
          value: mymariadbguacamole
        - name: TZ
          value: Asia/Taipei
      volumeMounts:
        - name: mariadb
          mountPath: /var/lib/mysql

  volumes:
    - name: mariadb
      hostPath:
        path: ./volume/mariadb/volume

  restartPolicy: Always
  • containers:
    - name: guacamole
    image: quay.io/flysangel/gmm:ext-demeter-v1.0.0
  • gmm:ext-demeter-v1.0.0 ,ext 的意思就是只要使用客製化的圖案,標籤前面就會有 ext。
    • ext-demeter-v1.0.0,希臘神
    • ext-zeus-v1.0.0,宙斯
    • ext-leopard-v1.0.0,石虎
    • ext-storage-v1.0.0,學士帽
  • 要換圖片的話,換 image 的名稱就好
$ cat Dockerfile.ext-sre-v1.0.0
FROM quay.io/flysangel/guacamole

USER root

RUN \
    mkdir -p /guacamole-home/extensions

COPY ./guac-ext/jar/ext-sre.jar /guacamole-home/extensions/guac-ext.jar

USER guacamole
  • 換圖片就要換 image 的原因是因為,如果用原生的 Guacamole 他的圖案不會是我們指定的,要做到插件,會需要打包成規定的 *.jar 檔格式,因為 Guacamole 是 Java 寫的。
  • 如果今天要把圖片客製化,或是其他內容客製化,一定要符合官網的格式,不是將圖片放到某個資料夾就好,也就是說要把自己客製化的內容,打包成 *.jar 檔, Guacamole 才會咬住新的設定。
  • 如果 Guacamole 要放宙斯的圖,就是要 run 宙斯的 Dockerfile 來建 Container 。
  • 產生 .jar 不容易。
  • 如果已啟動的 Guacamole 想換圖片,要先 Remove 掉原本的。資料的部分,因為只有 mariadb 啟動之後,他會產生 volune 在資料夾(oss_gmm)下面,所以只要 volune 還在,無論怎麼重新產生 Guacamole ,資料都不會被影響到,因為 Guacamole 是直接去讀取資料,他沒有任何東西存在 Container 裡面。

oss gmm

Apache Guacamole is a clientless remote desktop gateway. It supports standard protocols like VNC, RDP, and SSH. We call it clientless because no plugins or client software are required. Thanks to HTML5, once Guacamole is installed on a server, all you need to access your desktops is a web browser.

Apache guacamole

Chinese-characters

How to start on podman

  1. Git clone

    $ git clone https://gitlab.com/flysangel/oss_gmm.git
  2. Use oss gmm

    $ cd oss_gmm
  3. Create db volume

    $ mkdir -p ./volume/mariadb/volume
  4. podman play

    # single guacd
    $ sudo podman play kube podman.yaml
    $ sudo podman ps -a
    # stop single guacd
    $ sudo podman pod stop gmm
    $ sudo podman pod rm gmm
    $ sudo rm -r volume
    • play,Play containers, pods or volumes from a structured file

Test

  1. Open Chrome

    http://localhost:8080/guacamole
    
    username: guacadmin
    password: guacadmin

Reset guacadmin password

  1. Login to guacamole mariadb and use guacamole databases

    # https://github.com/apache/guacamole-client/blob/master/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/002-create-admin-user.sql
    
    -- Create default user "guacadmin" with password "guacadmin"
    INSERT INTO guacamole_entity (name, type) VALUES ('guacadmin', 'USER');
    INSERT INTO guacamole_user (entity_id, password_hash, password_salt, password_date)
    SELECT
       entity_id,
       x'CA458A7D494E3BE824F5E1E175A1556C0F8EEF2C2D7DF3633BEC4A29C4411960',  -- 'guacadmin'
       x'FE24ADC5E11E2B25288D1704ABE67A79E342ECC26064CE69C5B3177795A82264',
       NOW()
    FROM guacamole_entity WHERE name = 'guacadmin';
    
    -- Grant this user all system permissions
    INSERT INTO guacamole_system_permission (entity_id, permission)
    SELECT entity_id, permission
    FROM (
             SELECT 'guacadmin'  AS username, 'CREATE_CONNECTION'       AS permission
       UNION SELECT 'guacadmin'  AS username, 'CREATE_CONNECTION_GROUP' AS permission
       UNION SELECT 'guacadmin'  AS username, 'CREATE_SHARING_PROFILE'  AS permission
       UNION SELECT 'guacadmin'  AS username, 'CREATE_USER'             AS permission
       UNION SELECT 'guacadmin'  AS username, 'CREATE_USER_GROUP'       AS permission
       UNION SELECT 'guacadmin'  AS username, 'ADMINISTER'              AS permission
    ) permissions
    JOIN guacamole_entity ON permissions.username = guacamole_entity.name AND guacamole_entity.type = 'USER';
    
    -- Grant admin permission to read/update/administer self
    INSERT INTO guacamole_user_permission (entity_id, affected_user_id, permission)
    SELECT guacamole_entity.entity_id, guacamole_user.user_id, permission
    FROM (
             SELECT 'guacadmin' AS username, 'guacadmin' AS affected_username, 'READ'       AS permission
       UNION SELECT 'guacadmin' AS username, 'guacadmin' AS affected_username, 'UPDATE'     AS permission
       UNION SELECT 'guacadmin' AS username, 'guacadmin' AS affected_username, 'ADMINISTER' AS permission
    ) permissions
    JOIN guacamole_entity          ON permissions.username = guacamole_entity.name AND guacamole_entity.type = 'USER'
    JOIN guacamole_entity affected ON permissions.affected_username = affected.name AND guacamole_entity.type = 'USER'
    JOIN guacamole_user            ON guacamole_user.entity_id = affected.entity_id;

License

Apache License.

How to start on podman

Alpine install podman

Ubuntu install podman

  1. Git clone

    $ git clone https://gitlab.com/flysangel/oss_ncb.git
  2. Use oss ncb

    $ cd oss_ncb
  3. Setting init-letsencrypt.conf

    $ nano init-letsencrypt.conf
    ::
    EMAIL='qazzxc5200@gmail.com'
    DOMAINS='flymks.com gmm.flymks.com web.flymks.com'
  4. Change nginx default.conf

    $ nano ./volume/nginx/conf.d/default.conf
    ::
    server_name gmm.flymks.com web.flymks.com;
  5. Run init-letsencrypt

    $ sudo ./init-letsencrypt.sh
  6. Change init-letsencrypt.conf to prod

    $ nano init-letsencrypt.conf
    ::
    STAGING='0'
  7. Run init-letsencrypt

    $ sudo ./init-letsencrypt.sh
  8. Change nginx default.conf

    $ nano ./volume/nginx/conf.d/default.conf
    ::
    server {
        listen 443 ssl;
    
        server_name gmm.flymks.com;
        include /etc/nginx/policy/ssl/flymks.com.conf;
    
        location / {
            include /etc/nginx/policy/websocket/websocket.conf;
            proxy_pass http://192.168.1.252:8080/guacamole/;
        }
    }
  9. podman play

    $ sudo podman play kube podman.yml
    $ sudo podman ps -a

License

Apache License.

  315   cd /etc/local.d/
  316   ls -al
  317   sudo nano gmm.start
  $ cat gmm.start
  sudo podman pod restart gmm
  318   sudo nano ncb.start
  $ cat ncb.start
  sudo podman pod restart ncb
  319   sudo chmod a+x gmm.start
  320   sudo chmod a+x ncb.start
  343   git clone https://gitlab.com/flysangel/oss_ncb.git
  344   cd oss_ncb
  345   nano init-letsencrypt.conf
  346   ls -al
  347   ./init-letsencrypt.sh
  348   sudo ./init-letsencrypt.sh
  349   nano init-letsencrypt.conf
  350   sudo ./init-letsencrypt.sh
  351   sudo nano ./volume/nginx/conf.d/default.conf
  352   sudo nano ./volume/nginx/conf.d/default.conf
  353   ip a
  354  sudo podman play kube podman.yaml
  355  sudo podman ps -a
  356  sudo podman ps -a
  357  sudo podman ps -a
  358   ls -a-l
  359   cat init-letsencrypt.sh
  360   cat init-letsencrypt.conf
  361   sudo podman pod ps
  362   sudo podman ps -a
  363   sudo podman logs ncb-nginx
  364   sudo nano ./volume/nginx/conf.d/default.conf
  365   sudo podman pod stop ncb
  366   sudo podman pod rm ncb
  367   sudo podman play kube podman.yaml
  368   cat init-letsencrypt.sh
  369   cat init-letsencrypt.conf
  370   sudo podman pod ps
  371   sudo podman pod stop ncb
  372   sudo podman pod rm ncb
  373   sudo podman ps -a
  374   ls -al
  375   sudo ./init-letsencrypt.sh
  376   cat volume/nginx/conf.d/default.conf
  377   sudo nano volume/nginx/conf.d/default.conf
  378   sudo podman play kube podman.yaml
  379   sudo passwd bigred
tags: Apache Guacamole