Ubuntu 管理心得

搜尋此網誌

2020年6月28日 星期日

sync Frontdoor to dropbox

Two stages,
1. setup rclone with dropbox
2. setup incrontab with the command:
incrontab -e

and add this line:
/home/pi/webcam    IN_CREATE    /usr/bin/rclone sync /home/pi/webcam mydropbox:webcam/FrontDoor

2020年6月16日 星期二

core_version_requirement

 cf :https://www.drupal.org/node/3070687  



This version is not compatible with Drupal 9.0.0 and should be replaced.
Machine name: fahp_synthesis
Requires:
  • Drupal Core (8.x) (incompatible with version 9.0.0)

Edit my_custom_module.info.yml:

change

core: 8.x

to
 
core: 8.x
core_version_requirement: ^8 || ^9

for drupal 9.x

2020年6月12日 星期五

drupal_set_message deprecated in drupal 9

Create a function:

//---------------------------------------------------------
function drupal_set_message($message = NULL)
    {
    $messenger = \Drupal::messenger();
    if (isset($message)){
      $messenger->addMessage($message,'status',FALSE);    }
    }
//---------------------------------------------------------

Replace

 drupal_set_message(array(
        '#type' => 'markup',
        '#markup' => $tle));

with these lines:

 $this->drupal_set_message(array(
       '#type' => 'markup',
       '#markup' => $tle));

drupal 9 db_query deprecated

cf: https://www.drupal.org/project/advban/issues/3090341

Replace db_query with \Drupal::database()->query, e.g.

//$res=db_query($sql) or die("Error: $sql");
$res=Database::getConnection()->query($sql) or die("Error: $sql");

Use the script to change:


#!/bin/bash
find ./ -type f -exec sed -i 's+db_query(+Database::getConnection()->query(+g' {} \;

2020年6月5日 星期五

Create drupal 9 with composer

$ mkdir /home/chiao/public_html/drupal9 
$ composer create-project drupal/recommended-project:~9.0.0
  /home/chiao/public_html/drupal9
Go to /home/chiao/public_html/drupal9/web/sites.
 Copy files to drupal9:
    Custom themes go to /home/chiao/public_html/drupal9/web/themes/custom/
    Custom modules go to /home/chiao/public_html/drupal9/web/modules/custom/
    Libraries go to /home/chiao/public_html/drupal9/web/libraries/
    Your uploaded files and images go to /home/chiao/public_html/drupal9/web/sites/default/files/ 
Copy (using sudo cp -av) the following files and directories to new site:
  1. sites/default/settings.php 
  2. sites/default/settings.local.php
  3. sites/default/files/config_5cKxplPBXz7CfVTT9KjhZ3fJkIg1ygQ2hTdYEM64PUZQUPSy94TTCTcHuJ16-cOW_918dZ1kpw/   asdfsd
  4. sites/development.services.yml 
$  cd /home/chiao/public_html/drupal9
$  composer install
All done for creating new drupal 9.
 

2020年5月23日 星期六

tex-common error

sudo mv /etc/texmf /etc/texmf_old
sudo apt install lyx tex-common

2020年5月22日 星期五

Create new drupal from old drupal using composer

(For updating 8.9.x in kpci7, cf. https://kpchiaoo.blogspot.com/2018/09/update-drupal.html

 

When using:

composer update --dry-run "drupal/*"

This should show any available minor or patch update, however, my site didn't show any minor version for drupal.

So I follow this: https://www.drupal.org/docs/8/install/add-composer-to-an-existing-site
to create a new site and to transfer my old files to the new site.

1. Create a new drupal site, drupal_new:
cd /home/chiao/public_html
composer create-project drupal/recommended-project:~8.8.0 drupal_new --stability dev --no-interaction

2. Copy files to drupal_new:

    Custom themes go to /var/www/sites/new_html/web/themes/custom/

    Custom modules go to /var/www/sites/new_html/web/modules/custom/

    Libraries go to /var/www/sites/new_html/web/libraries/

    Your uploaded files and images go to /var/www/sites/new_html/web/sites/default/files/
3. Copy sites files:
cd /home/chiao/public_html/drupal_new/web/sites/default
sudo cp -av ~/public_html/drupal/sites/default/settings.php .
sudo cp -av ~/public_html/drupal/sites/default/settings.local.php .
sudo cp -av ~/public_html/drupal/sites/default/files/config_5cKxplPBXz7CfVTT9KjhZ3fJkIg1ygQ2hTdYEM64PUZQUPSy94TTCTcHuJ16-cOW_918dZ1kpw/ files/

cd /home/chiao/public_html/drupal_new/web/sites/
sudo cp -av ~/public_html/drupal/sites/development.services.yml .

change owner, www-data:
sudo chown -R www-data.www-data files/ settings.*

4. Edit composer.json in your new project root (e.g., /var/www/sites/new_html) and copy the list of packages from your old composer.json's "require" and "require-dev" sections to the new composer.jsonfile.

5. rm  ~/public_html/drupal_new/composer.lock
composer install

6. All done for creating new druapl.

7. cd  ~/public_html/drupal_new/
drush state:set system.maintenance_mode 1
drush cache-clear drush
composer update drupal/core-recommended --with-dependencies
drush updatedb
drush cache-clear drush
drush state:set system.maintenance_mode 0
drush cache:rebuild

drupal, All links redirect to Homepage

sudo a2enmod rewrite
sudo systemctl restart apache2

2020年5月11日 星期一

Increase mp4 volume using FFMPEG

cf: https://blog.programster.org/change-audio-level-in-video

ffmpeg -i my.mp4 -vcodec copy -af "volume=25dB" my_25dB.mp4

Or,

for i in *.mp4; do \
ffmpeg -i $i  -vcodec \
copy -af "volume=25dB" \
${i%.*}_25dB.mp4 ; \
done

2020年4月29日 星期三

Thunderbird AU calendar not working and not shown

Delete the 'AU' calender, and create it again.

2020年4月15日 星期三

drupal 批次設定使用者角色 (role)






然後在「動作」中點選「Add the QuantitativeMethods role to the selected user(s)

2020年3月17日 星期二

Pulse Secure installation

  1. Download the Pulse Secure client:
    https://its.wpi.edu/software/259/pulse-secure
    https://drive.narlabs.org.tw/navigate/s/6C30CA2A0C7A47E48C2D4034C4A55630GUY
    Pulse Secure Installer (Linux 64-bit)Ubuntu

  2. sudo dpkg --install pulse-9.1R3.x86_64.deb
  3. sudo apt-get install libwebkitgtk-1.0-0
  4. sudo apt-get install libproxy1-plugin-webkit
  5. /usr/local/pulse/pulseUi
  6. Add new connection for AU using URL:
    https://au.twaren.net/au/staff

2020年2月28日 星期五

replace xz with 7z with password

#!/bin/bash

for i in /BACKUP/kpchiao9600k/20200225_Ubuntu_18.04.4_LTS/*; do
    xzcat $i | 7z a -mx=9 -mmt=4 -p -si "$(basename "$i" .tar.xz)_pwd_bsun.tar.7z"
done
#
# Decompress with the following command followed by the password.
#   7z x -so boot_efi_2020_02_25_pwd_bsun.tar.7z | tar tvf -
# Just key in the password, no prompt will be shown.

2020年2月27日 星期四

setup permission for mysqldump


  1. Create ~/.my.cnf, add these lines:
    [mysqldump]
    user=student
    password=student
    chmod 0600 ~/.my.cnf
  2. Inside phpmyadmin, set 'Select' and 'LOCK TABLES' permission to database 'drupal' for 'student' as the following image:


  3. Then, dump drupal with the command without username and password:
     mysqldump drupal > kpchiao9600k_drupal.sql
    or
     mysqldump -B drupal > kpchiao9600k_drupal.sql
    The -B option will add the create database and use datatebase lines into dump file as:
    CREATE DATABASE /*!32312 IF NOT EXISTS*/ `drupal` /*!40100 DEFAULT CHARACTER SET latin1 */;

    USE `drupal`;





2020年2月14日 星期五

2020年2月12日 星期三

Install nvidia driver ubuntu

  1. ubuntu-drivers devices
    e.g. nvidia-driver-435 - distro non-free recommended
  2. sudo ubuntu-drivers autoinstall or

    sudo ubuntu-drivers nvidia-driver-435 

  3. reboot 

2020年2月9日 星期日

mysql installation on ubuntu 18.04

  1. sudo apt update
  2. sudo apt install mysql-server
  3. sudo mysql_secure_installation
  4. sudo mysql, then issue the command: SELECT user,authentication_string,plugin,host FROM mysql.user;
Originally, the root user is authenticated with the "auth_socket" plugin.
To configure the root account to authenticate with a password,
run the following ALTER USER command.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
 
Replacing the 'password' with a new strong password. 
Note that this command will change the root password you set in Step 2. 

2020年1月19日 星期日

Catalina on Virtualbox installation

cf: https://techsviewer.com/install-macos-10-15-catalina-on-virtualbox-on-windows-pc/

These codes are critical. Issue  these lines in user account (chiao) not sudo.
Code for VirtualBox (New): 
Note: replace "Your VM Name" in this commands line with your Virtual Machine Name in step 3, then type in the following code:
  • cd "C:\Program Files\Oracle\VirtualBox\"
  • VBoxManage modifyvm "Your VM Name" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
  • VBoxManage setextradata "Your VM Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
  • VBoxManage setextradata "Your VM Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
  • VBoxManage setextradata "Your VM Name" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
  • VBoxManage setextradata "Your VM Name" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
  • VBoxManage setextradata "Your VM Name" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

Change the screen size (e.g. 1440x900):
VBoxManage setextradata  "Your VM Name" VBoxInternal2/EfiGraphicsResolution 1440x900

2020年1月11日 星期六

screen useful commands

Screen commands

 create new window C-a c
rename current window C-a A
see window list C-a " (allows you to select a window to change to)  

split display horizontally C-a S
split display vertically C-a | or C-a V (for the vanilla vertical screen patch)
jump to next display region C-a tab
remove current region C-a X
remove all regions but the current one C-a Q


Scrollback-buffer

In copy mode, one can navigate the scrollback buffer in various ways:
half page up C-u half page down C-d
back C-b forward C-f
cursor left/down/up/right h/j/k/l

2020年1月3日 星期五

vmware mac OS Catalina installation

cf from: https://techsviewer.com/how-to-install-macos-10-15-catalina-on-vmware-on-windows-pc/

  1. update vmware wordkstation to 15.5.1
  2. download unlocker 3.0.3, VERY IMPORTANT!, Edit lnx-install.sh,
    Change the lines inside of lnx-install.sh from 'python gettools.py' to 'python3.7  gettools.py
  3.  Create new guest : Select Guest Operation System: Apple OS X -> macOS 10.15
  4.  After get into guest, then power off, close vmware workstation
  5.  Edit vmx file: insert smc.version = "0" 
  6. Open guest and click Options tab, Guest Operating System  change  to Microsoft Windows and Version to Windows 10 x64
  7.  Power on guest, get into the page: macOS 工具程式,select:
  8. click it, then
  9. Then erase it and format as Mac OS 擴充格式 (日誌式)
    click 清除.

  10. Back into macOS 工具程式,then 安裝 macOS
  11. Wait ... couple of hours !
  12. After installation is ok, change Guest OS back to "macOS 10.15"

2020年1月2日 星期四

clone grade database

Clone from  kpci7:
mysqldump -u chiao -h localhost  -p grade_108_1 > grade_108_1_20200103.sql

to kpchiaoi5:
mysql -u chiao -p grade_108_1 < grade_108_1_20200103.sql



2019年12月29日 星期日

install gd fro php

sudo apt install php-gd
sudo systemctl restart apache2

2019年12月28日 星期六

drupal clean url not working

sudo a2enmod rewrite
sudo systemctl restart apache2

If drupal cannot work after cloning, then ... try this

Some error messages:

Error: Class 'DOMDocument' not found in Drupal\Component\Utility\Html::load() (line 286 of core/lib/Drupal/Component/Utility/Html.php)

sudo apt-get install php-xml
sudo systemctl restart apache2
 

Using root login mysql with password

sudo mysql
ALTER USER 'root'@'localhost%' IDENTIFIED WITH mysql_native_password BY 'your-password';
FLUSH PRIVILEGES;
exit;
 

2019年12月6日 星期五

cwtex with bkai and bsmi fonts

LyX source file
LaTeX source file

\documentclass{extarticle}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage{CJKutf8}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=0.75in,bmargin=0.75in,lmargin=0.75in,rmargin=0.75in}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage[authoryear]{natbib}
\begin{document}
\begin{CJK}{UTF8}{}%

\section{\CJKencfamily{UTF8}{bkai}

}


\CJKencfamily{UTF8}{bsmi}這是本文

{\Huge{}這是本文(最大字)}{\Huge\par}
\end{CJK}

\end{document}

2019年12月5日 星期四

cwfsu61 trouble solved!

Do not use 
\CJKencfamily{UTF8}{cwfsu}
use
\CJKencfamily{UTF8}{cwfsc}

Also, inside text contents use
\CJKencfamily{UTF8}{cwkc}

2019年11月5日 星期二

Wireless wakeup on lan

For my hp pavilion gaming 15 notebook:

iw phy0 wowlan show
sudo iw phy0 wowlan  enable magic-packet disconnect
iw phy0 wowlan show

網誌存檔