If reuseHome is set and if /home/<username> exists, backup dotfiles.
This commit is contained in:
parent
6c6e4a1f88
commit
d65df112dd
@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -23,6 +23,7 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@ -123,6 +124,29 @@ CreateUserJob::exec()
|
|||||||
defaultGroups.append( QString( ",%1" ).arg( autologinGroup ) );
|
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()->
|
int ec = CalamaresUtils::System::instance()->
|
||||||
targetEnvCall( { "useradd",
|
targetEnvCall( { "useradd",
|
||||||
"-m",
|
"-m",
|
||||||
|
Loading…
Reference in New Issue
Block a user