Ubuntu 管理心得

搜尋此網誌

2020年6月29日 星期一

update grub efi from grub pc for gpt uefi


  1. make a fat32 partition of size 10M, e.g. /dev/sda1
  2. sudo mkdir /boot/efi
  3. put this line into /etc/fstab
    UUID=4CA9-C727  /boot/efi       vfat    umask=0077      0       1
  4. sudo mount -a
  5. purge old grub-pc, e.g.
  6. install grub-efi. e.g.  apt install grub-efi
  7. sudo update-grub
  8. sudo grub-install
  9. Done.

Using ubuntu live CD and suppose /mnt/2 contains all the old operation system, say ubuntu 18.04.
cd /mnt/2
mount -B /dev dev
mount -B /dev/pts dev/pts
mount -B /proc proc
mount -B /sys sys
mount -B /run run

cd /
chroot /mnt/2
vim /etc/hosts, add this line:
140.110.240.80 tw.archive.ubuntu.com 
 
To find where efi, say sda2, then
mount /dev/sda2 /boot/efi
apt purge grub-pc
apt update
apt install grub-efi

update-grub
grub-install
exit

umount /mnt/2/dev/pts
umount /mnt/2/dev
umount /mnt/2/proc
umount /mnt/2/sys
umount /mnt/2/run








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.
 

網誌存檔