mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-06 23:50:16 +08:00
commit
851169d19f
@ -1,17 +1,18 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (HankChow)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-12715-1.html)
|
||||
[#]: subject: (Using Bash traps in your scripts)
|
||||
[#]: via: (https://opensource.com/article/20/6/bash-trap)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
在脚本中使用 Bash 信号捕获
|
||||
======
|
||||
|
||||
> 无论你的脚本是否成功运行,<ruby>信号捕获<rt>trap</rt></ruby>都能让它平稳结束。
|
||||
|
||||
![Hands programming][1]
|
||||
![](https://img.linux.net.cn/data/attachment/album/202010/13/182135f2nktcrnryncisg8.jpg)
|
||||
|
||||
Shell 脚本的启动并不难被检测到,但 Shell 脚本的终止检测却并不容易,因为我们无法确定脚本会按照预期地正常结束,还是由于意外的错误导致失败。当脚本执行失败时,将正在处理的内容记录下来是非常有用的做法,但有时候这样做起来并不方便。而 [Bash][2] 中 `trap` 命令的存在正是为了解决这个问题,它可以捕获到脚本的终止信号,并以某种预设的方式作出应对。
|
||||
|
||||
@ -19,22 +20,21 @@ Shell 脚本的启动并不难被检测到,但 Shell 脚本的终止检测却
|
||||
|
||||
如果出现了一个错误,可能导致发生一连串错误。下面示例脚本中,首先在 `/tmp` 中创建一个临时目录,这样可以在临时目录中执行解包、文件处理等操作,然后再以另一种压缩格式进行打包:
|
||||
|
||||
|
||||
```
|
||||
#!/usr/bin/env bash
|
||||
CWD=`pwd`
|
||||
TMP=${TMP:-/tmp/tmpdir}
|
||||
|
||||
## create tmp dir
|
||||
mkdir $TMP
|
||||
mkdir "${TMP}"
|
||||
|
||||
## extract files to tmp
|
||||
tar xf "${1}" --directory $TMP
|
||||
tar xf "${1}" --directory "${TMP}"
|
||||
|
||||
## move to tmpdir and run commands
|
||||
pushd $TMP
|
||||
pushd "${TMP}"
|
||||
for IMG in *.jpg; do
|
||||
mogrify -verbose -flip -flop $IMG
|
||||
mogrify -verbose -flip -flop "${IMG}"
|
||||
done
|
||||
tar --create --file "${1%.*}".tar *.jpg
|
||||
|
||||
@ -42,22 +42,21 @@ tar --create --file "${1%.*}".tar *.jpg
|
||||
popd
|
||||
|
||||
## bundle with bzip2
|
||||
bzip2 --compress $TMP/"${1%.*}".tar \
|
||||
--stdout > "${1%.*}".tbz
|
||||
bzip2 --compress "${TMP}"/"${1%.*}".tar \
|
||||
--stdout > "${1%.*}".tbz
|
||||
|
||||
## clean up
|
||||
/usr/bin/rm -r /tmp/tmpdir
|
||||
```
|
||||
|
||||
一般情况下,这个脚本都可以按照预期执行。但如果归档文件中的文件是 PNG 文件而不是期望的 JPEG 文件,脚本就会在中途失败,这时候另一个问题就出现了:最后一步删除临时目录的操作没有被正常执行。如果你手动把临时目录删掉,倒是不会造成什么影响,但是如果没有手动把临时目录删掉,在下一次执行这个脚本的时候,就会在一个残留着很多临时文件的临时目录里执行了。
|
||||
一般情况下,这个脚本都可以按照预期执行。但如果归档文件中的文件是 PNG 文件而不是期望的 JPEG 文件,脚本就会在中途失败,这时候另一个问题就出现了:最后一步删除临时目录的操作没有被正常执行。如果你手动把临时目录删掉,倒是不会造成什么影响,但是如果没有手动把临时目录删掉,在下一次执行这个脚本的时候,它必须处理一个现有的临时目录,里面充满了不可预知的剩余文件。
|
||||
|
||||
其中一个解决方案是在脚本开头增加一个预防性删除逻辑用来处理这种情况。但这种做法显得有些暴力,而我们更应该从结构上解决这个问题。使用 `trap` 是一个优雅的方法。
|
||||
|
||||
### 使用 `trap` 捕获信号
|
||||
### 使用 trap 捕获信号
|
||||
|
||||
我们可以通过 `trap` 捕捉程序运行时的信号。如果你使用过 `kill` 或者 `killall` 命令,那你就已经使用过名为 `SIGTERM` 的信号了。除此以外,还可以执行 `trap -l` 或 `trap --list` 命令列出其它更多的信号:
|
||||
|
||||
|
||||
```
|
||||
$ trap --list
|
||||
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
|
||||
@ -85,40 +84,38 @@ $ trap --list
|
||||
|
||||
例如,下面的这行语句可以捕获到在进程运行时用户按下 `Ctrl + C` 组合键发出的 `SIGINT` 信号:
|
||||
|
||||
|
||||
```
|
||||
`trap "{ echo 'Terminated with Ctrl+C'; }" SIGINT`
|
||||
trap "{ echo 'Terminated with Ctrl+C'; }" SIGINT
|
||||
```
|
||||
|
||||
因此,上文中脚本的缺陷可以通过使用 `trap` 捕获 `SIGINT`、`SIGTERM`、进程错误退出、进程正常退出等信号,并正确处理临时目录的方式来修复:
|
||||
|
||||
|
||||
```
|
||||
#!/usr/bin/env bash
|
||||
CWD=`pwd`
|
||||
TMP=${TMP:-/tmp/tmpdir}
|
||||
|
||||
trap \
|
||||
"{ /usr/bin/rm -r $TMP ; exit 255; }" \
|
||||
SIGINT SIGTERM ERR EXIT
|
||||
"{ /usr/bin/rm -r "${TMP}" ; exit 255; }" \
|
||||
SIGINT SIGTERM ERR EXIT
|
||||
|
||||
## create tmp dir
|
||||
mkdir $TMP
|
||||
tar xf "${1}" --directory $TMP
|
||||
mkdir "${TMP}"
|
||||
tar xf "${1}" --directory "${TMP}"
|
||||
|
||||
## move to tmp and run commands
|
||||
pushd $TMP
|
||||
pushd "${TMP}"
|
||||
for IMG in *.jpg; do
|
||||
mogrify -verbose -flip -flop $IMG
|
||||
mogrify -verbose -flip -flop "${IMG}"
|
||||
done
|
||||
tar --create --file "${1%.*}".tar *.jpgh
|
||||
tar --create --file "${1%.*}".tar *.jpg
|
||||
|
||||
## move back to origin
|
||||
popd
|
||||
|
||||
## zip tar
|
||||
bzip2 --compress $TMP/"${1%.*}".tar \
|
||||
--stdout > "${1%.*}".tbz
|
||||
--stdout > "${1%.*}".tbz
|
||||
```
|
||||
|
||||
对于更复杂的功能,还可以用 [Bash 函数][3]来简化 `trap` 语句。
|
||||
@ -134,7 +131,7 @@ via: https://opensource.com/article/20/6/bash-trap
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[HankChow](https://github.com/HankChow)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,119 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (tanslating)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (GNOME 3.38 is Here With Customizable App Grid, Performance Improvements and Tons of Other Changes)
|
||||
[#]: via: (https://itsfoss.com/gnome-3-38-release/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
GNOME 3.38 is Here With Customizable App Grid, Performance Improvements and Tons of Other Changes
|
||||
======
|
||||
|
||||
[GNOME 3.36][1] brought some much-needed improvements along with a major performance boost. Now, after 6 months, we’re finally here with GNOME 3.38 with a big set of changes.
|
||||
|
||||
### GNOME 3.38 Key Features
|
||||
|
||||
Here are the main highlight of GNOME 3.38 codenamed Orbis:
|
||||
|
||||
[Subscribe to our YouTube channel for more Linux videos][2]
|
||||
|
||||
#### Customizable App Menu
|
||||
|
||||
The app grid or the app menu will now be customizable as part of a big change in GNOME 3.38.
|
||||
|
||||
Now, you can create folders by dragging application icons over each other and move them to/from folders and set it right back in the app grid. You can also just reposition the icons as you want in the app grid.
|
||||
|
||||
![][3]
|
||||
|
||||
Also, these changes are some basic building blocks for upcoming design changes planned for future updates — so it’ll be exciting to see what we can expect.
|
||||
|
||||
#### Calendar Menu Updates
|
||||
|
||||
![][4]
|
||||
|
||||
The notification area is a lot cleaner with the recent GNOME updates but now with GNOME 3.38, you can finally access calendar events right below the calendar area to make things convenient and easy to access.
|
||||
|
||||
It’s not a major visual overhaul, but there’s a few improvements to it.
|
||||
|
||||
#### Parental Controls Improvement
|
||||
|
||||
You will observe a parental control service as a part of GNOME 3.38. It supports integration with various components of the desktop, the shell, the settings, and others to help you limit what a user can access.
|
||||
|
||||
#### The Restart Button
|
||||
|
||||
Some subtle improvements lead to massive changes and this is exactly one of those changes. It’s always annoying to click on the “Power Off” / “Shut down” button first and then hit the “Restart” button to reboot the system.
|
||||
|
||||
So, with GNOME 3.38, you will finally notice a “Restart” entry as a separate button which will save you click and give you a peace of mind.
|
||||
|
||||
#### Screen Recording Improvements
|
||||
|
||||
[GNOME shell’s built-in screen record][5] is now a separate system service which should potentially make recording the screen a smooth experience.
|
||||
|
||||
Also, window screencasting had several improvements to it along with some bug fixes:
|
||||
|
||||
#### GNOME apps Updates
|
||||
|
||||
The GNOME calculator has received a lot of bug fixes. In addition to that, you will also find some major changes to the [epiphany GNOME browser][6].
|
||||
|
||||
GNOME Boxes now lets you pick the OS from a list of operating systems and GNOME Maps was updated with some UI changes as well.
|
||||
|
||||
Not just limited to these, you will also find subtle updates and fixes to GNOME control center, Contacts, Photos, Nautilus, and some other packages.
|
||||
|
||||
#### Performance & multi-monitor support improvements
|
||||
|
||||
There’s a bunch of under-the-hood improvements to improve GNOME 3.38 across the board. For instance, there were some serious fixes to [Mutter][7] which now lets two monitors run at different refresh rates.
|
||||
|
||||
![][8]
|
||||
|
||||
Previously, if you had one monitor with a 60 Hz refresh rate and another with 144 Hz, the one with the slower rate will limit the second monitor. But, with the improvements in GNOME 3.38, it will handle multi-monitors without limiting any of them.
|
||||
|
||||
Also, some changes reported by [Phoronix][9] pointed out around 10% lower render time in some cases. So, that’s definitely a great performance optimization.
|
||||
|
||||
#### Miscellaneous other changes
|
||||
|
||||
* Battery percentage indicator
|
||||
* Restart option in the power menu
|
||||
* New welcome tour
|
||||
* Fingerprint login
|
||||
* QR code scanning for sharing Wi-Fi hotspot
|
||||
* Privacy and other improvements to GNOME Browser
|
||||
* GNOME Maps is now responsive and changes its size based on the screen
|
||||
* Revised icons
|
||||
|
||||
|
||||
|
||||
You can find a details list of changes in their official [changelog][10].
|
||||
|
||||
### Wrapping Up
|
||||
|
||||
GNOME 3.38 is indeed an impressive update to improve the GNOME experience. Even though the performance was greatly improved with GNOME 3.36, more optimizations is a very good thing for GNOME 3.38.
|
||||
|
||||
GNOME 3.38 will be available in Ubuntu 20.10 and [Fedora 33][11]. Arch and Manjaro users should be getting it soon.
|
||||
|
||||
I think there are plenty of changes in right direction. What do you think?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/gnome-3-38-release/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/ankush/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/gnome-3-36-release/
|
||||
[2]: https://www.youtube.com/c/itsfoss?sub_confirmation=1
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/09/gnome-app-arranger.jpg?resize=799%2C450&ssl=1
|
||||
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/09/gnome-3-38-calendar-menu.png?resize=800%2C721&ssl=1
|
||||
[5]: https://itsfoss.com/gnome-screen-recorder/
|
||||
[6]: https://en.wikipedia.org/wiki/GNOME_Web
|
||||
[7]: https://en.wikipedia.org/wiki/Mutter_(software)
|
||||
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/09/gnome-multi-monitor-refresh-rate.jpg?resize=800%2C369&ssl=1
|
||||
[9]: https://www.phoronix.com/scan.php?page=news_item&px=GNOME-3.38-Last-Min-Mutter
|
||||
[10]: https://help.gnome.org/misc/release-notes/3.38
|
||||
[11]: https://itsfoss.com/fedora-33/
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,112 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Integrate your calendar with Ansible to avoid schedule conflicts)
|
||||
[#]: via: (https://opensource.com/article/20/10/calendar-ansible)
|
||||
[#]: author: (Nicolas Leiva https://opensource.com/users/nicolas-leiva)
|
||||
|
||||
Integrate your calendar with Ansible to avoid schedule conflicts
|
||||
======
|
||||
Make sure your automation workflow's schedule doesn't conflict with
|
||||
something else by integrating a calendar app into Ansible.
|
||||
![Calendar close up snapshot][1]
|
||||
|
||||
Is "anytime" a good time to execute your automation workflow? The answer is probably no, for different reasons.
|
||||
|
||||
If you want to avoid simultaneous changes to minimize the impact on critical business processes and reduce the risk of unintended service disruptions, then no one else should be attempting to make changes at the same time your automation is running.
|
||||
|
||||
In some scenarios, there could be an ongoing scheduled maintenance window. Or maybe there is a big event coming up, a critical business time, or a holiday—or maybe you prefer not to make changes on a Friday night.
|
||||
|
||||
![Street scene with a large calendar and people walking][2]
|
||||
|
||||
([Curtis MacNewton][3], [CC BY-ND 2.0][4])
|
||||
|
||||
Whatever the reason, you want to signal this information to your automation platform and prevent the execution of periodic or ad-hoc tasks during specific time slots. In change management jargon, I am talking about specifying blackout windows when change activity should not occur.
|
||||
|
||||
### Calendar integration in Ansible
|
||||
|
||||
How can you accomplish this in [Ansible][5]? While it has no calendar function per se, Ansible's extensibility will allow it to integrate with any calendar application that has an API.
|
||||
|
||||
The goal is this: Before you execute any automation or change activity, you execute a `pre-task` that checks whether something is already scheduled in the calendar (now or soon enough) and confirms you are not in the middle of a blocked timeslot.
|
||||
|
||||
Imagine you have a fictitious module named `calendar`, and it can connect to a remote calendar, like Google Calendar, to determine if the time you specify has otherwise been marked as busy. You could write a playbook that looks like this:
|
||||
|
||||
|
||||
```
|
||||
\- name: Check if timeslot is taken
|
||||
calendar:
|
||||
time: "{{ ansible_date_time.iso8601 }}"
|
||||
register: output
|
||||
```
|
||||
|
||||
Ansible facts will give `ansible_date_time`, which is passed to the `calendar` module to verify the time availability so that it can register the response (`output`) to use in subsequent tasks.
|
||||
|
||||
If your calendar looks like this:
|
||||
|
||||
![Google Calendar screenshot][6]
|
||||
|
||||
(Nicolas Leiva, [CC BY-SA 4.0][7])
|
||||
|
||||
Then the output of this task would highlight the fact this timeslot is taken (`busy: true`):
|
||||
|
||||
|
||||
```
|
||||
ok: [localhost] => {
|
||||
"output": {
|
||||
"busy": true,
|
||||
"changed": false,
|
||||
"failed": false,
|
||||
"msg": "The timeslot 2020-09-02T17:53:43Z is busy: true"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Prevent tasks from running
|
||||
|
||||
Next, [Ansible Conditionals][8] will help prevent the execution of any further tasks. As a simple example, you could use a `when` statement on the next task to enforce that it runs only when the field `busy` in the previous output is not `true`:
|
||||
|
||||
|
||||
```
|
||||
tasks:
|
||||
- shell: echo "Run this only when not busy!"
|
||||
when: not output.busy
|
||||
```
|
||||
|
||||
### Conclusion
|
||||
|
||||
In a [previous article][9], I said Ansible is a framework to wire things together, interconnecting different building blocks to orchestrate an end-to-end automation workflow.
|
||||
|
||||
This article looked at how playbooks can integrate or talk to a calendar application to check availability. However, I am just scratching the surface! For example, your tasks could also block a timeslot in the calendar… the sky is the limit.
|
||||
|
||||
In my next article, I will dig into how the `calendar` module is built and how other programming languages can be used with Ansible. Stay tuned if you are a [Go][10] fan like me!
|
||||
|
||||
* * *
|
||||
|
||||
_This originally appeared on Medium as [Ansible and Google Calendar integration for change management][11] under a CC BY-SA 4.0 license and is republished with permission._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/10/calendar-ansible
|
||||
|
||||
作者:[Nicolas Leiva][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/nicolas-leiva
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/calendar.jpg?itok=jEKbhvDT (Calendar close up snapshot)
|
||||
[2]: https://opensource.com/sites/default/files/uploads/street-calendar.jpg (Street scene with a large calendar and people walking)
|
||||
[3]: https://www.flickr.com/photos/7841127@N02/4217116202
|
||||
[4]: https://creativecommons.org/licenses/by-nd/2.0/
|
||||
[5]: https://docs.ansible.com/ansible/latest/index.html
|
||||
[6]: https://opensource.com/sites/default/files/uploads/googlecalendarexample.png (Google Calendar screenshot)
|
||||
[7]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[8]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html
|
||||
[9]: https://medium.com/swlh/python-and-ansible-to-automate-a-network-security-workflow-28b9a44660c6
|
||||
[10]: https://golang.org/
|
||||
[11]: https://medium.com/swlh/ansible-and-google-calendar-integration-for-change-management-7c00553b3d5a
|
118
sources/tech/20201013 Install MariaDB or MySQL on Linux.md
Normal file
118
sources/tech/20201013 Install MariaDB or MySQL on Linux.md
Normal file
@ -0,0 +1,118 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Install MariaDB or MySQL on Linux)
|
||||
[#]: via: (https://opensource.com/article/20/10/mariadb-mysql-linux)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
Install MariaDB or MySQL on Linux
|
||||
======
|
||||
Get started using an open source SQL database on your Linux system.
|
||||
![Person standing in front of a giant computer screen with numbers, data][1]
|
||||
|
||||
Both [MariaDB][2] and [MySQL][3] are open source databases that use SQL and share the same original codebase. MariaDB is a drop-in replacement for MySQL, so much so that you use the same command (`mysql`) to interact with MySQL and MariaDB databases. This article, therefore, applies equally to MariaDB and MySQL.
|
||||
|
||||
### Install MariaDB
|
||||
|
||||
You can install MariaDB using your Linux distribution's package manager. On most distributions, MariaDB is split into a server package and a client package. The server package provides the database "engine," the part of MariaDB that runs (usually on a physical server) in the background, listening for data input or requests for data output. The client package provides the command `mysql`, which you can use to communicate with the server.
|
||||
|
||||
On RHEL, Fedora, CentOS, or similar:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install mariadb mariadb-server`
|
||||
```
|
||||
|
||||
On Debian, Ubuntu, Elementary, or similar:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo apt install mariadb-client mariadb-server`
|
||||
```
|
||||
|
||||
Other systems may package MariaDB differently systems, so you may need to search your software repository to learn how your distribution's maintainers provide it.
|
||||
|
||||
### Start MariaDB
|
||||
|
||||
Because MariaDB is designed to function, in part, as a database server, it can run on one computer and be administered from another. As long as you have access to the computer running it, you can use the `mysql` command to administer the database. I ran MariaDB on my local computer when writing this article, but it's just as likely that you'll interact with a MariaDB database hosted on a remote system.
|
||||
|
||||
Before starting MariaDB, you must create an initial database. You should define the user you want MariaDB to use when initializing its file structure. By default, MariaDB uses the current user, but you probably want it to use a dedicated user account. Your package manager probably configured a system user and group for you. Use `grep` to find out whether there's a `mysql` group:
|
||||
|
||||
|
||||
```
|
||||
$ grep mysql /etc/group
|
||||
mysql❌27:
|
||||
```
|
||||
|
||||
You can also look in `/etc/passwd` for a dedicated user, but usually, where there's a group, there's also a user. If there isn't a dedicated `mysql` user and group, look through `/etc/group` for an obvious alternative (such as `mariadb`). Failing that, read your distribution's documentation to learn how MariaDB runs.
|
||||
|
||||
Assuming your install uses `mysql`, initialize the database environment:
|
||||
|
||||
|
||||
```
|
||||
$ sudo mysql_install_db --user=mysql
|
||||
Installing MariaDB/MySQL system tables in '/var/lib/mysql'...
|
||||
OK
|
||||
[...]
|
||||
```
|
||||
|
||||
The result of this step reveals the next tasks you must perform to configure MariaDB:
|
||||
|
||||
|
||||
```
|
||||
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
|
||||
To do so, start the server, then issue the following commands:
|
||||
|
||||
'/usr/bin/mysqladmin' -u root password 'new-password'
|
||||
'/usr/bin/mysqladmin' -u root -h $(hostname) password 'new-password'
|
||||
|
||||
Alternatively you can run:
|
||||
'/usr/bin/mysql_secure_installation'
|
||||
|
||||
which will also give you the option of removing the test
|
||||
databases and anonymous user created by default. This is
|
||||
strongly recommended for production servers.
|
||||
```
|
||||
|
||||
Start MariaDB using your distribution's init system:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo systemctl start mariadb`
|
||||
```
|
||||
|
||||
To enable the MariaDB server to start upon boot:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo systemctl enable --now mariadb`
|
||||
```
|
||||
|
||||
Now that you have a MariaDB server to communicate with, set a password for it:
|
||||
|
||||
|
||||
```
|
||||
mysqladmin -u root password 'myreallysecurepassphrase'
|
||||
mysqladmin -u root -h $(hostname) password 'myreallysecurepassphrase'
|
||||
```
|
||||
|
||||
Finally, if you intend to use this installation on a production server, run the `mysql_secure_installation` command before going live.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/10/mariadb-mysql-linux
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data)
|
||||
[2]: https://mariadb.org/
|
||||
[3]: https://www.mysql.com/
|
@ -0,0 +1,119 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (GNOME 3.38 is Here With Customizable App Grid, Performance Improvements and Tons of Other Changes)
|
||||
[#]: via: (https://itsfoss.com/gnome-3-38-release/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
GNOME 3.38 携可定制应用程序网格,性能改善和大量其它的更改而来
|
||||
======
|
||||
|
||||
[GNOME 3.36][1] 带来大量急需改善,同时也带来性能的重大提升。现在,在6个月后,我们终于和具有一系列的更改的 GNOME 3.38 一起到来。
|
||||
|
||||
### GNOME 3.38 主要特色
|
||||
|
||||
这里是 GNOME 3.38 (代码名称:Orbis) 的主要亮点:
|
||||
|
||||
[更多 Linux 视频,请订阅我们的 YouTube 频道][2]
|
||||
|
||||
#### 可定制应用程序菜单
|
||||
|
||||
作为 GNOME 3.38 重大更改中的一部分,应用程序网格或应用程序菜单现在是可以可定制的。
|
||||
|
||||
现在,你可以通过拖拽每个应用程序图标来创建文件夹,将它们移到/移出文件夹,并且可以在应用程序网格中重新设置回来。你也可以在应用程序网格中如你所想一样的重新定位图标。
|
||||
|
||||
![][3]
|
||||
|
||||
此外,这些变化是一些即将到来的未来设计更改更新的基本组成部分 — 因此,看到我们可以期待的东西会很令人兴奋。
|
||||
|
||||
#### 日历菜单更新
|
||||
|
||||
![][4]
|
||||
|
||||
随着最近一次的 GNOME 更新,通知区整洁了很多,但是现在随着 GNOME 3.38 的到来,你终于可以通过访问日历区正下方的日历事件来更方便地处理事情。
|
||||
|
||||
它不是一个主要的可见改造,但是它也有不少的改善。
|
||||
|
||||
#### 家长控制改善
|
||||
|
||||
你将会注意作为 GNOME 3.38 一部分的家长控制服务。它支持与桌面,shell,设置以及其它各种各样组件的集成来帮助你限制用户可以访问的内容。
|
||||
|
||||
#### 重新启动按钮
|
||||
|
||||
一些细微的改善导致了巨大的变化,重新启动按钮正是其中的一个变化。先单击 “关闭电源” / “关机” 按钮,再单击 “重新启动” 按钮的操作来重新启动系统总是让人很烦闷。
|
||||
|
||||
因此,随着 GNOME 3.38 的到来,你将最终会注意到一个作为单独按钮的 “重新启动” ,这将节省你的单击次数,平复你烦闷的心情。
|
||||
|
||||
#### 屏幕录制改善
|
||||
|
||||
[GNOME shell 的内置屏幕录制][5] 现在是一项独立的系统服务,这可能会使录制屏幕成为一种平滑流畅的体验。
|
||||
|
||||
另外,窗口截屏也有一些改善,并修复了一些错误。
|
||||
|
||||
#### GNOME 应用程序更新
|
||||
|
||||
GNOME 计算器也收到很多的错误修复。除此之外,你也将发现 [epiphany GNOME 浏览器][6] 的一些重大改变.
|
||||
|
||||
GNOME Boxes 现在允许你从一个操作系统列表中选择将要运行的操作系统,GNOME 地图也有一些图像用户界面上的更改。
|
||||
|
||||
当然,不仅限于这些,你页将注意到 GNOME 控制中心,联系人,照片,Nautilus,以及其它一些软件包的细微更新和修复。
|
||||
|
||||
#### 性能和多显示器支持改善
|
||||
|
||||
这里有一大堆隐藏改善来全面地改善 GNOME 3.38 。 例如,[Mutter][7] 有一些重要的修复,它现在允许在两个显示器中使用不同的刷新频率。
|
||||
|
||||
![][8]
|
||||
|
||||
先前,如果一台显示器的刷新频率为 60 Hz,而另一台的刷新频率为 144 Hz ,那么刷新频率较慢的显示器将限制另外一台显示器的刷新频率。但是,随着在 GNOME 3.38 中的改善,它将能够处理多个显示器,而不会使显示器相互限制。
|
||||
|
||||
另外,[Phoronix][9] 报告的一些更改指出,在一些情况下,缩短大约 10% 的渲染时间。因此,巨大的性能优化是很确定的。
|
||||
|
||||
#### 各种各样的其它更改
|
||||
|
||||
* 电池百分比指示器
|
||||
* 在电源菜单中的重新启动选项
|
||||
* 新的欢迎参观N
|
||||
* 指纹登录
|
||||
* 二维码扫描共享 Wi-Fi 热点
|
||||
* GNOME 浏览器的隐私和其它改善
|
||||
* GNOME 地图现在反应敏捷并能根据屏幕大小改变其大小
|
||||
* 重新修订的图标
|
||||
|
||||
|
||||
|
||||
你可以在它们的官方 [更改日志][10] 中找到一个详细的更改列表。
|
||||
|
||||
### 总结
|
||||
|
||||
GNOME 3.38 确实是一个令人赞叹的改善 GNOME 用户体验的更新。尽管 GNOME 3.36 带来了性能的很大改善, 但是针对 GNOME 3.38 的更多优化仍然是一件非常好的事.
|
||||
|
||||
GNOME 3.38 将在 Ubuntu 20.10 和 [Fedora 33][11] 中可用。Arch 和 Manjaro 用户应该很快就能获得。
|
||||
|
||||
我认为在正确的方向上有大量的更改。你觉得呢?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/gnome-3-38-release/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[robsean](https://github.com/robsean)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/ankush/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/gnome-3-36-release/
|
||||
[2]: https://www.youtube.com/c/itsfoss?sub_confirmation=1
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/09/gnome-app-arranger.jpg?resize=799%2C450&ssl=1
|
||||
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/09/gnome-3-38-calendar-menu.png?resize=800%2C721&ssl=1
|
||||
[5]: https://itsfoss.com/gnome-screen-recorder/
|
||||
[6]: https://en.wikipedia.org/wiki/GNOME_Web
|
||||
[7]: https://en.wikipedia.org/wiki/Mutter_(software)
|
||||
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/09/gnome-multi-monitor-refresh-rate.jpg?resize=800%2C369&ssl=1
|
||||
[9]: https://www.phoronix.com/scan.php?page=news_item&px=GNOME-3.38-Last-Min-Mutter
|
||||
[10]: https://help.gnome.org/misc/release-notes/3.38
|
||||
[11]: https://itsfoss.com/fedora-33/
|
@ -0,0 +1,111 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Integrate your calendar with Ansible to avoid schedule conflicts)
|
||||
[#]: via: (https://opensource.com/article/20/10/calendar-ansible)
|
||||
[#]: author: (Nicolas Leiva https://opensource.com/users/nicolas-leiva)
|
||||
|
||||
将你的日历与 Ansible 集成,以避免与日程冲突
|
||||
======
|
||||
通过将一个日历应用集成到 Ansible 中来确保你的自动化工作流计划不会与其他东西冲突。
|
||||
![Calendar close up snapshot][1]
|
||||
|
||||
”随时“是执行自动化工作流的好时机吗?答案可能是否定的,原因各不相同。
|
||||
|
||||
如果你希望避免同时进行更改,以最大限度地减少对关键业务流程的影响,并降低意外服务中断的风险,那么其他人不应该试图在你的自动化运行的同时进行更改。
|
||||
|
||||
在某些情况下,可能存在一个正在进行的计划维护窗口。 或者,可能有大型事件即将来临、一个关键的业务时间,或者假期,你或许不想在星期五晚上进行更改。
|
||||
|
||||
![Street scene with a large calendar and people walking][2]
|
||||
|
||||
([Curtis MacNewton][3], [CC BY-ND 2.0][4])
|
||||
|
||||
无论出于什么原因,你都希望将此信息发送到你的自动化平台,并防止在特定时间段内执行周期或临时任务。在变更管理的行话中,我说的是当变更活动不应该发生时,指定封锁窗口。
|
||||
|
||||
### Ansible 中的日历集成
|
||||
|
||||
如何在 [Ansible][5] 中实现这个功能?虽然它本身没有日历功能,但 Ansible 的可扩展性将允许它与任何具有 API 的日历应用集成。
|
||||
|
||||
目标是这样的:在执行任何自动化或变更活动之前,你要执行一个 `pre-task` ,它会检查日历中是否已经安排了某些事情(目前或最近),并确认你没有在一个阻塞的时间段中。
|
||||
|
||||
想象一下,你有一个名为 `calendar` 的虚构模块,它可以连接到一个远程日历,比如 Google 日历,以确定你指定的时间是否已经以其他方式被标记为繁忙。你可以写一个类似这样的 playbook:
|
||||
|
||||
|
||||
```
|
||||
\- name: Check if timeslot is taken
|
||||
calendar:
|
||||
time: "{{ ansible_date_time.iso8601 }}"
|
||||
register: output
|
||||
```
|
||||
|
||||
Ansible 实际会给出 `ansible_date_time`,将其传递给 `calendar` 模块,以验证时间的可用性,以便它可以注册响应 (`output`),用于后续任务。
|
||||
|
||||
如果你的日历是这样的:
|
||||
|
||||
![Google Calendar screenshot][6]
|
||||
|
||||
(Nicolas Leiva, [CC BY-SA 4.0][7])
|
||||
|
||||
那么这个任务的输出就会高亮这个时间段被占用的事实 (`busy: true`):
|
||||
|
||||
|
||||
```
|
||||
ok: [localhost] => {
|
||||
"output": {
|
||||
"busy": true,
|
||||
"changed": false,
|
||||
"failed": false,
|
||||
"msg": "The timeslot 2020-09-02T17:53:43Z is busy: true"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 阻止任务运行
|
||||
|
||||
接下来,[Ansible Conditionals][8] 将帮助阻止所有之后任务的执行。一个简单的例子,你可以在下一个任务上使用 `when` 语句来强制它只有当上一个输出中的 `busy` 字段不是 `true` 时,它才会运行:
|
||||
|
||||
|
||||
```
|
||||
tasks:
|
||||
- shell: echo "Run this only when not busy!"
|
||||
when: not output.busy
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
在[上一篇文章][9]中,我说过 Ansible 是一个将事物连接在一起的框架,将不同的构建相互连接,以协调端到端自动化工作流。
|
||||
|
||||
这篇文章探讨了 playbook 如何与日历应用集成以检查可用性。然而,我只做了一些表面工作!例如,你的任务也可以阻止日历中的一个时间段,这里的发挥空间很大。
|
||||
|
||||
在我的下一篇文章中,我将深入 `calendar` 模块是如何构建的,以及其他编程语言如何与 Ansible 一起使用。如果你和我一样是 [Go][10] 的粉丝,请继续关注!
|
||||
|
||||
* * *
|
||||
|
||||
_这篇文章最初发表在 Medium 上,名为 [Ansible and Google Calendar integration for change management][11],采用 CC BY-SA 4.0 许可,经许可后转载。_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/10/calendar-ansible
|
||||
|
||||
作者:[Nicolas Leiva][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/nicolas-leiva
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/calendar.jpg?itok=jEKbhvDT (Calendar close up snapshot)
|
||||
[2]: https://opensource.com/sites/default/files/uploads/street-calendar.jpg (Street scene with a large calendar and people walking)
|
||||
[3]: https://www.flickr.com/photos/7841127@N02/4217116202
|
||||
[4]: https://creativecommons.org/licenses/by-nd/2.0/
|
||||
[5]: https://docs.ansible.com/ansible/latest/index.html
|
||||
[6]: https://opensource.com/sites/default/files/uploads/googlecalendarexample.png (Google Calendar screenshot)
|
||||
[7]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[8]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html
|
||||
[9]: https://medium.com/swlh/python-and-ansible-to-automate-a-network-security-workflow-28b9a44660c6
|
||||
[10]: https://golang.org/
|
||||
[11]: https://medium.com/swlh/ansible-and-google-calendar-integration-for-change-management-7c00553b3d5a
|
Loading…
Reference in New Issue
Block a user