カテゴリー: PHP環境設定

ubuntu KVMのブリッジで仮想マシンを外のネットワークと通信するためのnetplanの設定(NATは使わない)

network:
  version: 2
  renderer: networkd
  ethernets:
    enp5s0:
      dhcp4: no
  bridges:
    br0:
      dhcp4: no
      addresses:
        - 10.10.10.88/16
      interfaces:
        - enp5s0
      routes:
        - to: default
          via: 10.10.10.1
      nameservers:
        addresses: [10.10.10.1]
      parameters:
        forward-delay: 0
        stp: false
      optional: true

history | grep hoge はめんどくさい

mkdir /usr/local/mycommand

cat > /usr/local/mycommand/his <<EOF
#/bin/bash
history | grep \$1
EOF

chmod 755 /usr/local/mycommand/his

echo ‘export PATH=$PATH:/usr/local/mycommand’ >> /etc/profile

 

 

 

UBUNTUでTOMCATを使用する場合で、ファイルを書き込むときの設定

/etc/systemd/system/multi-user.target.wants/tomcat9.service

# Security
User=tomcat
Group=tomcat
PrivateTmp=yes
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
CacheDirectory=tomcat9
CacheDirectoryMode=750
ProtectSystem=strict
ReadWritePaths=/etc/tomcat9/Catalina/
ReadWritePaths=/var/lib/tomcat9/webapps/
ReadWritePaths=/var/log/tomcat9/
ReadWritePaths=/upload_folder/ <- ここに追加

 

外のフォルダーをマウントするとき

mount -t cifs -o user=hogehoge,password=hogehoge,dir_mode=0777,uid=999,gid=999 //192.168.0.21/out_folder /upload_folder

uid=999はtomcat

 

 

tinyMCEを使う

  tinymce.init({
    selector: '#質問内容',
    language: 'ja' ,
    language_url: 'tinymce_6.8.2/tinymce/js/tinymce/langs/ja.js',
    autoresize_min_height: 200,
    autoresize_max_height: 10000,
    promotion: false,
    statusbar: false,
    plugins: 'autoresize anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount ',
    toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table mergetags | align lineheight | tinycomments | checklist numlist bullist indent outdent | emoticons charmap | removeformat',
    tinycomments_mode: 'embedded',
    mergetags_list: [
      { value: 'First.Name', title: 'First Name' },
      { value: 'Email', title: 'Email' },
    ],
    init_instance_callback: editor => {
        editor.on('drop', event => {
          const file = event.dataTransfer.files[0];
          editor.on('Change', () => {
            if (file != undefined && file != null && file.name != '') {
              const doc = editor.getDoc();
              const imgs = Array.from(doc.images);
              // const len = imgs.length;
              imgs.forEach(img => {
                if (img.src.match(/^blob/) || img.currentSrc.match(/^blob/)) {
                  fetch(img.src)
                    .then(response => {
                      return response.blob();
                    })
                    .then(blob => {
                      const fData = new FormData();
                      fData.append('image', blob, file.name);
                      fData.append('action_cmd', 'upload');
                      fetch(
                        "質問Detail.do",
                        {
                          method: 'POST',
                          body: fData
                        }
                      )
                        .then(response => {
                          return response.json();
                        })
                        .then(json => {
                          img.src = json.result; // この「img」オブジェクトが挿入されるタグなので、「class」なり「data-caption」なり好きに追加できる
                        });
                    });
                }
              });
            }
          });
        });
      }
  });

chrome os mvneにインストールする時

$ sudo bash chromeos-install.sh -src rammu_recovery.bin -dst /dev/nvme0n1p1/dev/nvme0n1
はエラーになるので
以下のコマンドでやるとうまくいく
$ sudo bash chromeos-install.sh -src rammus_recovery.bin -dst /dev/nvme0n1

asterisk 保留音を変換する

#!/bin/sh

INDIR=/music/original
OTDIR=/music/asterisk
find ${INDIR}/ -name “*.wav” | grep ” ” | sed -e ‘s/.*/”&”/; p; s/ /_/g’ | xargs -n2 mv
if [ ! -e ${INDIR} ]; then
echo “${INDIR}$1: 元のフォルダーが存在しません.”
return 0
fi
if [ ! -d ${INDIR} ]; then
echo “$1: 元のファイルがフォルダーではありません.”
return 0
fi
if [ ! -e ${OTDIR} ]; then
echo “${OTDIR}$1: 先のフォルダーが存在しません.”
return 0
fi
if [ ! -d ${OTDIR} ]; then
echo “$1: 先のファイルがフォルダーではありません.”
return 0
fi
for file in `ls -1A ${INDIR}/*.wav `
do
fname=`basename ${file}`
echo ${fname}
sox “${INDIR}/${fname}” -b 16 “${OTDIR}/${fname}” channels 1 rate 8k norm gain -24
done

let’s encrypt IIS 更新処理

管理者でコマンドプロンプトを出す

d:
cd D:\win-acme.v2.1.8.847.x64.pluggable
wacs.exe を起動する。
Rを入れてエンターする
Qを入れてエンターする
以上終了

一発コマンド
D:\wacs.exe –renew –baseuri “https://acme-v02.api.letsencrypt.org/”

PostgreSql フィールド情報取得

select
information_schema.columns.column_name as fieldname ,
information_schema.columns.data_type as fieldtype ,
information_schema.columns.character_maximum_length as length ,
information_schema.columns.is_nullable ,
information_schema.columns.column_default as defaultflg,
information_schema.columns.numeric_precision,
information_schema.columns.numeric_precision_radix,
information_schema.columns.numeric_scale,
(select description from pg_description where
pg_description.objoid=pg_stat_user_tables.relid and
pg_description.objsubid=information_schema.columns.ordinal_position
) as comment
from
pg_stat_user_tables,
information_schema.columns
where
pg_stat_user_tables.relname=’authority_mail’
and pg_stat_user_tables.relname=information_schema.columns.table_name
order by information_schema.columns.ordinal_position;

defaultflg
defaultvalue
comment

はいずこ

Smarty 4.x: PHP 7.4 変数に日本語を使いたかった ;;_0_;;

class Smarty_Internal_Templatelexer
{


public function yylex2()
{
if (!isset($this->yy_global_pattern2)) {
$this->yy_global_pattern2 = $this->replace(“/\G((SMARTYldel)SMARTYal(if|elseif|else if|while)\\s+)|\G((SMARTYldel)SMARTYalfor\\s+)|\G((SMARTYldel)SMARTYalforeach(?![^\s]))|\G((SMARTYldel)SMARTYalsetfilter\\s+)|\G((SMARTYldel)SMARTYalmake_nocache\\s+)|\G((SMARTYldel)SMARTYal[0-9]*[、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠0-9a-zA-Z_]*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$]smarty\\.block\\.(child|parent)\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/][0-9]*[、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠0-9a-zA-Z_]*\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$][0-9]*[、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠0-9a-zA-Z_]*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal)/isS”);



public function yylex3()
{
if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 = $this->replace(“/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\”])|\G(‘[^’\\\\]*(?:\\\\.[^’\\\\]*)*’)|\G([$][0-9]*[、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠0-9a-zA-Z_]*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[]{2})\\s*)|\G([@])|\G(array\\s*[(]\\s*)|\G([#])|\G(\\s+[0-9]*[、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠0-9a-zA-Z_]*)?(\\\\[0-9]*[、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠0-9a-zA-Z_]*)+)|\G([0-9]*[、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠0-9a-zA-Z_]*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS”);



public function yylex5()
{
if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 = $this->replace(“/\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal[0-9]*[、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠0-9a-zA-Z_]*)|\G((SMARTYldel)SMARTYal)|\G([\”])|\G([`][$])|\G([$][0-9]*[、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠a-zA-Z_][、-◯ア-ンガ-ボァ-ョヮッーあ-んが-ぼぁ-ょゎっー亜-龠0-9a-zA-Z_]*)|\G([$])|\G(([^\”\\\\]*?)((?:\\\\.[^\”\\\\]*?)*?)(?=((SMARTYldel)SMARTYal|\\$|`\\$|\”SMARTYliteral)))|\G([\S\s])/isS”);




}

gitlab は全部gitlab だからアップグレードもgitlab

#yum install gitlab-ce-11.11.8-ce.0.el7.x86_64
#gitlab-ctl pg-upgrade
#gitlab-ctl reconfigure
#gitlab-ctl restart

バックアップ

#su - gitlab-psql
$/opt/gitlab/embedded/bin/pg_dump -h /var/opt/gitlab/postgresql gitlabhq_production > gitlabhq_production._20220401dump