-
Notifications
You must be signed in to change notification settings - Fork 30
/
startup_items.py
56 lines (40 loc) · 1.61 KB
/
startup_items.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import logging as log
from utils import copy_dir, ensure_dir_owned_by_user
import config
def backup():
log.info('Backing up start up items...')
backup_user_launch_agents()
backup_system_launch_agents()
backup_system_daemons_agents()
def restore():
log.info('Restoring start up items...')
restore_user_launch_agents()
restore_system_launch_agents()
restore_system_daemons_agents()
def backup_user_launch_agents():
source = config.get_user_launch_agents_dir()
dest = config.get_user_launch_agents_backup_dir()
copy_dir(source, dest)
def backup_system_launch_agents():
source = config.get_system_launch_agents_dir()
dest = config.get_system_launch_agents_backup_dir()
copy_dir(source, dest)
def backup_system_daemons_agents():
source = config.get_system_launch_daemons_dir()
dest = config.get_system_launch_daemons_backup_dir()
copy_dir(source, dest)
def restore_user_launch_agents():
source = config.get_user_launch_agents_backup_dir()
dest = config.get_user_launch_agents_dir()
copy_dir(source, dest, with_sudo=True)
ensure_dir_owned_by_user(dest, config.get_user())
def restore_system_launch_agents():
source = config.get_system_launch_agents_backup_dir()
dest = config.get_system_launch_agents_dir()
copy_dir(source, dest, with_sudo=True)
ensure_dir_owned_by_user(dest, 'root:wheel', '644')
def restore_system_daemons_agents():
source = config.get_system_launch_daemons_backup_dir()
dest = config.get_system_launch_daemons_dir()
copy_dir(source, dest, with_sudo=True)
ensure_dir_owned_by_user(dest, 'root:wheel', '644')