Тут показані розбіжності між вибраною ревізією та поточною версією сторінки.
Наступна ревізія | Попередня ревізія Остання ревізія Both sides next revision | ||
systemd [2015/03/18 00:47] wombat створено |
systemd [2015/04/16 10:28] wombat настройка системного времени |
||
---|---|---|---|
Рядок 1: | Рядок 1: | ||
====== systemd ====== | ====== systemd ====== | ||
+ | |||
+ | ====== Настройка ====== | ||
===== Службы ===== | ===== Службы ===== | ||
Рядок 32: | Рядок 34: | ||
sudo systemctl start updatedb.timer | sudo systemctl start updatedb.timer | ||
+ | |||
+ | |||
+ | ===== Настройка времени ===== | ||
+ | |||
+ | timedatectl list-timezones | ||
+ | sudo timedatectl set-timezone Europe/Kiev | ||
+ | |||
+ | ((https://wiki.archlinux.org/index.php/Time)) | ||
+ | |||
+ | |||
+ | ====== Создание ====== | ||
+ | |||
+ | ==== Службы ==== | ||
+ | |||
+ | <file ini '/etc/systemd/system/mount-data.service'> | ||
+ | [Unit] | ||
+ | Description=Mount USB HDD | ||
+ | |||
+ | [Service] | ||
+ | Type=oneshot | ||
+ | RemainAfterExit=yes | ||
+ | |||
+ | #PIDFile=/run/thttpd.pid | ||
+ | #ExecStart=/usr/bin/thttpd -D -C /etc/thttpd.conf | ||
+ | ExecStart=/usr/local/bin/mount_data.sh | ||
+ | #ExecReload= | ||
+ | ExecStop=/usr/local/bin/mount_data.sh unmount | ||
+ | #Restart=always | ||
+ | |||
+ | # No USB HDD attached | ||
+ | RestartPreventExitStatus=1 | ||
+ | |||
+ | |||
+ | #[Install] | ||
+ | #WantedBy=multi-user.target | ||
+ | </file> | ||
+ | |||
+ | <file bash '/usr/local/bin/mount_data.sh'> | ||
+ | #!/bin/bash | ||
+ | |||
+ | if [ "$1" == "unmount" ] | ||
+ | then | ||
+ | MOUNT=`mount | grep '/mnt/data'` | ||
+ | if [ -n "$MOUNT" ] | ||
+ | then | ||
+ | echo "Unmounting /mnt/data" | ||
+ | umount /mnt/data | ||
+ | else | ||
+ | echo "ERROR: /mnt/data is not mounted." | ||
+ | fi | ||
+ | else | ||
+ | if [ -e /dev/sda4 ] | ||
+ | then | ||
+ | echo "Mounting /dev/sda4 as /mnt/data" | ||
+ | mount /mnt/data | ||
+ | else | ||
+ | echo "ERROR: No HDD." | ||
+ | exit 1 | ||
+ | fi | ||
+ | fi | ||
+ | </file> | ||
+ | |||
+ | <file systemd '/etc/systemd/system/multi-user.target.wants/transmission.service'> | ||
+ | [Unit] | ||
+ | ... | ||
+ | Requires=mount-data.service | ||
+ | After=mount-data.service | ||
+ | ... | ||
+ | </file> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Ссылки ===== | ||
+ | |||
+ | http://www.freedesktop.org/software/systemd/man/systemd.service.html | ||
+ | |||
+ | http://www.freedesktop.org/software/systemd/man/systemd.unit.html | ||
+ | |||
+ | https://wiki.archlinux.org/index.php/Systemd#Writing_unit_files |