diff --git a/src/modules/users/CreateUserJob.cpp b/src/modules/users/CreateUserJob.cpp index 4fbe19c9d..556ff9d89 100644 --- a/src/modules/users/CreateUserJob.cpp +++ b/src/modules/users/CreateUserJob.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2014-2016, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #include "utils/Logger.h" #include "utils/CalamaresUtilsSystem.h" +#include #include #include #include @@ -123,6 +124,29 @@ CreateUserJob::exec() defaultGroups.append( QString( ",%1" ).arg( autologinGroup ) ); } + // If we're looking to reuse the contents of an existing /home + if ( gs->value( "reuseHome" ).toBool() ) + { + QString shellFriendlyHome = "/home/" + m_userName; + QDir existingHome( destDir.absolutePath() + shellFriendlyHome ); + if ( existingHome.exists() ) + { + QString backupDirName = "dotfiles_backup_" + + QDateTime::currentDateTime() + .toString( "yyyy-MM-dd_HH-mm-ss" ); + existingHome.mkdir( backupDirName ); + + CalamaresUtils::System::instance()-> + targetEnvCall( { "sh", + "-c", + "mv -f " + + shellFriendlyHome + "/.* " + + shellFriendlyHome + "/" + + backupDirName + } ); + } + } + int ec = CalamaresUtils::System::instance()-> targetEnvCall( { "useradd", "-m",