スズハドットコム

IT関連や3Dプリンタの記事、たまに生活のメモを書いていきます。

Intel N100ミニPCにProxmox VE導入 ③You do not have a valid subscription for this serverダイアログを消す

Proxmoxをサブスクリプション無しで使用していると、

有効なサブスクリプションがありません
You do not have a valid subscription for this server. Please visit www.proxmox.com to get a list of available options.

のダイアログがたびたび表示されます。
サブスクリプション無しで使うのも正当な方法なのですが…何故こんなにうるさいの…
イライラしてきたので、こいつを消します!

Proxmox VEのサブスクリプションとは、製品自体の利用料金ではなくサポート料金です。
Proxmox VEはAGPL 3.0ライセンスで配布されていますので、無償で利用できますし、改造する権利もあります。

このダイアログ表示を司っているのは /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js です。
まず、編集失敗したときに備えてコピーしておきます。

root@proxmox:~# cp -p /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js.bak

proxmoxlib.js を編集します。
(エディタはviじゃなくてnanoとかでも構いませんよ)

root@proxmox:~# vi /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js

編集前
※左の数字は行番号です。
543行目のif文でサブスクリプションの有無を判定して、サブスクリプションがない場合は545行目のExt.Msg.showで例のダイアログを表示してます。

    533     checked_command: function(orig_cmd) {
    534         Proxmox.Utils.API2Request(
    535             {
    536                 url: '/nodes/localhost/subscription',
    537                 method: 'GET',
    538                 failure: function(response, opts) {
    539                     Ext.Msg.alert(gettext('Error'), response.htmlStatus);
    540                 },
    541                 success: function(response, opts) {
    542                     let res = response.result;
    543                     if (res === null || res === undefined || !res || res
    544                         .data.status.toLowerCase() !== 'active') {
    545                         Ext.Msg.show({
    546                             title: gettext('No valid subscription'),
    547                             icon: Ext.Msg.WARNING,
    548                             message: Proxmox.Utils.getNoSubKeyHtml(res.data.url),
    549                             buttons: Ext.Msg.OK,
    550                             callback: function(btn) {
    551                                 if (btn !== 'ok') {
    552                                     return;
    553                                 }
    554                                 orig_cmd();
    555                             },
    556                         });
    557                     } else {
    558                         orig_cmd();
    559                     }
    560                 },
    561             },
    562         );
    563     },

編集後
543行目に「/*」、559行目に「*/」を挿入することで、この区間をまとめてコメントアウトします。また、561行目の波括弧の前に「//」を入れてコメントアウトします。
これによりサブスクリプションの有無判定をスキップし、本来実行したい処理「orig_cmd();」だけが実行されるようにします。

    533     checked_command: function(orig_cmd) {
    534         Proxmox.Utils.API2Request(
    535             {
    536                 url: '/nodes/localhost/subscription',
    537                 method: 'GET',
    538                 failure: function(response, opts) {
    539                     Ext.Msg.alert(gettext('Error'), response.htmlStatus);
    540                 },
    541                 success: function(response, opts) {
    542                     let res = response.result;
    543                     /*
    544                     if (res === null || res === undefined || !res || res
    545                         .data.status.toLowerCase() !== 'active') {
    546                         Ext.Msg.show({
    547                             title: gettext('No valid subscription'),
    548                             icon: Ext.Msg.WARNING,
    549                             message: Proxmox.Utils.getNoSubKeyHtml(res.data.url),
    550                             buttons: Ext.Msg.OK,
    551                             callback: function(btn) {
    552                                 if (btn !== 'ok') {
    553                                     return;
    554                                 }
    555                                 orig_cmd();
    556                             },
    557                         });
    558                     } else {
    559                     */
    560                         orig_cmd();
    561                     // }
    562                 },
    563             },
    564         );
    565     },

編集したファイルを保存したら、pveproxy.serviceを再起動して反映します。

root@proxmox:~# systemctl restart pveproxy.service

ログイン直後にも、アップデート時にも、「有効なサブスクリプションがありません」ダイアログは表示されなくなりました。めでたしめでたし。