You need the `-y` (aka `--assume-yes`) flag when running apt in a script otherwise the thing hangs forever waiting for interactive confirmation for some larger downloads.