5858run_scripts /usr/lib/coriolis/firstboot/user
5959
6060if [ $first_error -eq 0 ]; then
61- echo "All the scripts completed successfully, creating /var/lib/coriolis/firstboot-complete"
61+ echo "All the scripts completed successfully."
62+ echo "Creating /var/lib/coriolis/firstboot-complete"
6263 mkdir -p /var/lib/coriolis
6364 touch /var/lib/coriolis/firstboot-complete
6465else
65- echo "One of the scripts failed, won't create /var/lib/coriolis/firstboot-complete"
66+ echo "One of the scripts failed."
67+ echo "Won't create /var/lib/coriolis/firstboot-complete"
6668fi
6769
6870exit $first_error
@@ -168,8 +170,23 @@ def register_firstboot_script(
168170 self ,
169171 script : str ,
170172 index : int = 0 ,
171- user_provided = True ,
173+ user_provided : bool = True ,
174+ script_filename : str | None = None ,
172175 ):
176+ """Register a script to be executed during the first replica boot.
177+
178+ :param script: the script content
179+ :param index: script execution index (0-99), used as a script filename
180+ prefix. The scripts will be executed in alphabetic order,
181+ the Coriolis scripts first and then user provided scripts
182+ afterwards.
183+ :param user_provider: whether this is a Coriolis internal script
184+ (executed first) or user provided script.
185+ :param script_filename: optional script filename. The index parameter
186+ will be ignored when explicitly specifying
187+ the filename. Coriolis internal scripts should
188+ specify a filename to facilitate debugging.
189+ """
173190 pass
174191
175192 @abc .abstractmethod
@@ -796,8 +813,10 @@ def register_firstboot_script(
796813 self ,
797814 script : str ,
798815 index : int = 0 ,
799- user_provided = True ,
816+ user_provided : bool = True ,
817+ script_filename : str | None = None ,
800818 ):
819+
801820 if len (script ) == 0 :
802821 LOG .debug ("Empty first-boot script, skipping..." )
803822 return
@@ -806,8 +825,12 @@ def register_firstboot_script(
806825 script_dir = "/usr/lib/coriolis/firstboot/user"
807826 else :
808827 script_dir = "/usr/lib/coriolis/firstboot/service"
809- unique_id = str (uuid .uuid4 ()).split ("-" )[0 ]
810- script_path = os .path .join (script_dir , f"{ index :02d} -{ unique_id } .sh" )
828+
829+ if not script_filename :
830+ unique_id = str (uuid .uuid4 ()).split ("-" )[0 ]
831+ script_filename = f"{ index :02d} -{ unique_id } .ps1"
832+
833+ script_path = os .path .join (script_dir , script_filename )
811834
812835 self ._exec_cmd_chroot (f"mkdir -p { script_dir } " )
813836 self ._write_file_sudo (script_path , script )
0 commit comments