summaryrefslogtreecommitdiff
path: root/src/core/procedures/automatic
blob: f088ff8668e83088d7afc334449d21901c2e4764 (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
# This procedure is in development!!
# This is a procedure for automatic deployment/installation/configuration of systems. # TODO: document! (readme, notes about deployment profiles, examples, ...)
# check /usr/share/aif/examples for some example config files.
# This procedure can easily replace the old quickinst script if you look at the "generic install" config file
# Look at the base procedure to see the phases and which workers they'll execute.
# It should be:
# phase_preparation=(configure intro sysprep select_source runtime_network runtime_repositories runtime_packages)
# phase_basics=(set_clock prepare_disks)
# phase_system=(package_listTODO install_packages auto_fstab auto_networkTODO auto_locale auto_keymap_font configure_system mkinitcpio locales install_bootloader)
# phase_finish=(msg_report)

# In theory, the only manual thing should maybe be configuring the runtime network and putting the configfile in place
# TODO: I don't know if you can do non-interactive dm_crypt stuff.. maybe by pulling luks keyfiles from svn/git/..?
# TODO: for worker_configure_system, we probably want the user to specify hostname, root pass etc.

# for a list of recognized variables, see examples/generic-install-on-sda

depend_procedure core base

var_OPTS_STRING="c:"
var_ARGS_USAGE="-c <config>: Specify a configfile (profile) to be used"
var_AUTOMATIC_PROFILE=""
# TODO: if the user does aif -p automatic -c, then $1 is ":-" ??? if you do -c <something> then it's ok.
process_args ()
{
	if [ "$1" = '-c' ]
	then
		[ -z "$2" ] && die_error "You must specify a config"
		var_AUTOMATIC_PROFILE=$2
	else
		usage
		exit 5
        fi
}


worker_intro ()
{
	notify "Automatic procedure running..."
}


worker_configure ()
{
	var_UI_TYPE=${arg_ui_type:-cli}
	[ -z "$var_AUTOMATIC_PROFILE" ] && die_error "You must specify a config file to use this procedure"
	source $var_AUTOMATIC_PROFILE   || die_error "Could not source config $var_AUTOMATIC_PROFILE"
	var_RUNTIME_REPOSITORIES=$AUTOMATIC_RUNTIME_REPOSITORIES
	var_RUNTIME_PACKAGES=$AUTOMATIC_RUNTIME_PACKAGES
	[ -z "$var_PARTITIONS" ] && die_error "You did not specify a partition scheme"
	[ -z "$var_BLOCKDATA"  ] && die_error "You did not specify a partition scheme"
}

worker_select_source ()
{
        var_PKG_SOURCE_TYPE=${AUTOMATIC_SOURCE:-cd}
        var_FILE_URL=${AUTOMATIC_FILE_URL:-file:///src/core/pkg}
        var_SYNC_URL=${AUTOMATIC_SYNC_URL:-}
}

worker_runtime_network ()
{
	true # for now. we assume the user has taken care of this himself already. doing this interactively wouldn't be a good default anyway.
	# maybe check if network works, if not, try dhcp. let user override by using a static config in his config file
	#if ask_yesno "Do you want to (re)-configure your networking?"
	#then
	#	interactive_runtime_network
	#else
	#	infofy "Ok. skipping network config"
	#fi
}


# Check if we have all needed settings loaded from the profile
worker_runtime_settings ()
{
	if check_is_in svn $var_RUNTIME_PACKAGES
	then
		[ -z "$SVN_USERNAME" ] && ask_string "Please enter your svn username" && SVN_USERNAME=$ANSWER_STRING
		[ -z "$SVN_PASSWORD" ] && ask_password svn #TODO: if user entered incorrect password, the install process will just fail..
		[ -z "$SVN_BASE"     ] && ask_string "What's the base path of your svn repo? (no ending /) " && SVN_BASE=$ANSWER_STRING
		[ -z "$DEPLOY_CLASS" ] && ask_string "Which hostclass are you installing? (optional)" '' 0 && DEPLOY_CLASS=$ANSWER_STRING
		SVN="svn --username $SVN_USERNAME --password $SVN_PASSWORD"
	elif check_is_in moo $var_RUNTIME_PACKAGES
	then
		# Maybe more stuff later
		true
	fi
	[ -z "$HOSTNAME" ] && ask_string "Hostname of target system?" && HOSTNAME=$ANSWER_STRING

	return 0
}


worker_prepare_disks ()
{
	echo "$var_PARTITIONS" > $TMP_PARTITIONS
	echo "$var_BLOCKDATA" > $TMP_BLOCKDEVICES
	process_disks       || die_error "Could not process_disks"
	if ! process_filesystems
	then
		show_warning "Could not process_filesystems"
		txt='also failed to execute properly'
		rollback_filesystems && txt='ended successfully'
		die_error "Something failed while processing the filesystem.  A rollback was executed, which $txt"
	fi
	infofy "Partitions and filesystems made successfully"

	# TODO: fstab? auto-add to fstab with libs? auto mkdir's on target_dir?
	true	
}


worker_install_packages ()
{
        target_prepare_pacman core extra community #TODO: it would be better if this was a separate worker, i think
        [ -z "$TARGET_PACKAGES" ] && die_error "No packages listed to be installed!"
        installpkg
}


worker_set_clock ()
{
	#TODO implement this
	true
}


worker_auto_network () {
	# temporary override because i need to implement this
	true
}


worker_install_bootloader ()
{
	install-grub /dev/sda #TODO: this can be more flexible..
}


worker_runtime_yaourt ()
{
	_yaourt_replace_pacman
}